Page 1 of 1

Params before SQL

Posted: 20.03.2007, 02:28
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?

Posted: 20.03.2007, 02:43
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?

Posted: 20.03.2007, 09:49
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;

Posted: 20.03.2007, 11:23
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... :(

Posted: 20.03.2007, 11:28
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;

Posted: 20.03.2007, 13:29
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...