--- On Thu, 8/28/08, Masis, Alexander (US SSA) <[EMAIL PROTECTED]> wrote:
> From: Masis, Alexander (US SSA) <[EMAIL PROTECTED]>
> Subject: [GENERAL] MySQL LAST_INSERT_ID() to Postgres
> To: pgsql-general@postgresql.org
> Date: Thursday, August 28, 2008, 4:14 PM
> I
On 29/08/2008 05:45, Tom Lane wrote:
> A general comment on those pages is that the tabular lists of functions
> are intended to give one-liner descriptions of what the functions do.
> For cases where a one-liner isn't sufficient, there's a sentence or a
> paragraph following the table.
>
> I don
Magnus Hagander escribió:
> Alvaro Herrera wrote:
> > Russ Brown escribió:
> >> Masis, Alexander (US SSA) wrote:
> >>>"SELECT CURRVAL(
> >>> pg_get_serial_sequence('my_tbl_name','id_col_name'));"
> >> Any reason why you can't just do this?
> >>
> >> CREATE FUNCTION last_insert_id() RETURNS bigi
Alvaro Herrera wrote:
> Russ Brown escribió:
>> Masis, Alexander (US SSA) wrote:
>>>"SELECT CURRVAL(
>>> pg_get_serial_sequence('my_tbl_name','id_col_name'));"
>> Any reason why you can't just do this?
>>
>> CREATE FUNCTION last_insert_id() RETURNS bigint AS $$
>> SELECT lastval();
>> $$ LANG
"Raymond O'Donnell" <[EMAIL PROTECTED]> writes:
> On 28/08/2008 22:26, Bill wrote:
>> someone confirm that currval() returns the the value for the connection
>> from which it is called?
> Yes, see here:
> http://www.postgresql.org/docs/8.3/static/functions-sequence.html
> and specifically a litt
On Thu, 28 Aug 2008 16:46:19 -0600
"Scott Marlowe" <[EMAIL PROTECTED]> wrote:
> On Thu, Aug 28, 2008 at 4:18 PM, Joshua Drake <[EMAIL PROTECTED]>
> wrote:
> > On Thu, 28 Aug 2008 16:06:14 -0600
> > "Scott Marlowe" <[EMAIL PROTECTED]> wrote:
> >> No, setval, currval, and lastval all require as an a
On Thu, Aug 28, 2008 at 4:18 PM, Joshua Drake <[EMAIL PROTECTED]> wrote:
> On Thu, 28 Aug 2008 16:06:14 -0600
> "Scott Marlowe" <[EMAIL PROTECTED]> wrote:
>> No, setval, currval, and lastval all require as an argument a sequence
>> name. So the real issue is you have to know the sequence name to u
On Thu, 28 Aug 2008 15:29:51 -0700
Bill <[EMAIL PROTECTED]> wrote:
> The PostgresSQL 8.3 help file clearly shows that lastval() does not
> take a sequence as a parameter and the description i is "Return the
> value most recently returned by |nextval| in the current session.
> This function is iden
Scott Marlowe wrote:
On Thu, Aug 28, 2008 at 3:38 PM, Bill <[EMAIL PROTECTED]> wrote:
I am new to PostgreSQL but it seems to me that lastval() will only work if
the insert does not produce side effects that call nextval(). Consider the
case where a row is inserted into a table that has an aft
On Aug 28, 2008, at 3:23 PM, D. Dante Lorenso wrote:
I use RETURNING for all my insert and UPDATE statements now.
Usually I'll return the primary key for the table, but sometimes I
return a column that is created by one of my triggers. It's
awesome to be able to do this in one query.
Scott Marlowe wrote:
On Thu, Aug 28, 2008 at 3:38 PM, Bill <[EMAIL PROTECTED]> wrote:
I am new to PostgreSQL but it seems to me that lastval() will only work if
the insert does not produce side effects that call nextval(). Consider the
case where a row is inserted into a table that has an after
Russ Brown escribió:
> Masis, Alexander (US SSA) wrote:
> >
> >"SELECT CURRVAL(
> > pg_get_serial_sequence('my_tbl_name','id_col_name'));"
>
> Any reason why you can't just do this?
>
> CREATE FUNCTION last_insert_id() RETURNS bigint AS $$
> SELECT lastval();
> $$ LANGUAGE SQL VOLATILE;
I
On Thu, 28 Aug 2008 16:06:14 -0600
"Scott Marlowe" <[EMAIL PROTECTED]> wrote:
> On Thu, Aug 28, 2008 at 3:38 PM, Bill <[EMAIL PROTECTED]> wrote:
> > I am new to PostgreSQL but it seems to me that lastval() will only
> > work if the insert does not produce side effects that call
> > nextval(). Cons
On Thu, Aug 28, 2008 at 3:38 PM, Bill <[EMAIL PROTECTED]> wrote:
> I am new to PostgreSQL but it seems to me that lastval() will only work if
> the insert does not produce side effects that call nextval(). Consider the
> case where a row is inserted into a table that has an after insert trigger
> a
Steve Atkins wrote:
On Aug 28, 2008, at 12:09 PM, Scott Marlowe wrote:
On Thu, Aug 28, 2008 at 10:14 AM, Masis, Alexander (US SSA)
<[EMAIL PROTECTED]> wrote:
I was mapping C++ application code that works with mySQL to work with
Postgres.
There were a number of articles on line regarding the c
On 28/08/2008 22:26, Bill wrote:
> someone confirm that currval() returns the the value for the connection
> from which it is called?
Yes, see here:
http://www.postgresql.org/docs/8.3/static/functions-sequence.html
and specifically a little further down the page on "currval":
Return the va
Masis, Alexander (US SSA) wrote:
I was mapping C++ application code that works with mySQL to work with
Postgres.
There were a number of articles on line regarding the conversion from
mySQL to Postgres like:
http://en.wikibooks.org/wiki/Programming:Converting_MySQL_to_PostgreSQL
http://groups.dru
On Thu, Aug 28, 2008 at 1:56 PM, Steve Atkins <[EMAIL PROTECTED]> wrote:
>
> Or lastval() if you want something bug-compatible with MySQL.
Not exactly. LAST_INSERT_ID is transactionally safe in that one
connection doesn't see another connections. However, it has it's own
special brand of bug tha
On Aug 28, 2008, at 12:09 PM, Scott Marlowe wrote:
On Thu, Aug 28, 2008 at 10:14 AM, Masis, Alexander (US SSA)
<[EMAIL PROTECTED]> wrote:
I was mapping C++ application code that works with mySQL to work with
Postgres.
There were a number of articles on line regarding the conversion from
mySQL
Masis, Alexander (US SSA) wrote:
>
>"SELECT CURRVAL(
> pg_get_serial_sequence('my_tbl_name','id_col_name'));"
>
Any reason why you can't just do this?
CREATE FUNCTION last_insert_id() RETURNS bigint AS $$
SELECT lastval();
$$ LANGUAGE SQL VOLATILE;
--
Sent via pgsql-general mailing list
On Thu, Aug 28, 2008 at 10:14 AM, Masis, Alexander (US SSA)
<[EMAIL PROTECTED]> wrote:
> I was mapping C++ application code that works with mySQL to work with
> Postgres.
> There were a number of articles on line regarding the conversion from
> mySQL to Postgres like:
SNIP
> Well, in MySQL it's eas
I was mapping C++ application code that works with mySQL to work with
Postgres.
There were a number of articles on line regarding the conversion from
mySQL to Postgres like:
http://en.wikibooks.org/wiki/Programming:Converting_MySQL_to_PostgreSQL
http://groups.drupal.org/node/4680
http://jmz.iki.f
22 matches
Mail list logo