Another alternative is to submit 2 queries - the first would be to retrieve
the sequence "nextval":

   SELECT [sequence name].NEXTVAL as my_seq_nextval FROM dual

and the next would be the INSERT where you actually provide the
value you just SELECT'ed.  It does involve an initial SELECT query to get 
the value of the sequence nextval, but with this approach you don't need
to use the dbi last_insert_id.

Hardy Merrill

>>> "Gaul, Ken" <[EMAIL PROTECTED]> 10/6/2005 9:00 AM >>>

-----Original Message-----
From: Ron Savage [mailto:[EMAIL PROTECTED] 
Sent: 06 October 2005 11:30
To: List - DBI users
Subject: Oracle and dbh -> last_insert_id

Hi Folks

I can't get last_insert_id() to work with Oracle.

OS: GNU/Linux
DBI: V 1.48
Oracle: 9.2.0

Demo (to save you typing): http://savage.net.au/last.pl 

I've tried various values for catalog and schema, including the schema
for the 
(test) table.

Any idea?
-- 
Cheers
Ron Savage, [EMAIL PROTECTED] on 6/10/2005
http://savage.net.au/index.html 
Let the record show: Microsoft is not an Australian company

I would doubt that dbd Oracle supports this. I would recommend using the
insert...returning clause, 
INSERT INTO emp
  (empno, ename)
  VALUES
  (seq_emp.NEXTVAL, 'Morgan')
  RETURNING empno
  INTO x;

Ken.


Reply via email to