I have a function that looks like this.
Function GetNewBatch ( CourseName Varchar2 ) Return RefCursor
As
Results RefCursor;
CourseId Number;
Begin
CourseId := Courselist.GetId( CourseName );
Open Results For
Select q.user_abn UserAbn,
q.completed_t DateCompleted,
CourseName,
q.batch_n BatchId
From GAK.GAKHR02_ACK q
Where q.crse_i = CourseId
And q.batch_n is null
And rownum < 1000;
GAK.SEQ1_GAKHR03.NextVal;
Return Results;
End;
I want to increment the sequence after the select, but SQL Developer is giving me the error:
“Error(194,5): PLS-00313: ‘NEXTVAL’ not declared in this scope.”
How can I do this?
It’s because you’re not assigning the
nextvalto a variable. Assume that.nextvalis a function of some description. It’s not, Oracle actually describe it as a psuedocolumn; something used in the same context as a column but not written to the disk.How you increment a sequence depends on the version of Oracle you’re using. Prior to 11G you could do the following in a PL/SQL block:
In 11G this changed slightly so you could also assign the “return” value from
.nextvalto a variable:The reason for PLS-00313 is that Oracle is assuming that
SEQ1_GAKHR03is a package or some other object and.nextvalis a sub-type of this object.It’s very unusual to increment a sequence without actually using the value. Is this intended behaviour?