DBD::Pg - insert_id

2003-06-20 Thread Chisel Wright
Sorry to pollute the list with a non-Buffy post, I'm a bit stumped. I regularly work with mysql and postgres databases. I use the DBD::mysql and DBD::Pg modules for this work, via DBI. One piece of functionality I can't find in the postgres database interface is the equivalent of: $sth->{'mysq

Re: DBD::Pg - insert_id

2003-06-20 Thread Dominic Mitchell
Chisel Wright wrote: The only way I can think of doing this is to use something along these lines: ... $oid = $sth->{'pg_oid_status'} ($tablename) = ($sql =~ m{^insert\s+into\s+(.+?)\s+\(/}i); $sth = $dbh->prepare("SELECT id FROM $tablename WHERE oid = $oid"); ... Which seems really groad

Re: DBD::Pg - insert_id

2003-06-20 Thread Raf
I haven't used postgres for a while, but I used to use something like select(next_val(my_sequence)) and then insert this in or something along those lines. If you find the sp I mean, which grabs the next id in the sequence id, it'll work for you.. It's very annoying, that there doesn't appear to

Re: DBD::Pg - insert_id

2003-06-20 Thread Jason Clifford
On Fri, 20 Jun 2003, Raf wrote: > I haven't used postgres for a while, but I used to use something like > select(next_val(my_sequence)) and then insert this in or something along > those lines. If you find the sp I mean, which grabs the next id in the > sequence id, it'll work for you.. How safe

Re: DBD::Pg - insert_id

2003-06-20 Thread Roger Burton West
On Fri, Jun 20, 2003 at 01:12:39PM +0100, Jason Clifford wrote: >On Fri, 20 Jun 2003, Raf wrote: >> I haven't used postgres for a while, but I used to use something like >> select(next_val(my_sequence)) and then insert this in or something along >> those lines. If you find the sp I mean, which gra

Re: DBD::Pg - insert_id

2003-06-20 Thread Tim Sweetman
Jason Clifford wrote: On Fri, 20 Jun 2003, Raf wrote: I haven't used postgres for a while, but I used to use something like select(next_val(my_sequence)) and then insert this in or something along those lines. If you find the sp I mean, which grabs the next id in the sequence id, it'll work for

Re: DBD::Pg - insert_id

2003-06-20 Thread Jason Clifford
On Fri, 20 Jun 2003, Roger Burton West wrote: > >How safe is this in environments where lots of separate processes, using > >separate connections to the database, are updating the same table? > > That's the point of sequences. They are guaranteed to work. The > procedore of getting a new number

Re: DBD::Pg - insert_id

2003-06-20 Thread Jason Clifford
On Fri, 20 Jun 2003, Jason Clifford wrote: > In the case where an application is written poorly so that it grabs the > sequence number and spends time on $OTHER_TASK before performing the > actual insert other database clients will suffer delays wont they or does > the method used allow breaks i

Re: DBD::Pg - insert_id

2003-06-20 Thread Luis Campos de Carvalho
Jason Clifford wrote: On Fri, 20 Jun 2003, Raf wrote: How safe is this in environments where lots of separate processes, using separate connections to the database, are updating the same table? AFAIK, this is the safest method of updating the same table using different processes. The sequence

Re: DBD::Pg - insert_id

2003-06-20 Thread David Cantrell
On Friday, June 20, 2003 13:25 +0100 Tim Sweetman <[EMAIL PROTECTED]> wrote: I'm not sure it was entirely helpful of Postgres to go "Hmm, well Informix and MySQL and probably Oracle all do it the same way - let's only provide that facility obscurely, if at all". Grr. Postgres can do SEQUENCEs in

Re: DBD::Pg - insert_id

2003-06-20 Thread Jason Clifford
On Fri, 20 Jun 2003, Luis Campos de Carvalho wrote: >AFAIK, this is the safest method of updating the same table using > different processes. The sequence never offers the same value for two > different requests, even when they're parallel. Unless you have multiple servers accepting inserts

Re: DBD::Pg - insert_id

2003-06-20 Thread Raf
Jason Clifford said: > On Fri, 20 Jun 2003, Raf wrote: > >> I haven't used postgres for a while, but I used to use something like >> select(next_val(my_sequence)) and then insert this in or something > How safe is this in environments where lots of separate processes, using > separate connections

Re: DBD::Pg - insert_id

2003-06-20 Thread Raf
Luis Campos de Carvalho said: > Jason Clifford wrote: >> On Fri, 20 Jun 2003, Raf wrote: ^^^ Lies! I did not write that! It's just poor indentation. >> >> How safe is this in environments where lots of separate processes, >> using separate connections to the data

Re: DBD::Pg - insert_id

2003-06-20 Thread Leon Brocard
Raf sent the following bits through the ether: > It's very annoying, that there doesn't appear to be a standard for this. FWIW it's been brought up on dbi-dev recently and DBI may wrap all the methods someday. Can I be any more vague? Possibly. Leon -- Leon Brocard

Re: DBD::Pg - insert_id

2003-06-20 Thread Paul Johnson
Raf said: > Luis Campos de Carvalho said: >> Jason Clifford wrote: >>> On Fri, 20 Jun 2003, Raf wrote: > ^^^ > > Lies! I did not write that! > It's just poor indentation. > >>> >>> How safe is this in environments where lots of separate processes, >>> using separa

Re: DBD::Pg - insert_id

2003-06-21 Thread Lusercop
On Fri, Jun 20, 2003 at 01:22:43PM +0100, Roger Burton West wrote: > Not if the program has been written by someone vaguely competent. Big "if"... -- Lusercop.net - LARTing Lusers everywhere since 2002

Re: DBD::Pg - insert_id

2003-06-23 Thread Toby Corkindale
On Fri, Jun 20, 2003 at 10:53:47AM +0100, Chisel Wright wrote: > One piece of functionality I can't find in the postgres database > interface is the equivalent of: > > $sth->{'mysql_insertid'} > > It would just be really nice to be able to do something like: > > $sql = q[INSERT INTO foo (foo

Re: DBD::Pg - insert_id

2003-06-23 Thread Dominic Mitchell
Toby Corkindale wrote: On Fri, Jun 20, 2003 at 10:53:47AM +0100, Chisel Wright wrote: One piece of functionality I can't find in the postgres database interface is the equivalent of: $sth->{'mysql_insertid'} It would just be really nice to be able to do something like: $sql = q[INSERT INTO foo

Re: DBD::Pg - insert_id

2003-06-23 Thread Roger Burton West
On Mon, Jun 23, 2003 at 05:16:51PM +0100, Dominic Mitchell wrote: >Toby Corkindale wrote: >>Note that this is quite safe and the value returned is the current value >>for >>YOUR session only; so no need to worry about someone else inserting >>something >>or other such race conditions. :) >Doesn't

Re: DBD::Pg - insert_id

2003-06-23 Thread Toby Corkindale
On Mon, Jun 23, 2003 at 05:16:51PM +0100, Dominic Mitchell wrote: > >Note that this is quite safe and the value returned is the current value > >for YOUR session only; so no need to worry about someone else inserting > >something or other such race conditions. :) > > Doesn't that depend on whether

Re: DBD::Pg - insert_id

2003-06-25 Thread Mark Morgan
Jun 2003 08:50:41 -0700 > From: Toby Corkindale <[EMAIL PROTECTED]> > Reply-To: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > Subject: Re: DBD::Pg - insert_id > > On Fri, Jun 20, 2003 at 10:53:47AM +0100, Chisel Wright wrote: > > One piece of functionality I can't fin

RE: DBD::Pg - insert_id

2003-06-25 Thread Tielman De Villiers
SERT command. pg_cmd_status Returns the name of the last command type. Possible types are: INSERT, DELETE, UPDATE, SELECT. === -Original Message- From: Mark Morgan [mailto:[EMAIL PROTECTED] Sent: 25 June 2003 18:13 To: [EMAIL PROTECTED] Subject: Re: DBD::

Re: DBD::Pg - insert_id

2003-06-25 Thread Toby Corkindale
On Wed, Jun 25, 2003 at 06:13:27PM +0100, Mark Morgan wrote: > Not sure if postgres is similar to oracle, in this respect, but in Oracle, > it's illegal to do a currval call until nextval has been called at least > once on a sequence. Something that may come to bite you... That is the case; I'm a