Re: [SQL] writing a function to mimic mysql last_insert_id

2002-09-11 Thread Joe Conway
Beth Gatewood wrote: > well, I know that I will have only a single sequence that will generate the > primary key per table. So basically, this type of function, for me needs > only to return the value of the primary key. > > I believe I mentioned in one of my posts the motivation behind not want

Re: [SQL] writing a function to mimic mysql last_insert_id

2002-09-11 Thread Beth Gatewood
bject: RE: [SQL] writing a function to mimic mysql last_insert_id > > > But in Postgres, you can have as many "autoincrement" columns > in a table as > you want - how will you handle that? > > And what's wrong with select currval()? > > Chris > > >

Re: [SQL] writing a function to mimic mysql last_insert_id

2002-09-11 Thread Chris
Hi Beth, Here's a function I use to do the same sort of thing - but you need to supply it with a table name to get it - in the case of standard inserts it's pretty easy since it's always the third word (so if you're using an abstraction layer it's easy to change). It can be written a lot bett

Re: [SQL] writing a function to mimic mysql last_insert_id

2002-09-11 Thread Christopher Kings-Lynne
But in Postgres, you can have as many "autoincrement" columns in a table as you want - how will you handle that? And what's wrong with select currval()? Chris > I am wondering if I can get some input on the logic that I would need to > code a function that would mimic mysql's last_insert_id()..

Re: [SQL] writing a function to mimic mysql last_insert_id

2002-09-11 Thread Josh Berkus
Beth, > However, we are in the midst of porting a mysql database to pgsql. The perl > application that is tied to this mysql database heavily utilizes > last_insert_id. In an effort to save the perl developers the pain of having > to go in and modify a bunch of their SQL to call out to seq.cur

Re: [SQL] writing a function to mimic mysql last_insert_id

2002-09-11 Thread Beth Gatewood
; From: Josh Berkus [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 11, 2002 10:31 AM > To: Beth Gatewood; [EMAIL PROTECTED] > Subject: Re: [SQL] writing a function to mimic mysql last_insert_id > > > > Beth, > > > I am wondering if I can get some input on the l

Re: [SQL] writing a function to mimic mysql last_insert_id

2002-09-11 Thread Ross J. Reedstrom
Beth - Take a look at pgsql's sequences. They do pretty much exactly what you want, here. There's even a 'pseudo type' serial that sets up an int column with a default value coming from a sequence. Sequences are more loosely couple to 'auto increment' columns than in mysql or other database sys

Re: [SQL] writing a function to mimic mysql last_insert_id

2002-09-11 Thread Josh Berkus
Beth, > I am wondering if I can get some input on the logic that I would need to > code a function that would mimic mysql's last_insert_id().. Um, what about CURRVAL('sequence-name')? -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)-

[SQL] writing a function to mimic mysql last_insert_id

2002-09-11 Thread Beth Gatewood
Hi all- I am wondering if I can get some input on the logic that I would need to code a function that would mimic mysql's last_insert_id().. Here is what last_insert_id() does in mysql: Returns the last automatically generated value that was inserted into an AUTO_INCREMENT column. mysql> SELECT