SQL Sequences

nukn

New Member
I have created four sequences for my database, and they show in Data Dictionary. But when I am trying to get a number from thm in a query like this:
Code:
insert into Object (Id, Name, ParentId, MailingAddress) values (ObjectsSequence.nextval, 'myplace', 0, 'myplaceaddress');

I get mistake
=== SQL Exception 1 ===
SQLState=
ErrorCode=-20170
[JDBC OpenEdge Driver]:[]-20170

User guide tells that this mistake means "Invalid reference to a sequence was used". The name of the sequence is correct, I checked this. Does anybody have any idea how this can be solved?
Thank you!
 
I don't use SQL very often so I don't know if I can help, but the exact sequence name (ObjectsSequence) is shown in SYSSEQUENCES?

Does it help if you put the schema reference in the statement (e.g. PUB)?

Can it be that it should be NEXTVAL instead of nextval?

Regards,

Casper.
 
I don't use SQL very often so I don't know if I can help, but the exact sequence name (ObjectsSequence) is shown in SYSSEQUENCES?

When I try to select from this table, I get an error "Table/View/Synonym not found"

Does it help if you put the schema reference in the statement (e.g. PUB)?

Can it be that it should be NEXTVAL instead of nextval?

No, trying both of these didn't help.:confused:
 
The answer was easy:

Code:
insert into Object (Id, Name, ParentId, MailingAddress) values [B](pub.[/B]ObjectsSequence.nextval, 'myplace', 0, 'myplaceaddress');
 
Back
Top