Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Jonathan Leffler wrote:
> GV wrote:\\
>
>> I have a table with clients and a sequid, in this sequid I will put
>> the id of the sequence that corresponds to the client:
>>
>> CREATE TABLE client(
>> name CHAR(20),
>> sequid INT REFERECES syssequences(sequid)
>> )>
>
> -201: Syntax error.>
*sighofrelief*
>> Every time there is an insert on this table I will create a sequence
>> with the same name as client.name and put the sequence sequid in
>> client.sequid. My question is: In a SQL procedure, how can I obtain
>> the NEXT VALUE for each sequence?
>>
>> Something like this would be perfect:
>>
>> SELECT NEXTVAL INTO m_nextval FROM syssequences WHERE sequid=3
>>
>> but this doesn't work. Is there any way to call the nextval function
>> other than with sequence_name.nextval?
If I understand you correctly you want to use the sequence as an argument?
You can always use dynamic SQL for that. Glue together the expression
and EXECUTE away.
> No - should there be? Does Oracle provide such a mechanism?
Jonathan, I've seen similar requests for DB2....
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.