COPY data between to files with SQL in iSeries

225 pts.
Tags:
iSeries SQL
SQL
SQL Copy Record
SQL Record
hi, i need help with this: i have two files in Iseries one of them is new and other have old records and i pretend with sql copy some records. But file 1(new) and file 2(old) they don't have same collums file1 file2 fielda fielda fieldb fieldb fieldc filedd fieldd how can i make the correspond field in sql instruction? thanks
ASKED: January 14, 2009  2:29 PM
UPDATED: January 14, 2009  2:56 PM

Answer Wiki

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

Hi,

You can use CPYF with the record format field mapping options to do this :-

CPYF FROMFILE(Yourlib/Oldfile) TOFILE(Yourlib/Newfile) MBROPT(*REPLACE) FMTOPT(*MAP *DROP)

Regards,

Martin Gilbert.

Discuss This Question: 1  Reply

 
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
    Martin's answer is excellent. CPYF will do lots of good stuff and doesn't need SQL. It can do stuff like select records (where) But if you need SQL. Here is the trick -- Assuming that you haven't defined column FieldC to allow null. Typically you won't want AS/400 columns to allow null. Then you must provide values for all columns. So I've added a value ' ' or 0 to the subselect results to be mapped into File1 If FieldC is character: INSERT INTO File1 (fielda, fieldb, fieldc, fieldd) SELECT Fielda, Fieldb, ' ', Fieldd FROM File2 If FieldC is numeric INSERT INTO File1 (fielda, fieldb, fieldc, fieldd) SELECT Fielda, Fieldb, 0, Fieldd FROM File2 Phil
    48,575 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