Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Reproduce mysql "auto increment" in Oracle, using Perl?

Re: Reproduce mysql "auto increment" in Oracle, using Perl?

From: Mike Dwyer <dwyermj_at_co>
Date: Tue, 26 Sep 2000 08:31:18 -0600
Message-ID: <kw2A5.192$Ya.46389@wdc-read-01.qwest.net>

Sequences. Here is an answer I posted earlier today on http://www.computer-mentors.co.uk/wwwboard/oracle (answering a slightly different question).

select last_number from user_sequences where sequence_name = 'SAL_EMPLOYEE_S'; LAST_NUMBER



6047

select sal_employee_s.nextval from dual;

NEXTVAL



6047

c/next/curr/
1* select sal_employee_s.currval from dual /

CURRVAL



6047

select last_number from user_sequences where sequence_name = 'SAL_EMPLOYEE_S'; LAST_NUMBER



6048

BTW, the sequence was created with:
CREATE SEQUENCE SAL_EMPLOYEE_S START WITH 1; -- "start with 1" is optional

HTH
- Mike

<uqmoore_at_my-deja.com> wrote in message news:8qo13o$uck$1_at_nnrp1.deja.com...
> What's the best way to mimic mysql's "auto increment" feature in Oracle,
> using Perl?
>
> In mysql, you can set a column as "auto increment". Thus, when you
> insert a new row and specify NULL for this auto increment column's
> value, it automatically gives this column the integer value of the
> previously submitted row, plus one.
>
> The other neat thing is that mysql returns this column's value back to
> Perl ($sth->{'insertid'}).
>
> I am familiar with Oracle sequences but I do not know how to get the
> sequence value that was inserted with the new record back to Perl. I
> don't believe I can simply query the sequence's current value since
> there's no guarantee that another insert won't happen before this query
> (right?). I prefer not to lock the table. Any ideas?!?!? Thanks in
> advance.
>
> QM
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Tue Sep 26 2000 - 09:31:18 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US