query.execute question

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

query.execute question

Post by snorkel » Wed 24 Dec 2008 16:37

Hi,
I am writing a query editor type app and I want the user to simple execute the query and not have to decide if they need to to a query.execute vs query.open via two differnent buttons.

So I tried this:

pgquery1.SQL.Clear;
pgquery1.SQL.Add('select * from pg_class;');
pgquery1.Execute;
showmessage(intTostr(pgquery1.RecordCount));
pgquery1.close;

pgquery1.SQL.Clear;
pgquery1.SQL.Add('insert into test (firstname) VALUES (''snorkel'');');
pgquery1.Execute;
showmessage(intTostr(pgquery1.RowsAffected));

The grid is filled during the first execute and the record count is returned.
I then clear the SQL and close the query, I then add new SQL that does not return a result set (INSERT) and the query gets executed just fine, but the Rows affected returns -1 instead of 1. If I don't do the first result set returning query the rowsaffeced is 1.

Is there a way to reset the query between executes so the rowsaffected works? I could create a new query object each time, but that seems like excessive overhead.

Thanks,

Snorkel

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

Post by Plash » Thu 25 Dec 2008 09:37

We have fixed this problem. The fix will be included in the next build of PgDAC.

Post Reply