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



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







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.