Page 1 of 1

SQL FUNCTIONS

Posted: Thu Dec 14, 2017 4:11 pm
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

Re: SQL FUNCTIONS

Posted: Thu Dec 14, 2017 5:56 pm
by Valdir
up

Re: SQL FUNCTIONS

Posted: Thu Dec 14, 2017 5:58 pm
by karinha
Valdir wrote:up
Master Nages, look please,

http://fivewin.com.br/index.php?/topic/ ... ansaction/

Regards.

Re: SQL FUNCTIONS

Posted: Thu Dec 14, 2017 6:01 pm
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

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()

Re: SQL FUNCTIONS

Posted: Thu Dec 14, 2017 6:49 pm
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