I have a flat file i want to update via SQL. I am not very proficient in SQL so I'm not sure how to do this. I have three files I need to access in this statement:
EPLP14 - Flat File
CSB6REP - Landlord File
CSIOREP - Phone Number File
If the landlord (B6KINB) NE *Zeros (CSB6REP file)
link to the flat file i want to update (EPLP14 file) with the landlord field (CSB6REP/B6KINB) to the landlord field on the flat file (EPLP14/A1B2NB)
Then link to the Phone Number File (CSIOREP) to get the appropriate phone numbers to update into the EPLP14 file.
If phone type = 'H' (IOI2ST = 'H') from CSIOREP file
Set EPLP14/CHAREA1 = CSIOREP/IOF7NB
Set EPLP14/CHPHON1 = CSIOREP/IOF8NB
If phone type = 'I' (IOI2ST = 'I') from CSIOREP file
Set EPLP14/CHAREA2 = CSIOREP/IOF7NB
Set EPLP14/CHPHON2 = CSIOREP/IOF8NB
If phone type = 'C' (IOI2ST = 'C') from CSIOREP file
Set EPLP14/CCAREA1 = CSIOREP/IOF7NB
Set EPLP14/CCPHON1 = CSIOREP/IOF8NB
If phone type = 'D' (IOI2ST = 'D') from CSIOREP file
Set EPLP14/CCAREA2 = CSIOREP/IOF7NB
Set EPLP14/CCPHON2 = CSIOREP/IOF8NB
The SQL statement will then run via a CL program. I do not have the option to do this update with a program. It needs to be SQL. I do have a working example that does something like this update using two files, but i'm not sure as to how/where to add the third file for the above SQL. Here is my working example:
UPDATE tlvlib/eplp14 A SET A.tharea1 = (SELECT i8zjn1 FROM csi8rep B WHERE A.q0KGNB=B.i8KGNB and A.q0aycd=B.i8aycd and B.i8vhst='H'), A.thphon1=(SELECT i8zkn1 FROM csi8rep B WHERE A.q0KGNB = B.i8KGNB and A.q0aycd = B.i8aycd and B.i8vhst='H')WHERE exists(SELECT * FROM csi8rep where A.q0kgnb=i8kgnb and A.q0aycd=i8aycd and i8vhst='H');
Any help would be greately appreciated!
EPLP14 - Flat File
CSB6REP - Landlord File
CSIOREP - Phone Number File
If the landlord (B6KINB) NE *Zeros (CSB6REP file)
link to the flat file i want to update (EPLP14 file) with the landlord field (CSB6REP/B6KINB) to the landlord field on the flat file (EPLP14/A1B2NB)
Then link to the Phone Number File (CSIOREP) to get the appropriate phone numbers to update into the EPLP14 file.
If phone type = 'H' (IOI2ST = 'H') from CSIOREP file
Set EPLP14/CHAREA1 = CSIOREP/IOF7NB
Set EPLP14/CHPHON1 = CSIOREP/IOF8NB
If phone type = 'I' (IOI2ST = 'I') from CSIOREP file
Set EPLP14/CHAREA2 = CSIOREP/IOF7NB
Set EPLP14/CHPHON2 = CSIOREP/IOF8NB
If phone type = 'C' (IOI2ST = 'C') from CSIOREP file
Set EPLP14/CCAREA1 = CSIOREP/IOF7NB
Set EPLP14/CCPHON1 = CSIOREP/IOF8NB
If phone type = 'D' (IOI2ST = 'D') from CSIOREP file
Set EPLP14/CCAREA2 = CSIOREP/IOF7NB
Set EPLP14/CCPHON2 = CSIOREP/IOF8NB
The SQL statement will then run via a CL program. I do not have the option to do this update with a program. It needs to be SQL. I do have a working example that does something like this update using two files, but i'm not sure as to how/where to add the third file for the above SQL. Here is my working example:
UPDATE tlvlib/eplp14 A SET A.tharea1 = (SELECT i8zjn1 FROM csi8rep B WHERE A.q0KGNB=B.i8KGNB and A.q0aycd=B.i8aycd and B.i8vhst='H'), A.thphon1=(SELECT i8zkn1 FROM csi8rep B WHERE A.q0KGNB = B.i8KGNB and A.q0aycd = B.i8aycd and B.i8vhst='H')WHERE exists(SELECT * FROM csi8rep where A.q0kgnb=i8kgnb and A.q0aycd=i8aycd and i8vhst='H');
Any help would be greately appreciated!