AIX String Concatenation Problem
Posted in 1998
Anybody have an answer? ---------------------- Forwarded by Kate Tomchik/IS/SSC/THD on 06/11/98 04:09 PM We have come across a problem with string concatenation on the international development box, cpaiad2a. I have a module rvp100m03.4gl where a string variable defined as char(1536) is used in an SQL PREPARE statement executed later. The variable is set in one instance of a case statement to be: LET p_select_for = " SELECT po_line_nbr, ", " 'PART', ", " sku_nbr, ", " ord_qty, ", " 0, ", ### shpd_qty " 0, ", ### rcvd_qty " 0, ", ### plnd_recv_seq_nbr " sku_cost_amt ", " FROM str_po_sku ", " WHERE loc_nbr = ", gr_str_recv.loc_nbr, " AND loc_typ_cd = '", gr_str_recv.loc_typ_cd, "'", " AND acct_po_typ_cd = '", gr_str_recv.acct_po_typ_cd, "'", " AND po_ctrl_nbr = ", g_po_ctrl_nbr, " AND ord_seq_nbr = ", gr_str_recv.ord_seq_nbr, " AND ord_qty > 0 " Following the case statement the SQL statement is executed: PREPARE st_fetch_sku FROM p_select_for IF ( SQLCA.SQLCODE != 0 ) THEN CALL init_abend_proc( SQLCA.SQLCODE ) LET gr_appl_log.evnt_typ_ind = "F" LET gr_appl_log.msg_nbr = "00081" LET gr_appl_log.mod_id = "rvp100m03.4gl" LET gr_appl_log.func_id = "load_details_for_po" LET gr_appl_log.tbl_nm = "N/A" LET gr_appl_log.msg_data_val = # "ERROR ON: Prepare of ", p_select_for CLIPPED, "ERROR ON: Prepare of p_select_for ", "MODE is ", gr_cda.curr_actn_mode, " xfer_nbr is ", gr_str_recv.xfer_ctrl_nbr, " PO # ", g_po_ctrl_nbr, " ord_typ_cd = ", gr_str_po.ord_typ_cd, " recv_ctrl_nbr = ", gr_str_recv.recv_ctrl_nbr, " SQLERRM = ", SQLCA.SQLERRM CLIPPED CALL exec_abend_proc( gr_appl_log.* ) RETURNING p_rtn_cd LET p_rtn_cd = 1 RETURN p_rtn_cd, p_element_cnt, p_col_heading END IF This code works on the HP machines but does not work on our AIX box. It compiles OK, but the string p_select_for is corrupted: ****** 'PART', sku_nbr, ord_qty, 0, 0, 0, sku_cost_amt FROM str_po_sku W HERE loc_nbr = 86 AND loc_typ_cd = 'STR ' AND acct_po_typ_cd = '0' AND po_ct rl_nbr = 63420 AND ord_seq_nbr = 1 AND ord_qty > 0 and therefore the SQL statement fails. We have been able to clean up the string by changing the code from one concatenation of many substrings to many concatenations of a few substrings: LET p_select_for = "SELECT po_line_nbr, ", " 'PART', ", " sku_nbr, ", " ord_qty, ", " 0, ", " 0, ", " 0, ", " sku_cost_amt ", "FROM str_po_sku ", " WHERE " let p_select_for = p_select_for clipped," loc_nbr = ", gr_str_recv.loc_nbr let p_select_for = p_select_for clipped," AND loc_typ_cd = '", gr_str_recv.loc_typ_cd CLIPPED,"'" let p_select_for = p_select_for clipped," AND loc_typ_cd = '", gr_str_recv.loc_typ_cd CLIPPED,"'" let p_select_for = p_select_for clipped," AND acct_po_typ_cd = '", gr_str_recv.acct_po_typ_cd CLIPPED,"'" let p_select_for = p_select_for clipped, " AND po_ctrl_nbr = ", g_po_ctrl_nbr let p_select_for = p_select_for clipped, " AND ord_seq_nbr = ", gr_str_recv.ord_seq_nbr let p_select_for = p_select_for clipped, " AND ord_qty > 0 " These two code segments should be synonymous, but they are not on the AIX box. We need to know if this is a known bug (that will be corrected on the Y2K compliant version we are about to install) or if there is a compiler option that can be changed to make the old code work, or if we have overlook something obvious to you. This code style is prevalent in the subsystems we are porting to the AIX box and changing every occurance would be a substantial task. Please call me with any questions at x18913, I can step you through this or show you further examples if needed. Thanks, Charlie