FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour SQL FUNCTIONS
Posts: 20
Joined: Fri Feb 10, 2006 05:21 PM
SQL FUNCTIONS
Posted: Thu Dec 14, 2017 04:11 PM
Nages,

fantastic job, congratulations !!!

Please:
 
Why can not I compile this simple example using the SQL functions?

oQry = oServer:Query( "SELECT * FROM nombres" )
oQry:GoBottom()
BEGIN TRANSACTION
cCmdSql:= "INSERT INTO nombres ( "
cCmdSql += "nombre" + ","
cCmdSql += "apellido1" + ","
cCmdSql += "apellido2" + ","
cCmdSql += "direccion" + ","
cCmdSql += "edad" + ","
cCmdSql += "poblacion" + ","
cCmdSql += "provincia )"
cCmdSql += "VALUES("
cCmdSql += "'"+cNombre+"'" +","
cCmdSql += "'"+cApellido1+"'" +","
cCmdSql += "'"+cApellido2+"'" +","
cCmdSql += "'"+cDireccion+"'" +","
cCmdSql += ""+str(cEdad)+"" +","
cCmdSql += "'"+cPoblacion+"'" +","
cCmdSql += "'"+cProvincia+"' )"
oServer:Execute( cCmdSql )
IF oServer:nError = 0
COMMIT()
BEEP()
MSGRUN(OemToAnsi("Registros inclusos com Sucesso..."),OemToAnsi("ATENۂO..."))
ELSE
ROLLBACK()
BEEP()
MSGRUN(OemToAnsi("Nao foi possivel Incluir os Registros..."),OemToAnsi("ATENۂO..."))
oServer:ShowError()
ENDIF
END TRANSACTION
oServer:End()


Returns Syntax error => "Error E0030 Syntax error: 'syntax error at" TRANSACTION "'"
I use the Buildx.bat of FW 1608

Thank you
Valdir - Jundiaí - S.P. - Brasil

Fivewin 16.08
Posts: 20
Joined: Fri Feb 10, 2006 05:21 PM
Re: SQL FUNCTIONS
Posted: Thu Dec 14, 2017 05:56 PM

up

Valdir - Jundiaí - S.P. - Brasil

Fivewin 16.08
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: SQL FUNCTIONS
Posted: Thu Dec 14, 2017 05:58 PM
Valdir wrote:up


Master Nages, look please,

http://fivewin.com.br/index.php?/topic/27381-duvida-com-begin-transaction/

Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: SQL FUNCTIONS
Posted: Thu Dec 14, 2017 06:01 PM

Nages,

fantastic job, congratulations !!!

May I know what for please?
Your posting has nothing to do with any work I had done.
Any way,

There are no commands like BEGIN TRANSACTION, etc.
Are you using TDolphin?

If so, please use
_BeginTransaction( [<oServer>] ), _CommitTransaction( [<oServer>] ), _RollBack( [<oServer>] )
in the place of commands like BEGIN TRANSACTION, etc.

In case you include "tdolphin.ch"
you can also use BEGINMYSQL, COMMITMYSQL, ROLLBACKMYSQL.

In any case, because you are inserting only one row in one single table, there is no need to enclose in Begin and Commit Transaction.


FWH supports FWMARIALIB.
Using this lib, we could write the above code as:
Code (fw): Select all Collapse
nRet := oCn:Insert( "nombres", "nombre,apellido1,apellido2,direccion,edad,poblacion,provincia", ;
      { cNombre, cApellido1 ,cApellido2, cDireccion,cEdad,cPoblacion,cProvincia } )


With FWH MARIADB, for Begin transaction, etc, please use:

oCn:BeginTransaction()
oCn:CommitTransaction()
oCn:RollBack()
Regards



G. N. Rao.

Hyderabad, India
Posts: 20
Joined: Fri Feb 10, 2006 05:21 PM
Re: SQL FUNCTIONS
Posted: Thu Dec 14, 2017 06:49 PM

Dear Mr. Rao.

Thank you for your help, even if it is not a work developed by you.
This SQL world is totally new to me, so I appreciate your teachings.

oCn: BeginTransaction (), oCn: CommitTransaction () and oCn: RollBack () solved the problem.

Thank you

Valdir - Jundiaí - S.P. - Brasil

Fivewin 16.08

Continue the discussion