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
Software/Hardware used:
ASKED:
January 14, 2009 2:29 PM
UPDATED:
January 14, 2009 2:56 PM
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