There are LOTS of problems with this technique.  Suppose your key's are 
1,3,4,7,8,9 (with some having been deleted).  Now you RGZPFM and get rid 
of the deleted records.  Using your technique, the current high key would 
be 6.  Nice try with counting the number of deleted records though.

Rob Berendt
-- 
Group Dekko Services, LLC
Dept 01.073
PO Box 2000
Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





Raul Jager <raul@xxxxxxxxxx> 
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
03/10/2005 07:35 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
Re: Suggestions






This program returns the number of records in the file.  Just add 1 and 
use as the key, unless you decide to begin teh keys with zero.
___________________________________________________________________________________________
0001.00              PGM        PARM(&NAME &LIBR &SIZE)
0002.00              DCL        VAR(&NAME) TYPE(*CHAR) LEN(10)
0003.00              DCL        VAR(&LIBR) TYPE(*CHAR) LEN(10)
0004.00              DCL        VAR(&SIZE) TYPE(*DEC) LEN(10) VALUE(0)
0005.00              DCL        VAR(&NBRCURRCD) TYPE(*DEC) LEN(10) 
VALUE(0)
0006.00              DCL        VAR(&NBRDLTRCD) TYPE(*DEC) LEN(10) 
VALUE(0)
0007.00              RTVMBRD    FILE(&LIBR/&NAME) NBRCURRCD(&NBRCURRCD) +
0008.00                           NBRDLTRCD(&NBRDLTRCD)
0009.00              MONMSG     MSGID(CPF9812) EXEC(DO) /* 'Archivo no 
esta' */
0010.00                    CHGVAR     VAR(&SIZE) VALUE(-1)
0011.00                    RETURN
0012.00                    ENDDO
0013.00              CHGVAR     VAR(&SIZE) VALUE(&NBRCURRCD + &NBRDLTRCD)
0014.00              ENDPGM
______________________________________________________________________________
Raul

Buck Calabro wrote:

>>I have a physical file that will hold
>>gas type information, but one of the
>>fields needs to be an integer id field.
>> 
>>
>
>Search the archives for SQL IDENTITY and you'll probably come up with
>a bunch of useful examples.  http://archive.midrange.com There are
>several native RPG ways to go about this.
>
>1) Use a data area to store the last number used
>*lock in lastno
>      add 1      lastno
>     out lastno
>
>2) Get the highest key by looking at the last record
>*hival setll
>       readp
>       add 1 key
>...
>
>3) Store the last number used in another database file
>
>Hope this gets you started.
>  --buck
>
>
>
> 
>

-- 
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 thread ...

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.