SQL FUNCTIONS

SQL FUNCTIONS

Postby Valdir » Thu Dec 14, 2017 4: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
Valdir
 
Posts: 20
Joined: Fri Feb 10, 2006 5:21 pm

Re: SQL FUNCTIONS

Postby Valdir » Thu Dec 14, 2017 5:56 pm

up
Valdir - Jundiaí - S.P. - Brasil
Fivewin 16.08
Valdir
 
Posts: 20
Joined: Fri Feb 10, 2006 5:21 pm

Re: SQL FUNCTIONS

Postby karinha » Thu Dec 14, 2017 5:58 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7846
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: SQL FUNCTIONS

Postby nageswaragunupudi » Thu Dec 14, 2017 6: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: Select all  Expand view  RUN
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
User avatar
nageswaragunupudi
 
Posts: 10663
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SQL FUNCTIONS

Postby Valdir » Thu Dec 14, 2017 6: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
Valdir
 
Posts: 20
Joined: Fri Feb 10, 2006 5:21 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 62 guests