DB2 logical files

1150 pts.
Logical Files
Physical File
HI, i wanted to know if i can add a new field to a PF via a logical file. If yes give me an example. thanks....ram

Answer Wiki

Thanks. We'll let you know when a new response is added.


What you’re asking isn’t possible. The fields in a logical are a “view” of the fields in the physical – the fields have to exist in the physical first, before they can be used in the logical.


Martin Gilbert.

Gilbert is right, as always. But give us an idea of what you’re trying to do, perhaps we can make some recommendations.


Dido… but why not just add it to the PF and NOT COMPILE. Just do a CHGPF and specify *NO for record level check. If you compile it it will make all the other programs using that file to not work. So changing it will get your new field in the file. You might have to do it on your logical too.. I can’t remember if you have to or not.

Ten2008 —

I would agree that adding the field to the source and then doing a CHGPF to update the physical file is the best way to go. The logical files automatically get updated. But I disagree with specifying level check = *NO. It’s best to identify where those files are used and recompile all those programs once you have done your CHGPF.



I think Tod’s right on this. LVLCHK(*NO) is (in my opinion) a last resort option to get/keep things working. It’s something I would only use when I have no source for one of the programs that uses the file or for some reason can’t re-compile the program.


Martin Gilbert.


If you change the PF and want to use the LVLCHK(*NO) you should add the field to the end of the record format otherwise your programs wil give bad results without being compiled. I would not recommend doing this except in a have to situation.

Gary Whitten

WOW. lol.. I agree but its a solution. It all depends on the system avaialbility etc. *no level check is vert dangerouse… Be carefull.. If you only have a few programs using it then great. But if you have a few thousand using the file then it might take some time to compile.


Discuss This Question: 2  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • BigKat
    You CAN create some new fields in the logical that aren't "in" the physical. They just have to be based on fields that are. You can substring, concatenate, and rename existing fields to make new ones Kevin Affiliated
    9,460 pointsBadges:
  • Vatchy
    Actually, in a way, you can. Create a new PF with the new field in it, along with the fields from the original PF that will allow you to match the two files. Then create a join logical over both files, selecting the fields you need from the original PF and the new field from the new file. Of course, this only works if no, or very few, existing programs need to access the new field; otherwise, what they said.
    1,415 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: