| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.oracle -> Re: Declaring sequence number qualifiers in Pro*c
In article <BtJF1H.G5s_at_ibmpcug.co.uk> boxfield_at_ibmpcug.co.uk (Paul J Snelling) writes:
>>suthemb1_at_jhuapl.edu (Marvin Suther) writes:
>>> I am writing a Pro*C application and am trying to access an already existing
>>> sequence number. However, no matter how I declare the sequence number id, I
>>> receive an error message that the sequence id does not exist. All
>>> documentation only references the use and not the declaration. Anyone know
>>> how this is declared?
>>
>
>Perhaps you are trying to access sequence.curval (last used value) before
>accessing sequence.nextval (next available value).
>
>Unfortunately in any session, you must access nextval before curval is
>available to you...
>
>--
>Paul Snelling, BoxField Systems Ltd
Marvin,
Are you getting this error message when you precompile your PRO*C program or during runtime? What is the sqlcheck option set to? SQLCHECK=limited does partial checks on the SQL statements, like object existence. I think some older versions of PRO*C had problems distinguishing table and sequence names. Precompile your PRO*C program with sqlcheck=none (the default) if the error occurs when you precompile. If it is a runtime error, then make sure the user connecting to ORACLE in the program has access to that sequence (if not the owner). Try it in sqlplus, too.
Here's an example:
----->
EXEC SQL BEGIN DECLARE SECTION;
int next_sequence;
EXEC SQL END DECLARE SECTION;
EXEC SQL SELECT sequence_name.nextval into :next_sequence from sys.dual;
printf("The next sequence is %d.\n", next_sequence);
<-----
![]() |
![]() |