I would like to pass a sequence name into the function, and return the next value.
It looks like DB2 does not allow use of NEXT VALUE FOR syntax in a CREATE FUNCTION statement, even for a hardcoded sequence name (job log message indicates this)
The CREATE statement fails with an error complaining about the syntax.
Substituting hardcoded return values for the NEXT VALUE for statement allow the function to be created.
What alternate approach would people recommend? Create a Procedure? Other?
Am on V5R3M0
I have been trying
Expand|Select|Wrap|Line Numbers
- CREATE FUNCTION GETSEQNO (seqname char(10) )
- RETURNS DECIMAL(13,0)
- LANGUAGE SQL
- SPECIFIC GETSEQNO1
- func1_lab:
- BEGIN
- DECLARE seqno1 DECIMAL(13,0);
- SET seqno1 = decimal(next value for seqname,13,0) ;
- RETURN seqno1 ;
- END;