ZQuery execute sql

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
manz
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.06.2008, 03:58
Location: Cilegon
Contact:

ZQuery execute sql

Post by manz »

Dear all,

Just simply,

does zquery can execute multiple statement in single sql.text ?

for example :
Here the SQL statements :
create temporary table if not exists t_purchase_order
(
po_number varchar(30) not null,
po_item_number varchar(30) not null,
po_date date,
vendor_code varchar(20) default '',
stock_code varchar(40) default '',
delivery_date date,
plant varchar(20) default '',
warehouse_code varchar(20) default '',
po_quantity double precision default 0,
uom_code varchar(20) default '',
pr_number varchar(30) default '',
pr_item_number varchar(30) default '',
pr_date date,
po_type varchar(2) default '',
currency varchar(4) default '',
unitprice double precision default 0,
department varchar(40) default '',
actual_delivery_date date,
remark text,
create_date datetime null,
update_date datetime null,
uname varchar(20) default '',
constraint pk_purchase_order primary key (po_number, po_item_number)
);
delete from t_purchase_order;

and command: zQuery1.ExecSQL;


Thanks
Man'z

6.6.4-stable version
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

not ZQuery but ZSQLProcessor ;)
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

It should be possible using a ZQuery as well. Try ZConnection1.Properties.Add('CLIENT_MULTI_STATEMENTS=1'); before opening the query. Or set the values using the property editor for ZConnection1.Properties.
This is a mysql only feature, however.
In general gto's solution is advisable for script-like actions as you describe.

Mark
Image
manz
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.06.2008, 03:58
Location: Cilegon
Contact:

Post by manz »

Thanks to gto and mark to resolve this matter.

Manz
manz
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.06.2008, 03:58
Location: Cilegon
Contact:

Post by manz »

BTW, Which is faster :
using zSQLProcessor that handle multi statements or using zQuery that using client_multi_statements at zConnection1.Properties ?

Man'z
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

I guess client_multi_statements as it doesn't split the script and the processor uses zqueries internally. But let me warn you : there is no such thing as correct error handling of 'client_multi_statements' in zeoslib. So if one statement of a series fails this can go completely unnoticed. (I'm not sure if only the first or only the last errorstatus is retrieved)

Mark
Image
manz
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.06.2008, 03:58
Location: Cilegon
Contact:

Post by manz »

Ok, Thanks Mark ...

before we create script-like, we tested first one-by-one statements to make sure the sql in good result.

Thanks again Mark
Post Reply