Hi again Jan.
Before posting here I did try to step through (using the debugger) to see what the TZQuery component did to process this statement.
Unfortunately I couldn't follow the logic there. Nevertheless I'll give it another go and try and be a bit more patient.
Also, apart from this particular query, I've found the DBC layer surprisingly easy to use.
Edit: OK, I tried again stepping through this with the debugger and what I'd gleaned, and thought I'd tried before, now seems to work just fine.
Anyhow, for anyone else wondering how to do this, the following seems to work ...
Code: Select all
SQL = 'INSERT INTO transactions (field1, field2) VALUES (''val1'', 'val2'') RETURNING oid;';
Connection := DriverManager.GetConnectionWithParams(Url, nil);
Statement := Connection.PrepareStatement(SQL);
ResultSet := Statement.ExecuteQueryPrepared;
if Assigned(ResultSet) and ResultSet.Next then
caption := inttostr(ResultSet.GetInt(1));