Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rmcobol InstantSQL

Status
Not open for further replies.

TSTEVENS123

Programmer
May 13, 2021
4
US
I am new at using the InstantSQL for RMCOBOL. I have rmcobol installed on a 64-bit Unix machine. I have setup an ODBC connection to a DB2 v12 mainframe database. When my program does the SQL BIND Command any field that is CHAR is spaces when I display my working storage field. I also have 2 decimal columns that I pull from the table and they display fine. If I get a good sql-ok after the fetch then I display my working storage fields. The decimals show the values but the cus-id is always spaces. I tried pulling other char columns from the table in the select statement and they are all spaces. I also turned on unixODBC trace and every sql command gets good return codes. Any help would be appreciated.

Working Storage section....
01 DM-RATE-TABLE.
02 CUS-ID PIC X(9).
02 DAILY-INT-AM-PER-HUN PIC 9.9(9).
02 INT-AM-PER-HUN PIC 9.9(9).
Procedure section....

050-ISQL-CONNECT-DATASOURCE.
SQL CONNECT DATASOURCE
sql-ConnectionHandle,
sql-DataSourceName,
sql-UserName,
sql-UserPassword.
IF NOT sql-OK
DISPLAY "<Error connecting to SD0T data source.>"
PERFORM 1000-SQL-ERROR thru 1000-exit
STOP RUN.
060-DISCONNECT-SQLSERVER.
MOVE SQLServer-ConnectionHandle TO sql-ConnectionHandle.
PERFORM 070-ISQL-DISCONNECT-DATASOURCE.
MOVE ZERO TO SQLServer-ConnectionHandle.

070-ISQL-DISCONNECT-DATASOURCE.
SQL DISCONNECT DATASOURCE
sql-ConnectionHandle.
MOVE ZERO TO sql-ConnectionHandle.
080-SQL-SHUTDOWN.
SQL SHUTDOWN.
100-CONSTRUCT-QUERY.
SQL CONSTRUCT QUERY sql-QrySQL,
"SELECT CUS_ID, DAILY_INT_AM_PER_HUN, INT_AM_PER_HUN ",
"FROM CX.DAILY_RATE",
"WHERE PMT_DT = '2021-02-14'".
200-PREPARE-QUERY.
IF sql-ConnectionHandle = ZERO
PERFORM 050-ISQL-CONNECT-DATASOURCE.
SQL PREPARE QUERY
sql-QueryHandle,
sql-ConnectionHandle,
sql-QrySQL.
SQL BIND PARAMETER
sql-QueryHandle
1, sql-Char, OMITTED,
2, sql-Decimal, OMITTED,
3, sql-Decimal, OMITTED.
300-EXECUTE-QUERY.
SQL START QUERY
sql-QueryHandle.
400-BIND-DATA.
SQL BIND COLUMN sql-QueryHandle
1, CUS-ID, OMITTED,
2, DAILY-INT-AM-PER-HUN, OMITTED,
3, INT-AM-PER-HUN, OMITTED.
500-FETCH-ROW.
SQL FETCH ROW
sql-QueryHandle
If sql-OK
DISPLAY DM-RATE-TABLE LINE 19 POSITION 1
ACCEPT WSOK LINE 24 POSITION 1.
600-END-QUERY.
SQL END QUERY
sql-QueryHandle.

 
1. Have you confirmed that there is data in the CustID column in DB2?
2. Have you confirmed the size and data type of the CustID column in DB2? Is it Char or Varchar? Is it size 9? Are you getting truncation because the DB2 field is larger and there are, perhaps, leading spaces? Is ODBC acting weird because the field sizes are different or the field types are different?
3. Try defining CUST-ID as PIC 9(9) and see if ODBC will do an implicit conversion to numbers. (this is a workaround)

The fact that you can't get anything except SPACES for any CHAR/VARCHAR column is worth a support call.
 
Yes the CUS_ID has data. When I do the same select statement in QMF for windows, I get 8 records back all 3 columns have data. The column is char and defined as 9 characters NOT NULL. I wondered if there was an environment variable setting or something that we might have set wrong.
 
yeah, maybe. I am not a RM Cobol person. I'm mostly Microfocus, and various proprietary flavors like IBM mainframe, Unisys, etc. And we used Oracle Pro*COBOL for our SQL calls from Microfocus. In Oracle, the process is called "Binding", which may or may not be the IBM or RM terminology.
 
We finally found the issue. My Linux admin had to change the /etc/odbcint.ini file to a different DB2 driver. Reading some IBM pages, they suggest using libdb2o.so instead of libdb2.so.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top