This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

InstantSQL for Linux

I am new to InstantSQL and I am running RMCobol on Linux 64bit.  I am using InstantSQL to select columns from a table that is on IBM DB2 mainframe, which I am using an unixODBC driver manager.  Any column that is defined as a CHAR, doesn't give me any values back on the SQL BIND COLUMN statement.  The database has it defined as CHAR 9, NOT NULL and I have it defined as PIC X(9) in working storage to bind to.  Any decimal columns that I have seem to work fine.  The CUS_ID column is the one I am having issues with below. Any help would be appreciated. 

Working Storage.

01 DM-RATE-TABLE.
     02 DM-DAILY-INT-AM-PER-HUN PIC 9(12)V9(9).
     02 DM-INT-AM-PER-HUN PIC 9(12)V9(9).
     02 DM-CUS-ID PIC X(09).

Procedure Division.

100-CONSTRUCT-QUERY.
     SQL CONSTRUCT QUERY
             sql-QrySQL,
      "SELECT DAILY_INT_AM_PER_HUN, INT_AM_PER_HUN, CUS_ID",
      "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.
300-EXECUTE-QUERY.
       SQL START QUERY
           sql-QueryHandle.
400-BIND-DATA.
        SQL BIND COLUMN sql-QueryHandle,
        1, DM-DAILY-INT-AM-PER-HUN, OMITTED,
        2, DM-INT-AM-PER-HUN, OMITTED,
        3, DM-CUS-ID, WS-CUSID-LEN.
500-FETCH-ROW.
        SQL FETCH ROW
             sql-QueryHandle.

  • Verified Answer

    +1  

    Traci,

    I'll have to try and reproduce your testcase, but here's a quick suggestion: I notice that there isn't a space after CUS_ID in the second argument to SQL CONSTRUCT QUERY, and I'm wondering if that's not required. It could be that there's nothing wrong with character columns, the database just doesn't recognize the column name. I must admit that I'd expect there to be a syntax error parsing the SQL statement, so my hopes that this is it are low, but it's something quick to try.

  • 0 in reply to   

    I tried to add the space, but that didn't fix it.  I changed the select to just pull the CUS_ID.  Her is the ODBC_trace_log from that select. 

  • 0 in reply to 

    [ODBC][20901][1620140733.180797][SQLPrepare.c][196]
    Entry:
    Statement = 0x1681ad0
    SQL = [SELECT CUS_ID FROM CX.DAILY_RATE WHERE PMT_DT = '2021-02-14'][length = 60]
    [ODBC][20901][1620140733.180942][SQLPrepare.c][371]
    Exit:[SQL_SUCCESS]

    [ODBC][20901][1620140733.183240][SQLDescribeCol.c][247]
    Entry:
    Statement = 0x1681ad0
    Column Number = 1
    Column Name = 0x1688070
    Buffer Length = 129
    Name Length = 0x162f424
    Data Type = 0x162f426
    Column Size = 0x162f3f8
    Decimal Digits = 0x162f420
    Nullable = 0x162f422
    [ODBC][20901][1620140733.183278][SQLDescribeCol.c][497]
    Exit:[SQL_SUCCESS]
    Column Name = [CUS_ID]
    Data Type = 0x162f426 -> 1
    Column Size = 0x162f3f8 -> 9
    Decimal Digits = 0x162f420 -> 0
    Nullable = 0x162f422 -> 0
    [ODBC][20901][1620140733.183312][SQLColAttributes.c][280]
    Entry:
    Statement = 0x1681ad0
    Column Number = 1
    Field Identifier = SQL_DESC_UNSIGNED
    Character Attr = (nil)
    Buffer Length = 0
    String Length = (nil)
    Numeric Attribute = 0x7fff3d430c88
    [ODBC][20901][1620140733.183351][SQLColAttributes.c][597]
    Exit:[SQL_SUCCESS]

    [ODBC][20901][1620140733.183378][SQLBindCol.c][236]
    Entry:
    Statement = 0x1681ad0
    Column Number = 1
    Target Type = 1 SQL_CHAR
    Target Value = 0x16846e0
    Buffer Length = 10
    StrLen Or Ind = 0x1684660
    [ODBC][20901][1620140733.183406][SQLBindCol.c][341]
    Exit:[SQL_SUCCESS]

  • 0 in reply to   

    We found the issue.  My linux adminstrator 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.