Page 1 of 1

how can i make multistatement in TPgQuery?

Posted: Mon 10 Aug 2009 10:34
by hugolam
how can i execute the Insert statement and update statement in the same datesat simultaneously.

the code like----------
insert into XX() values();

update XX set y = :y
where xxx;
------------------------

Posted: Tue 11 Aug 2009 07:54
by Plash
You can set the UnpreparedExecute option of TPgQuery to True to use several statements in one query.

Posted: Tue 11 Aug 2009 09:14
by hugolam
UnpreparedExecute is set to true.
this time the result only process the last statement if it is true else
error occurred....like that
"Update failed. Found 0 records" .

means that the first statement is not processed.

any other suggestion that can process all statement in the dataset?

Posted: Wed 12 Aug 2009 08:31
by Plash
The error "Update failed. Found 0 records" is generated by PgDAC. This error does not mean that the first statement is not processed.

PgDAC raises this error if RowsAffected = 0 after executing your query. You should check your database to learn if a row was inserted. RowsAffected can be zero because your query contains several statemens but query is executed successfully. In this case you can set the StrictUpdate option of TPgQuery to False to disable checking for RowsAffected.

Posted: Thu 13 Aug 2009 08:05
by hugolam
Thx guy.