Taking backup of data and copy back

30 pts.
Tags:
AS/400
Backup
Currently I am working on a project where I need to take backup of huge files with data. Then change the length of one particular field from decimal 3 to decimal 5 and then finally copy the data back to the original file (which now will be having field length of the modified field as 5). Which will be a better option?
  1. Create backup versions with new length with data through SQL scripts, then delete actual objects and recreate with data from backup through SQL scripts again.
  2. Create backup versions with new length with data through SQL scripts, then delete actual objects and recreate through CPYF command with create file (*YES).
  3. Create backup versions with new length with data through SQL scripts, then delete actual objects and recreate through CRTDUPOBJ command with DATA (*YES).


Software/Hardware used:
AS400

Answer Wiki

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

This isn’t a direct answer, but you can also do an ALTER TABLE, like so:

ALTER TABLE YOURLIB/YOURTABLE ALTER COLUMN YOURCOL
 SET DATA TYPE DECIMAL
(5 , 0) NOT NULL WITH DEFAULT                                      
That will make the change in situ. What I can’t tell you is whether or not it’s quicker.
I am old-fashioned, and would usually:
1. Make sure I have the SQL source to recreate the affected table (Navigator will generate this for you)
2. Take a backup of this table to a separate library with CPYF (not CRTDUPOBJ, I am only interested in the data, not constraints etc.)
3. Delete the table, using DROP TABLE, which will take care of dependent things (indexes, etc.)
4. Re-create the table using the new SQL
5. Copy back using CPYF FMTOPT(*MAP)
Ian

Discuss This Question: 3  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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb

    I would think that you would do a backup of the table as is.

    Then change the dds (if it exists) and use the CHGPFM

    or

    in SQL use the ALTER table command. 

    Either should, I beleive change the tables and data to the new format.  There maybe issues with indexs or logical files that use this field as a key.

    50,505 pointsBadges:
    report
  • ToddN2000

    I would copy the data to a backup, change the DDS if you have it. You will also run into level checks with programs using this file. When ever you change a record format then all logical files and programs will need to be recompiled.

    After all this then copy the data from the backup into the new changed version of the file using the FMTOPT(*MAP)

    13,050 pointsBadges:
    report
  • CharlieBrowne
    I would backup current file to a *SAVF
    Then use CHGPF - This will automatically change all your LFs
    Now recompile all program that use the PF or LFs
    41,380 pointsBadges:
    report

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following