From: Beth Gatewood <beth@vizxlabs.com>
To: 'Christopher Kings-Lynne' <chriskl@familyhealth.com.au>
To: pgsql-sql@postgresql.org
Subject: Re: writing a function to mimic mysql last_insert_id
Date: Wed, 11 Sep 2002 19:37:37 -0700
Message-ID: <000f01c25a05$5c549aa0$0c00000a@bethvizx> (raw)
In-Reply-To: <GNELIHDDFBOCMGBFGEFOGEDDCEAA.chriskl@familyhealth.com.au>
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 wanting
to use currval()...which was to trying to avoid having the developers make a
lot of sql revisions to their application.
Thanks-Beth
> -----Original Message-----
> From: Christopher Kings-Lynne [mailto:chriskl@familyhealth.com.au]
> Sent: Wednesday, September 11, 2002 7:05 PM
> To: Beth Gatewood; pgsql-sql@postgresql.org
> Subject: 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
>
> > 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 LAST_INSERT_ID();
> > -> 195
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: beth@vizxlabs.com, chriskl@familyhealth.com.au
Subject: Re: writing a function to mimic mysql last_insert_id
In-Reply-To: <000f01c25a05$5c549aa0$0c00000a@bethvizx>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox