[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Oracle Sequence Objects



That's the only way I've found. Since I usually use sequences for primary 
keys, I make my create procs return the sequence value as an out param. It's 
a little cleaner.

For example, User's get their ids from the user_id_seq.nextval. So the 
create_user procedure returns the user_id. Inside the proc it selects the 
nextval from the sequence, creates the user with it and returns the value to 
you.

I've found that this helps to keep the app logic clean, as I usually don't 
care about the sequence per se, but I do care about the user id.

BAL

>From: <alanherod@mindspring.com>
>Reply-To: alanherod@mindspring.com
>To: ajug-members@ajug.org
>Subject: Oracle Sequence Objects
>
>I need to access an Oracle Sequence object via JDBC.
>
>My current kluge(?) is to run a query:
>select My_Seq.NEXTVAL from dual;
>
>it seems to work....
>
>Is there a better way?
>
>Thanks in advance,
>
>Alan Herod


_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail