how can i make multistatement in TPgQuery?

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
hugolam
Posts: 3
Joined: Mon 10 Aug 2009 10:25

how can i make multistatement in TPgQuery?

Post by hugolam » Mon 10 Aug 2009 10:34

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;
------------------------

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 11 Aug 2009 07:54

You can set the UnpreparedExecute option of TPgQuery to True to use several statements in one query.

hugolam
Posts: 3
Joined: Mon 10 Aug 2009 10:25

Post by hugolam » Tue 11 Aug 2009 09:14

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?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 12 Aug 2009 08:31

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.

hugolam
Posts: 3
Joined: Mon 10 Aug 2009 10:25

Post by hugolam » Thu 13 Aug 2009 08:05

Thx guy.

Post Reply