The code below selects almost all the records I need into an array. What I need to do is if pr.cc = 171 or 173 grab the next pr.step record based on the existing where clause and place the pr.cc value found here into next_step_cc[i] not the 171 or 173 (invalid for this program purpose). Please help me if you can. Thanks.
Code:
212 EXEC SQL SELECT DISTINCT ms.mo_pre,ms.mo,ms.mo_lot,ms.cin,ms.last_step,
213 ms.last_step_cc,ms.last_step_cc_sn,ms.piw,ms.coil_wdth_in,
214 ms.coil_gage_in,ms.coil_wght_calc_lbs,pr.cc,pr.cc_sn,
215 pr.sch_grp_cd_desc ,pr.cc,pr.sch_grp_cd, ms.coat_cd
216 into :coil_array[i].mo_pre,:coil_array[i].mo,:coil_array[i].mo_lot,
217 :coil_array[i].cin,:coil_array[i].last_step,:coil_array[i].last_step_cc,
218 :coil_array[i].last_step_cc_sn,
219 :coil_array[i].piw,:coil_array[i].coil_wdth_in,
220 :coil_array[i].coil_gage_in ,:coil_array[i].coil_wght_calc_lbs,
221 :next_step_cc[i], /* RRL v1.9 */
222 :next_step_cc_sn[i],
223 :grp_cd_desc[i],:cc[i],:next_sch_grp_cd[i],
224 :coil_array[i].coat_cd
225 from psr_coil_mstr ms,msd_mfg_to_mo_lot m,msd_proc_rte pr
226 where ms.next_step=pr.step and m.mo=ms.mo and m.mo_lot=ms.mo_lot
227 and pr.psu_key=m.psu_key
228 and ms.next_step_cc=996
229 and ms.defunct_flag != 'Y'
230 order by pr.cc,pr.sch_grp_cd,ms.mo,ms.mo_lot,ms.cin;
231 EXEC SQL BEGIN;
232 i++;
233 EXEC SQL END;
234 EXEC SQL INQUIRE_INGRES (:tmp_rcount=rowcount);
235 EXEC SQL COMMIT;