× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Mike,

Instead of a Stored Procedure, make it a function. That way you can, for
example, do a simple table update. Something like:

UPDATE ANOTHER_TABLE SET new_Sequence = NEXTSEQ(0);
A simple skeleton for a function that does what you want would be:
********
DROP FUNCTION NEXTSEQ;

Create Function NEXTSEQ (RESET NUMERIC(04, 0) )
Returns Numeric(04, 0)
Language SQL
Modifies SQL DATA
BEGIN
Declare RetVal Numeric(04,
0);
Select NextKey INTO RetVal From
CONSTANT;
Update CONSTANT Set NextKey = NextKey + 1;
Return(RetVal);
END
********

If reset <> 0 you could update NextKey with the new value, for instance.
That is not defined in this example, but I just wanted to show to how to
code an entry parameter.
Also, you could make it return yy-#### instead of just a number. Define
RetVal as CHAR(07) and code a CONCAT() just before the Return statement.

HTH,

Luis Rodriguez
IBM Certified Systems Expert — eServer i5 iSeries

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.