Re: [SQL] Get the last inserted id

2008-04-11 Thread Andrew Sullivan
On Fri, Apr 11, 2008 at 07:23:04PM +0200, Nacef LABIDI wrote: > Hi all, > > I was wondering if postgres can return the last ID inserted for a table > which the primary key is autoincremented. I need to retrieve this ID in my > code to continue processing on that inserted row. Use select currval()

Re: [SQL] Get the last inserted id

2008-04-11 Thread A. Kretschmer
am Fri, dem 11.04.2008, um 19:23:04 +0200 mailte Nacef LABIDI folgendes: > Hi all, > > I was wondering if postgres can return the last ID inserted for a table which > the primary key is autoincremented. I need to retrieve this ID in my code to > continue processing on that inserted row. Either

Re: [SQL] Get the last inserted id

2008-04-11 Thread Nacef LABIDI
Nice idea but how can I use this in a frontend that I am developing using Delphi and ADO objects ? On Fri, Apr 11, 2008 at 7:41 PM, Scott Marlowe <[EMAIL PROTECTED]> wrote: > On Fri, Apr 11, 2008 at 11:23 AM, Nacef LABIDI <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > I was wondering if postgres

Re: [SQL] Get the last inserted id

2008-04-11 Thread Scott Marlowe
On Fri, Apr 11, 2008 at 11:23 AM, Nacef LABIDI <[EMAIL PROTECTED]> wrote: > Hi all, > > I was wondering if postgres can return the last ID inserted for a table > which the primary key is autoincremented. I need to retrieve this ID in my > code to continue processing on that inserted row. smarlowe=

[SQL] Get the last inserted id

2008-04-11 Thread Nacef LABIDI
Hi all, I was wondering if postgres can return the last ID inserted for a table which the primary key is autoincremented. I need to retrieve this ID in my code to continue processing on that inserted row. Thanks to all

Re: [SQL] Testing for null record in plpgsql

2008-04-11 Thread Erik Jones
Pavel & Craig, I'm replying to both of you to save some time :) All I was really trying to demonstrate was the need to be able to distinguish a completely null record from one that isn't. I can see by both of your responses that by incorporating that in a dummy example I inadvertently adde

Re: [SQL] Testing for null record in plpgsql

2008-04-11 Thread Pavel Stehule
Hello maybe CREATE OR REPLACE FUNCTION returns_empty_set_maybe() RETURNS SETOF foo AS $$ res integer; aux foo; BEGIN SELECT INTO res extract('month' from now()::integer % 2; IF res <> 0 THEN aux = (5,5); RETURN NEXT aux; END IF;

Re: [SQL] Testing for null record in plpgsql

2008-04-11 Thread Craig Ringer
Erik Jones wrote: Now, let's say I want to call this from another function and test the result to see if I have a null record (null, null),. I've got the following working but it feels like there should be something much simpler but I just can't seem to hit on it. Is this it? I'm assuming tha