|
Hans, No sequence is available in SQL but you can write your own UDF. One technique There is one on IBM's porting Web page that is pretty much a clone of Oracle sequences, or you can write a simpler version that uses a data area. In the one I wrote, I did check for overflow and it wasn't too bad. David Morris >>> boldt@ca.ibm.com 12/06/01 12:55PM >>> Tom wrote: >Well: > >D PBcontrol E DS ExtName(PBSCONTROL) Prefix(da_) >D DtaAra(PBACONTROL) >... >In *Lock PBcontrol; >da_Sequence = da_Sequence + 1; >Out PBcontrol; >pa_Sequence = da_Sequence; >... > >Where Sequence is a 7 digit number that used to, and still should, just roll >over at hival. (This is just one example of many sequence numbers) Oh I fully realize there may be one or two reasonable applications for numeric truncation. And this may well be one of them. But is it worth all the bugs that may be masked? As others have pointed out, do you really want to risk seeing $2.34 on your paycheque when it should be $1002.34? Or leave out high-order digits on customer bills? (Hmmm...) In this case, coding a MONITOR group around the EVAL is a small price to pay, and doesn't even cost anything in terms of run-time performance. And if we provided an option to mask the overflow exception, how many people would just blindly code the option without fully analyzing the real problem? (I was going to suggest using a SEQUENCE in SQL for this kind of functionality, but I'm not sure SQL on OS/400 has that particular extension.) Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com
As an Amazon Associate we earn from qualifying purchases.
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.