[Info-vax] Help with DECBasic: reading a record in an INDEX SEQ file using a compound key
Randy Park
rvfulltime.nospaam at isp.nospaam.com
Thu Jan 7 11:55:07 EST 2010
thick_guy_9 wrote:
> All
> I need some help with DECBasic. All the examples in the BASIC USER
> GUIDE use a simple key.
>
> This is how I open the file:
>
> OPEN sFILENAME AS FILE #1 &
> ,access modify &
> ,allow modify &
> ,map REC_MAP &
> ,organization indexed &
> ,primary (PAN, DOB) ! <======= NOTE &
> ,alternate LAST duplicates changes &
> ,alternate FIRST duplicates changes
>
> FIND #1, KEY #0 EQ "sMyPAN,sDOB", REGARDLESS
> GET #1
> The above Get command gives me a "RECORD NOT FOUND" error.
>
> Did I get the syntax correctly?
>
> Thanks!
It's been 10 years since I used Dec BASIC, but I did use it for over 15 years
and was pretty good at it. So here goes.
1. The "primary" and "alternate" clauses are useful only if creating the file.
You don't need them for opening an existing file.
2. PAN and DOB should be fixed length strings found in the map REC_MAP
3. If sMyPAN and sDOB are dynamic strings of the exact same length as PAN and
DOB then you can use the following:
sTEMP = sMyPAN + sDOB
GET #1, KEY #0 EQ sTEMP, REGARDLESS
For possible future debugging, I prefer using a temporary string (sTEMP).
4. If sMyPAN and sDOB are not the exact same length as PAN and DOB then do the
following:
PAN = sMyPAN !force correct length
DOB = sDOB !force correct length
sTEMP = PAN + DOB
GET #1, KEY #0 EQ sTEMP, REGARDLESS
5. In designing your indexed file I recommend against have last_name by itself
as an index. Same with first_name. You'll end up with way too many duplicates.
I recommend a multi segmented alternate key comprised of last_name and
first_name, and another multi segmented alternate key comprised of first_name
and last_name.
6. Performing a FIND statement followed by a GET statement, is really a waste
of time. Just perform the GET statement.
7. Hopefully you are not using BASIC to create your indexed file. The RMS
utilities do a better job and offer more functionality and flexibility. I want
to say the utility is EDIT/FDL and CREATE/FDL but I could be wrong.
8. Finally, you understand the implications of REGARDLESS don't you? You are
bypassing the record locking protections by using it.
Good luck.
More information about the Info-vax
mailing list