|
I like sequence objects and identity columns as much as the next person. But I believe those are better for table wide use. Unless you want to create a separate sequence object for each order number. But I balk at that. Rob Berendt -- Group Dekko Services, LLC Dept 01.073 PO Box 2000 Dock 108 6928N 400E Kendallville, IN 46755 http://www.dekko.com "HauserSSS" <Hauser@xxxxxxxxxxxxxxx> Sent by: rpg400-l-bounces@xxxxxxxxxxxx 01/29/2005 10:13 AM Please respond to RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx> To "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx> cc Subject AW: Suggested technique Hi, there are even some SQL solutions: 1. Create a file with an identity column field. When adding a record into this file (even with native I/O) the next value is automatically calculated and inserted. 2. If you don't want to change your file and you are already on release V5R3M0, you can use a SQL sequence object (CREATE SEQUENCE), which is nothing else than a data structure. You either can use NEXT VALUE FOR SequenceName directly in an insert statement or retrieve the next value using a SET-STATEMENT. C/EXEC SQL Set :NextSeqNo = Next Value For MySequence C/END-EXEC Birgitta -----Ursprungliche Nachricht----- Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]Im Auftrag von Carel Teijgeler Gesendet: Samstag, 29. Januar 2005 12:39 An: rpg400-l@xxxxxxxxxxxx Betreff: Re: Suggested technique Tony, If the memo records are created in a seperate programme, I would use a data area. Before you enter the programme you test the data area. If available, you can enter the programme and write your memo. Otherwise an information error (programme-defined) tells you , you cannot. When you leave the memo-programme the data area is cleared. Regards, Cael Teijgeler *********** REPLY SEPARATOR *********** On 28-1-05 at 15:07 Tony Carolla wrote: >I am writing something to create memo records for accounts, detailing >insurance billing denials. The key to the file is account number and >sequence number, and it requires unique keys. Basically, my technique >for writing is: > >- Chain using account# >- if no matches, sequence=1 >- if %Found, SETGT using account#, READP, then add one to the sequnece >number. > >I am building the outpt record, then performing the above and writing >immediately. But there still is a chance that somebody is sitting in >the account, and might press enter on a new memo while my program is >trying to add records, causing my program to error trying to write a >duplicate record. I am trying to visualize a soltion using a DOW loop >and a Monitor group, but I would want the program to keep determining >the next record number and retrying if there was an error. I am not >sure if I can just ITER if the error is found, or if I have to use a >GOTO. > >Any suggestions? > > >-- >"Enter any 11-digit prime number to continue..." >-- >This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list >To post a message email: RPG400-L@xxxxxxxxxxxx >To subscribe, unsubscribe, or change list options, >visit: http://lists.midrange.com/mailman/listinfo/rpg400-l >or email: RPG400-L-request@xxxxxxxxxxxx >Before posting, please take a moment to review the archives >at http://archive.midrange.com/rpg400-l. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.