[solved] Value in the insert ZQuery

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

[solved] Value in the insert ZQuery

Post by elidorio2 »

How to get the value in the insert ZQuery, sends to the database?

Edson
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

elidorio2,

Edson, i do not understand what you mean ): !
Some more details?

Michael
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

Post by elidorio2 »

Want to catch ZQuery script that is sending to the database.
example:
insert into t1 values ​​(: col1,: col2,: col3,: col4);

The script to insert the values ​​that zquery set up for the columns: col1, col2, col3 and col4.
josimarz
Junior Boarder
Junior Boarder
Posts: 41
Joined: 14.09.2009, 17:29
Location: Brazil

Post by josimarz »

Hello elidorio2

Use the ParamByName to retrieve the value setted up to parameters of TZQuery. Example:

Code: Select all

var
   I: Integer;
begin
   ZQuery1.ParamByName('col1').AsInteger := 9;
   I := ZQuery1.ParamByName('col1').AsInteger;
   {...}
end;
Bye, bye

Josimar
elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

Post by elidorio2 »

Olá Josimar,

Quero pegar o script sql que a query enviou para o banco.
josimarz
Junior Boarder
Junior Boarder
Posts: 41
Joined: 14.09.2009, 17:29
Location: Brazil

Post by josimarz »

Though our language is Portuguese, I suggest using English for what others may benefit from the information.

For your case I suggest using the TZSQLMonitor component. Just add it to your project, preferably in the same place the TZConnection component.

Change the TZSQLMonitor Active property to True and encode the event OnLogTrace to get the SQL that was sent to the database from Event.Message

I hope this helps.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

elidorio2,

i think josimarz, is right here. One hint from me:

Your

Code: Select all

insert into t1 values ​​(: col1,: col2,: col3,: col4); 
should be:

Code: Select all

insert into t1 values ​​(:col1, :col2, :col3, :col4); 
then you can use

Code: Select all

ZQuery.ParamByName('col1').AsString(what ever) := 'Your value';
ZQuery.ParamByName('col2').AsString := 'Your second value';
.....
Also can you execute:

Code: Select all

ZQuery.SQL.Text := 'insert into t1 values ​​(:col1, :col2, :col3, :col4);'
ZQuery.Prepare;
ZQuery.ParamByName('col1').AsString(what ever) := 'Your value';
ZQuery.ParamByName('col2').AsString := 'Your second value';
....
ZQuery.ExecSQL;
ZQuery.ParamByName('col1').AsString(what ever) := 'Your value';
ZQuery.ParamByName('col2').AsString := 'Your second value';
....
ZQuery.ExecSQL;
ZQuery.ParamByName('col1').AsString(what ever) := 'Your value';
ZQuery.ParamByName('col2').AsString := 'Your second value';
....
ZQuery.ExecSQL;
ZQuery.Unprepare;
This should speed up the Paramerters IF the Plain drivers do support Real Prepared statements. (for MySQL you need to set TZQuery.Options := [doPreferePreparedResolver...])

Michael
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

Post by elidorio2 »

ok,

Thank you;

Edson
Locked