Stuart Bishop wrote:
[...]
> If you are using a modern PostgreSQL (8.1 for sure, maybe 8.0), this is
> better spelt:
>
> cur.execute("SELECT currval(pg_get_serial_sequence(%s, %s))" % (
> tableid, columnid))
>
> (Assuming of course your table name and column name don't contain odd
> character
Frank Millman wrote:
> I used to use 'select lastval()', but I hit a problem. If I insert a
> row into table A, I want the id of the row inserted. If it is a complex
> insert, which triggers inserts into various other tables, some of which
> may also be auto-incrementing, lastval() returns the id
Frank Millman wrote:
> Did you read my extract from the PostgreSQL docs -
>
> "Notice that because this is returning a session-local value, it gives
> a predictable answer whether or not other sessions have executed
> nextval since the current session did."
>
I totally missed it, my bad. Thanks!
[EMAIL PROTECTED] wrote:
> Frank Millman wrote:
> > Dale Strickland-Clark wrote:
> > > Now that OIDs have been deprecated in PostgreSQL, how do you find the key
> > > of
> > > a newly inserted record?
> > >
>
> >
> > I used to use 'select lastval()', but I hit a problem. If I insert a
> > row int
[EMAIL PROTECTED] wrote:
> Frank Millman wrote:
>
>>Dale Strickland-Clark wrote:
>>
>>>Now that OIDs have been deprecated in PostgreSQL, how do you find the key of
>>>a newly inserted record?
>>>
>
>
>>I used to use 'select lastval()', but I hit a problem. If I insert a
>>row into table A, I wan
Frank Millman wrote:
> Dale Strickland-Clark wrote:
> > Now that OIDs have been deprecated in PostgreSQL, how do you find the key of
> > a newly inserted record?
> >
>
> I used to use 'select lastval()', but I hit a problem. If I insert a
> row into table A, I want the id of the row inserted. If i
Frank Millman wrote:
> I therefore use the following -
> cur.execute("select currval('%s_%s_Seq')" % (tableid, columnid)
I use this also (although isn't it right that sometimes the name of the
sequence is not so straightforward? for instance, isn't there a limit
on the number of chars?).
Can a
Dale Strickland-Clark wrote:
> Now that OIDs have been deprecated in PostgreSQL, how do you find the key of
> a newly inserted record?
>
> I've tried three Python client libraries, including psycopg2, and where they
> support cursor attribute 'lastrowid' (Python DB API 2.0), it is always
> zero.
>
Tim N. van der Leeuw wrote:
>
> Hi,
>
> select lastval();
>
Thanks, that was useful.
--
Dale Strickland-Clark
Riverhall Systems - www.riverhall.co.uk
--
http://mail.python.org/mailman/listinfo/python-list
Hi Harald
Thanks for that, somewhat comprehensive, answer.
--
Dale Strickland-Clark
Riverhall Systems - www.riverhall.co.uk
--
http://mail.python.org/mailman/listinfo/python-list
Dale,
> Now that OIDs have been deprecated in PostgreSQL, how do you find the key of
> a newly inserted record?
using OIDs as primary key was no good idea for some PostgreSQL versions
allready ... i.e. they really make dump & restore much more
challenging.
So usually us have something along:
CR
Dale Strickland-Clark wrote:
> Now that OIDs have been deprecated in PostgreSQL, how do you find the key of
> a newly inserted record?
>
> I've tried three Python client libraries, including psycopg2, and where they
> support cursor attribute 'lastrowid' (Python DB API 2.0), it is always
> zero.
>
Now that OIDs have been deprecated in PostgreSQL, how do you find the key of
a newly inserted record?
I've tried three Python client libraries, including psycopg2, and where they
support cursor attribute 'lastrowid' (Python DB API 2.0), it is always
zero.
Anyone figured this out?
Thanks.
--
Da
13 matches
Mail list logo