Page 1 of 1

query.execute question

Posted: Wed 24 Dec 2008 16:37
by snorkel
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

Posted: Thu 25 Dec 2008 09:37
by Plash
We have fixed this problem. The fix will be included in the next build of PgDAC.