Params before SQL

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
trob
Senior Boarder
Senior Boarder
Posts: 51
Joined: 20.03.2007, 02:24

Params before SQL

Post by trob »

Is it possible to create and set value of a param BEFORE setting value of a ZQuery's SQL statement what contains that param?
Last edited by trob on 20.03.2007, 02:44, edited 1 time in total.
trob
Senior Boarder
Senior Boarder
Posts: 51
Joined: 20.03.2007, 02:24

Post by trob »

In Delphi if i set ParamCheck to False, and run this:

...
DataMod.ZQexec.Params.CreateParam(ftBlob,'kep',ptInput);
DataMod.ZQexec.Params.ParamByName('kep').AsBlob:=kepstream.DataString;
...
UPDATE gyerek SET fenykep=:kep WHERE ...
...

Then it tells me:
Project Vasgyuro.exe raised exception class EZSQLException with message 'SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':kep WHERE ...' at line 1'

So i think that it doesn't assign SQL's :kep to paramlist's kep.

Could You help me?
User avatar
aperger
Expert Boarder
Expert Boarder
Posts: 129
Joined: 24.08.2005, 08:24
Location: Veszprém
Contact:

Post by aperger »

hello,

Fist of all, set the SQL.Text, and set the parameters, after call ExecSQL command on your TZQuery object.
IN this way you do not need to call CreateParam() just you sould set the values...


.... BUT on MYSQL I have problems to save BLOB fields into the DB.

Code: Select all

DM.iCsoportok.SQL.Text:='INSERT ... ';
DM.iCsoportok.ParamByName('NEV').AsString:=Self.Name;
DM.iCsoportok.ParamByName('LEIRAS').AsString:=Self.Leiras;
DM.iCsoportok.ParamByName('USERID').AsString:=UserID;
DM.iCsoportok.ParamByName('FUNKCIO').AsInteger:=Ord(Self.Funkcio);
DM.iCsoportok.ParamByName('IDO').AsDateTime:=Now();
DM.iCsoportok.ExecSQL;
trob
Senior Boarder
Senior Boarder
Posts: 51
Joined: 20.03.2007, 02:24

Post by trob »

I can save Blob without any problem.

I would like to set the parameter BEFORE setting SQL.Text, because there is an 'If' for UPDATE and INSERT, but their parameter is the same.
But it seems to be impossible... :(
User avatar
aperger
Expert Boarder
Expert Boarder
Posts: 129
Joined: 24.08.2005, 08:24
Location: Veszprém
Contact:

Post by aperger »

trob wrote:I can save Blob without any problem.

I would like to set the parameter BEFORE setting SQL.Text, because there is an 'If' for UPDATE and INSERT, but their parameter is the same.
But it seems to be impossible... :(
try to create a function which set the Params object!
procedure setXXXParams(Params:TParams);
begin
....

Params.ParamByName('kep').AsBlob:=kepstream.DataString;

end;
trob
Senior Boarder
Senior Boarder
Posts: 51
Joined: 20.03.2007, 02:24

Post by trob »

Köszi, de akkor már többe kerülne a leves, mint a hús... (nem tudom lenne ez angolul :) )

Thank you for your work and thinking...
Post Reply