This article describes how to avoid having a run-time query return an "ORA-01403: no data found" message.
Problem:
The directive used for compiling is
- dialect(ENTCOBOL) charset(ascii) SHOW-DIR copyext(cpy,cob,cpy) initcall "rtsora_t.so" p(cobsql) CSQLT=ORACLE8 DEBUGFILE SQLDEBUG MAKESYN VERBOSE end-c COMP5=NO picx=varchar2 SQLCHECK=FULL USERID=POC_USER/POC_USER@IKNPOC p(cp) endp FOLDCALLNAME LIST() OUTDD(SYSOUT,121,R) OLDNEXTSENTENCE endp;
One of the queries is returning an "ORA-01403: no data found" message, even though the data is present in the table.
-EXEC SQL
SELECT CUSTOMER_NBR,
CONTRACT_ID,
CONTRACT_STATUS,
EFFECTIVE_DATE,
ACQUISITION_DATE,
SETUP_DATE,
CYCLE_DATE,
LATEST_END_DATE,
DT_FOR_INVOICING,
PREBILL_SPAN,
LATE_CHRG_DATE,
LATE_CHARGE_NBR,
BILL_DATE,
COLL_FIRST_UNPD,
CURRENT_AGED,
LEO_STATUS,
BRANCH_CO_NBR,
BRANCH_NBR,
SUSPEND_DATE,
CLOSE_BILL_IND,
LEO_IND
INTO :ALF4000-CONTRACT:ALF4000-STAT-CD
FROM CONTRACT
WHERE CUSTOMER_NBR = :ALFSQL-CUSTOMER-NBR
AND CONTRACT_ID= :ALFSQL-CONTRACT-ID
END-EXEC.
Resolution:
Use CHARF instead of VARCHAR in the PICX directive.
The PICX directive specifies the default datatype of PIC X variables. The syntax for PICX is:
PICX={CHARF | VARCHAR2}
The default value is CHARF
The PICX directive can be entered only on the command line or in a configuration file.
Starting in Pro*COBOL 8.0, the default datatype of PIC X, N, or G variables was changed from VARCHAR2 to CHARF. PICX is provided for backward compatibility.
This new default behavior is consistent with the normal COBOL move semantics. Note that this is a change in behavior for the case where you are inserting a PIC X variable (with MODE=ORACLE) into a VARCHAR2 column. Any trailing blanks which had formerly been trimmed, will be preserved.
Note also, that the new default lessens the occurrence of the following:
Using a PIC X bind variable initialized with trailing blanks in a WHERE clause would never match a value with the same number of trailing blanks which was stored in a char column, because the bind variable's trailing blanks were stripped before the comparison.
#Server
#netexpress
#Enterprise
#EnterpriseServer
#COBOL