Hello,
I have done that (or at least something quite close). I had a similar
challenge in the early 90's when we implemented level checking. I had to
devise a way to add filed to a file without creating a level check while
leaving level checking on.
Here is what you could do.
- For the first time, you will still need exclusive access to the file
- you had one big alpha field to the file (1000 char. or more)
- you recompile the file and all programs that use it
Now you are set so you can had fields o the fly.
- You define an external data structure (basically a PF with no data in
it) that redefine the big alpha filed added earlier
- You use that external DS in the D spec of the program to overlay the
big field
-- This way, there is no level checking being done on the external data
structure since it is not on the F spec
- When you need a new field, you just modify the external data
structure, recompile it (it is never locked)
-- be sure to add new fields at the end and to never move a field.
- then you create a one shot program to initialize the new field
(putting all "0" in it or whatever)
- you must only recompile the programs that access that new fileds.
Of course, there are some limitation to this technique. The biggest is
that no filed added can be part of a key.
I do not recommend this method anymore, but it does achieve what you
want:
- Can add filed to a file while it is locked
- The only programs that need to be freed and recompile are those using
the new fields
- imply very little change to all existing program
I hope this make sense to you.
Denis Robitaille
Directeur services technique TI
819 363 6130
SUPPORT
Jour (EST) Daytime : 819-363-6134
En-dehors des heures (EST) After hour : 819-363-6158
Network Status : 819-363-6157
Alan Shore <AlanShore@xxxxxxxx> 2009-05-09 13:18 >>>
Hi guys
I've just been asked the following question by my boss's boss
Is there anyway to add new fields (columns) "on the fly" to an
existing
file, without having an exclusive lock on that file.
In other words, the file is still being used while the field is added
I know that chgpf is out of the question (unless someone proves me
wrong).
I know that SQL is also out of the question (ALTER TABLE x ADD
EXTRAFIELD
DEC(7, 2) NOT NULL DEFAULT 0) - again unless someone proves me wrong
If anyone knows of any way, any language, any procedure, any function
to
achieve this, please drop me a line.
Thanks in advance
Alan Shore
Programmer/Analyst, Distribution
E:AShore@xxxxxxxxxxx
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill
As an Amazon Associate we earn from qualifying purchases.