I added a new column to a table (physical file) in DB2/400 v6r1 using an SQL ALTER TABLE statement. I have a logical file based on that table and the new field doesn't appear in it. Is there a way update that logical file without deleting and recreating it?

有帮助吗?

解决方案

No.

You will need to recompile the logical.

If the field was added at the end of the record, you might be able to get away with turning level checking off on it, LVLCHK(*NO). This might allow you get away with not recompiling some programs, IF they use it only for input and do not need the new field. This option leaves many practitioners rather nervous, others think it's great. Use with care. Programs that access the file only via SQL may be exempt. All other programs that use the logical or physical with native I/O must be recompiled.

One side benefit of using only SQL in your programs -- fewer recompiles required.

Edit

To be clear -

You need to recompile all logicals that refer to the changed physical.

You need to recompile any programs that use native I/O to write or update records in the physical or any of the logicals.

Many (possibly most) will tell you to also recompile programs that only read the the file (PF or LF).

Some will tell you that IF you only add new fields to the end of the record format, then you might not need to recompile programs that use native I/O only to read the file. If you do this, you will want to either a) using OVRDBF LVLCHK(*NO) only when about to call these programs, and DLTOVR afterwards, or b) create or change the file(s) to have LVLCHK(*NO).

Both have risks. WARNING: These stunts have been performed by professionals. Do not try at home.

In other words, if your shop is not experienced enough to understand & properly deal with the issues carefully & completely, then play its safe. Definitely. If you've had to ask this question, you're not nearly there yet.

If you have added new fields at the beginning or middle of the record layout, or if you have changed the size or type of any existing fields, Do Not Pass GO! You will need recompile all programs that use the file(s).

其他提示

Recompile the LF (assuming it was created with DDS) or do an ALTER VIEW to update it in SQL.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top