SQL FUNCTIONS

Post Reply
Valdir
Posts: 20
Joined: Fri Feb 10, 2006 5:21 pm

SQL FUNCTIONS

Post by Valdir »

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
Valdir
Posts: 20
Joined: Fri Feb 10, 2006 5:21 pm

Re: SQL FUNCTIONS

Post by Valdir »

up
Valdir - Jundiaí - S.P. - Brasil
Fivewin 16.08
User avatar
karinha
Posts: 7917
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: SQL FUNCTIONS

Post by karinha »

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
nageswaragunupudi
Posts: 10712
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: SQL FUNCTIONS

Post by nageswaragunupudi »

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: Select all | Expand

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
Valdir
Posts: 20
Joined: Fri Feb 10, 2006 5:21 pm

Re: SQL FUNCTIONS

Post by Valdir »

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
Post Reply