Previous Thread
Next Thread
Print Thread
ISAM-A changing primary key #34099 28 Mar 21 01:52 PM
Joined: Jun 2001
Posts: 3,376
J
Jorge Tavares - UmZero Online Content OP
Member
OP Online Content
Member
J
Joined: Jun 2001
Posts: 3,376
Hi,
I would appreciate a confirmation from the ISAM-A experts, I guess, Herman and Jack in that sequence? laugh

I have an ISAM-A with three keys and I need to change the primary key but the buffer structure don't change, below is a simplified defstruct.

Code
defstruct ST_buffer
map2 buffer
   map3 key2$
       map4 teacher$,s,5
       map4 key1$
            map5 session'id$,s,10
            map5 session'seq$,s,3
  map3 fields
    ...
endstruct 


Now, the primary key is size 13, start on 6 and the secondary key is size 18, start on 1.
I want to convert the primary key to add teacher$ at the end so, primary key will be Concatenated 13, 6 with 5, 1.

In a secondary key, I would just delete the old one and create the new key but, that's not allowed for primary keys.
So, my doubt is if it's enough to dump the current file, create the new one and load the dump file.
I guess it is enough but, just rechecking because this file has vital data and I don't want to detect some anormaly ahead.

Thank you


Jorge Tavares

UmZero - SoftwareHouse
Brasil/Portugal
Re: ISAM-A changing primary key [Re: Jorge Tavares - UmZero] #34100 28 Mar 21 05:15 PM
Joined: Aug 2001
Posts: 2,645
H
Herman Roehm Offline
Member
Offline
Member
H
Joined: Aug 2001
Posts: 2,645
Jorge, anytime I change an index, I’ve had to dump the file and reload it. I’ve done this to increase the size of an index, reorganize the layout of an index as you are doing, or even change the size of variables in the record. I’ve had to change many, many field sizes over the past year or two because of a new standard we have to use. I read each record, put it in a sequential file in the new format and reload it one record at a time. I’ve never had any problem doing it this way. I don’t know of a way to change the index without doing this. I guess you could add an index and then maybe delete (not sure if this is allowed) the old one. Anyway, you could simply add the new index on the fly and just not use the old one. Hope this gives you something to think about.

Re: ISAM-A changing primary key [Re: Jorge Tavares - UmZero] #34101 28 Mar 21 06:11 PM
Joined: Jun 2001
Posts: 3,376
J
Jorge Tavares - UmZero Online Content OP
Member
OP Online Content
Member
J
Joined: Jun 2001
Posts: 3,376
Hi Herman,
Thank you very much for the material you sent me by email and, let me add that, for a simple file conversion, you're too perfectionist cool
I must confess that I use rustic small programs for that task that goes directly to the point:
1. read the old file with the old structure
2. adjust what needed
3. create record in the new file with the new structure

But, in this particular case, my goal is to not even write any small program and, just use ISMUTL:
1. ISMUTL "oldfile" - DUMP
2. create new file
3. ISMUTL "newfile" - LOAD

Apologize if that was not clear on the intial post.

Many thanks

Last edited by Jorge Tavares - UmZero; 28 Mar 21 09:18 PM.

Jorge Tavares

UmZero - SoftwareHouse
Brasil/Portugal
Re: ISAM-A changing primary key [Re: Jorge Tavares - UmZero] #34102 28 Mar 21 08:34 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Because the layout of the file is not changing, I don't see any problem with using ISMUTL to DUMP the old file, recreate the new one and then LOAD it from the previously dumped data. The only difference between the old and new files will be that the new primary key is concatenated.

You could probably even use the original DAT file as the load file (skipping the separate DUMP operation), provided you used the LOADX option and specified a record size one byte larger than the declared sized (since ISAMA files contain an extra file which indicates whether the record is in use.)

In any case, don't forget though that you will need to update programs that do FIND or GET operations on the file, because the key lookups are based on the separate expression that you provide in the FIND/GET statement, rather than being extracted from a record.

Re: ISAM-A changing primary key [Re: Jorge Tavares - UmZero] #34103 28 Mar 21 09:17 PM
Joined: Jun 2001
Posts: 3,376
J
Jorge Tavares - UmZero Online Content OP
Member
OP Online Content
Member
J
Joined: Jun 2001
Posts: 3,376
That's the kind of tip I love!
LOADX is there since ever and I never wonder one chance to use it, there it is, it loaded my old DAT into the new one perfectly.
It's not the case of having saved an huge amount of time, neither if writing a small convertion program or using the dump/load method, which I did too but, it's always good to learn new stuff.

Thank you to both


Jorge Tavares

UmZero - SoftwareHouse
Brasil/Portugal
Re: ISAM-A changing primary key [Re: Jorge Tavares - UmZero] #34104 29 Mar 21 01:52 AM
Joined: Aug 2001
Posts: 2,645
H
Herman Roehm Offline
Member
Offline
Member
H
Joined: Aug 2001
Posts: 2,645
I’ve got to look that up!


Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3