Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-03

SQLQuery

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Chris Crori

Hi guys,
i use a SQLQuery in a project to connect to a Firebird database. In my table i use a BEFORE INSERT trigger for my primary ID field. In the same transaction i have to insert a detail row in another column. How can i find out the ID result after post but before commit?

ps : i tried ZEOSDB and generators worked like a charm, but using ZEOSDB made my app sluggish -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140327/c5b4aad1/attachment.html>

Reply by email

Michael Van Canneyt
to Chris Crori
Chris Crori wrote 5 lines
Hi guys, ??? i use a SQLQuery in a project to connect to a Firebird database. In my table i use a BEFORE INSERT trigger for my primary ID field. In the same transaction i have to insert a detail row in another column. How can i find out the ID result after post but before commit?

There is currently no way to do this unless you run a second query that uses a unique field to retrieve the ID.

if you are using a manual insert query you can do
INSERT INTO YOURTABLE (fields) VALUES (yourvalues) RETURNING ID and use a OPEN to retrieve the ID.

ps : i tried ZEOSDB and generators worked like a charm, but using ZEOSDB made my app sluggish

There are some plans to support such a thing but nothing was implemented yet.

Michael.

Reply by email

Chris Crori
to Michael Van Canneyt
Chris Crori wrote 7 lines
Hi guys, i use a SQLQuery in a project to connect to a Firebird database. In my table i use a BEFORE INSERT trigger for my primary ID field. In the same transaction i have to insert a detail row in another column. How can i find out the ID result after post but before commit?

There is currently no way to do this unless you run a second query that uses a unique field to retrieve the ID.

if you are using a manual insert query you can do
INSERT INTO YOURTABLE (fields) VALUES (yourvalues) RETURNING ID and use a OPEN to retrieve the ID.

ps : i tried ZEOSDB and generators worked like a charm, but using ZEOSDB made my app sluggish

There are some plans to support such a thing but nothing was implemented yet.

Michael.

There is a DBGrid linked to that Query so i can't :( also i tried to use returning inside the InsertSql statement and it didn't word (i thought maybe it will update the ID field)

Reply by email

Chris Crori
to Chris Crori

Done!
I used the second query method on the beforepost event and it works fine

I would like to try expanding the TSQLQuery to be able to use generator fields, can someone help me send the patch after?

Thank you Michael for your help

-----?????? ??????-----

Earlier message 39 lines
From: Chris Crori Sent: Thursday, March 27, 2014 3:53 PM To: Lazarus mailing list Subject: Re: [Lazarus] SQLQuery On Thu, 27 Mar 2014, Chris Crori wrote: > Hi guys, > i use a SQLQuery in a project to connect to a Firebird database. In my > table i use a BEFORE INSERT trigger for > my primary ID field. > In the same transaction i have to insert a detail row in another column. > How can i find out the ID result after > post but before commit? There is currently no way to do this unless you run a second query that uses a unique field to retrieve the ID. if you are using a manual insert query you can do INSERT INTO YOURTABLE (fields) VALUES (yourvalues) RETURNING ID and use a OPEN to retrieve the ID. > ps : i tried ZEOSDB and generators worked like a charm, but using ZEOSDB > made my app sluggish There are some plans to support such a thing but nothing was implemented yet. Michael. There is a DBGrid linked to that Query so i can't :( also i tried to use returning inside the InsertSql statement and it didn't word (i thought maybe it will update the ID field) --

Reply by email