IBM i Access Client Solutions

 View Only
Expand all | Collapse all

IBM i Access ODBC for Linux

  • 1.  IBM i Access ODBC for Linux

    Posted Tue July 25, 2023 01:02 PM

    Hi all. I'm looking for someone with a better knowledge, who can help me in this situation.

    Scenario

    I'm trying to connect to IBM i Systems (AS400) from docker container, which is based on Linux(Debian).

    I did get the drivers from IBM repository which are "IBM i Access ODBC Driver 64-bit" and "IBM i Access ODBC Driver".

    Result:

    By testing connection to IBM i System connection is successful, however, when I try to execute sql i get an error: "[IBM][System i Access ODBC Driver][DB2 for i5/OS]PWS0001 - Function did not complete successfully. (69798) (SQLExecDirectW)')" and there is no more information on the error. I use python and pyodbc to query the database. Query and user permissions are also correct as same script runs fine on windows machine with windows iSeries Access ODBC drivers.

    BPCS/AS400 our organisation is using is very old and windows drivers that work for other windows machines are dated to year 2009.

    Thanks for any help in advance.



    ------------------------------
    Dainis Lubgans
    ------------------------------


  • 2.  RE: IBM i Access ODBC for Linux

    IBM Champion
    Posted Wed July 26, 2023 02:53 AM

    Dear Dainis

    From what you described, it sounds like you use a very old ODBC driver for Windows rather than one for Linux. (And I wonder how you installed it into Debian in the first place?) You should install IBM i ODBC driver for Linux from IBM i ACS' Linux Application Package which is downloaded from IBM Entitled Systems Support web site.  You need to create an IBM ID to use it and it is free of charge. This article explains how to download it :  https://techchannel.com/SMB/06/2019/acs-application-packages

    These web sites also have additional information that may be useful fro you on IBM i ACS ODBC driver for Linux  :

     https://github.com/IBM/ibmi-oss-docs/blob/master/odbc/installation.md#linux

     https://www.ibm.com/docs/en/i/7.2?topic=package-i-access-odbc



    ------------------------------
    Education is not the learning of facts but the training of the mind to think. -- Albert Einstein.
    ------------------------------
    Satid S.
    ------------------------------



  • 3.  RE: IBM i Access ODBC for Linux

    Posted Wed July 26, 2023 06:13 AM

    Hi Satid Singkorapoom,

    Appreciate your prompt response. I think there is a bit of misunderstanding. When I mentioned Windows, I meant that we have other machines that are windows PC's. Drivers on those are iSries Aceess ODBC drivers that are a bit old, however when I tested my python script on those machines everything worked as expected. Now I'm building an application which will be reporting tool that gets and displays the data. My application runs in docker container which is Linux based. I have installed linux i access odbc drivers ("IBM i Access ODBC driver", "IBM i Access ODBC driver 64-bit") on it and also tested with iSQL, which reports back successful connection, however, when I try to execute queries I get a very generic error: "Function did not complete successfully." and "Could not SQL Prepare". Just thinking if there anything else that needs to be installed along the driver. Could be also that some driver configurations need to be different compared to those on windows. 



    ------------------------------
    Dainis Lubgans
    ------------------------------



  • 4.  RE: IBM i Access ODBC for Linux

    IBM Champion
    Posted Wed July 26, 2023 09:50 PM
    Edited by Satid Singkorapoom Wed July 26, 2023 11:13 PM

    I see. So, it seems ODBC installation was fine but the submission of remote SQL from your docker container to IBM i had an error. Since the error had to do with SQLExecDirectW and "Could not SQL Prepare", my guess is that this error may have to do with what is called SQL Extended Dynamic mode in DB2i. 

    Please look at the ODBC data source parameter named ExtendedDynamic whether it is now set to a value of 1 or not ( use the instruction from Manually configure an ODBC data source at https://www.ibm.com/docs/en/i/7.2?topic=source-manually-configure-odbc-data ).   If so, you can set it to zero and run your docker's query again to see if you still get the same error or not. If not, then my guess is correct.

    If the same SQL statement is to be used multiple times, use SQLPrepare once, then use SQLExecute each time you want to run the statement will deliver faster execution time than using SQLExecDirect every time.  More info here :  https://www.ibm.com/support/pages/system/files/inline-files/$FILE/IBM%20DB2%20for%20i%20tips_%20SQL%20CLI%20frequently%20asked%20questions.pdf



    ------------------------------
    Education is not the learning of facts but the training of the mind to think. -- Albert Einstein.
    ------------------------------
    Satid S.
    ------------------------------



  • 5.  RE: IBM i Access ODBC for Linux

    IBM Champion
    Posted Wed July 26, 2023 10:04 PM
    Edited by Satid Singkorapoom Wed July 26, 2023 10:13 PM

    By the way, what is the release of your IBM i ?

    You may want to start ODBC traceing in order to see more information. Instruction is here : Must Gather Diagnostic Material for IBM i Access Client Solutions (ACS) Linux Application Package ODBC Problems at https://www.ibm.com/support/pages/must-gather-diagnostic-material-ibm-i-access-client-solutions-acs-linux-application-package-odbc-problems

    ------------------------------
    Education is not the learning of facts but the training of the mind to think. -- Albert Einstein.
    ------------------------------
    Satid S.
    ------------------------------



  • 6.  RE: IBM i Access ODBC for Linux

    Posted Thu July 27, 2023 06:35 AM

    Thanks for continuous support,

    I have tried to change ExtendedDynamic to either values, but still no luck.

    When I use iSQL I get successful connection, but when executing query I get an error:
    +---------------------------------------+
    | Connected!                            |
    |                                       |
    | sql-statement                         |
    | help [tablename]                      |
    | quit                                  |
    |                                       |
    +---------------------------------------+
    SQL> SELECT * FROM IIM

    When I execute python scripts that runs same query using same connection with pyodbc, I get this very generic error:

    pyodbc.Error: ('HY000', '[HY000] [IBM][System i Access ODBC Driver][DB2 for i5/OS]PWS0001 - Function did not complete successfully. (69798) (SQLExecDirectW)')

    Here is my DSN:
    [AS400]
    Description          = IBM i Access ODBC Driver
    Driver               = IBM i Access ODBC Driver
    System               = <domain name>
    UserID               = <user>
    Password             = <password>
    Naming               = 0
    DefaultLibraries     = ENGBPCSF
    Database             =
    ConnectionType       = 0
    CommitMode           = 2
    ExtendedDynamic      = 0
    DefaultPkgLibrary    = QGPL
    DefaultPackage       = A/DEFAULT(IBM),2,0,1,0,512
    AllowDataCompression = 1
    LibraryView          = 0
    AllowUnsupportedChar = 0
    ForceTranslation     = 0
    Trace                = 0

    Here are my driver configurations:

    [IBM i Access ODBC Driver]
    Description=IBM i Access for Linux ODBC Driver
    Driver=/opt/ibm/iaccess/lib/libcwbodbc.so
    Setup=/opt/ibm/iaccess/lib/libcwbodbcs.so
    Driver64=/opt/ibm/iaccess/lib64/libcwbodbc.so
    Setup64=/opt/ibm/iaccess/lib64/libcwbodbcs.so
    Threading=0
    DontDLClose=1
    UsageCount=1

    [IBM i Access ODBC Driver 64-bit]
    Description=IBM i Access for Linux 64-bit ODBC Driver
    Driver=/opt/ibm/iaccess/lib64/libcwbodbc.so
    Setup=/opt/ibm/iaccess/lib64/libcwbodbcs.so
    Threading=0
    DontDLClose=1
    UsageCount=1



    I have included cwbmedic, cwbdetail and odbc logs in case if this can help:https://drive.google.com/drive/folders/1q5ehBikhutQ6Zw2NaQexaZ-o2ssyzl0c?usp=sharing



    ------------------------------
    Dainis Lubgans
    ------------------------------



  • 7.  RE: IBM i Access ODBC for Linux

    Posted Thu July 27, 2023 07:10 AM

    Release of the IBM i is V5R3M0



    ------------------------------
    Dainis Lubgans
    ------------------------------



  • 8.  RE: IBM i Access ODBC for Linux

    IBM Champion
    Posted Thu July 27, 2023 08:13 PM
    Edited by Satid Singkorapoom Thu July 27, 2023 08:20 PM

    Dear Dainis

    I have a hunch that IBM i ACS ODBC driver may be very likely not to support SQL execution to V5R3 server. The reason may be likely that the ODBC protocol level of V5R3 may be too low and is not compatible with the level used in IBM i ACS ODBC driver. Not to mention V5R3 is no longer supported by IBM.   I did a Google search and found a few information implicitly stating that V5R4 is the lowest release supported by IBM i ACS (File transfer and 5250 emulation).

    ------------------------------
    Education is not the learning of facts but the training of the mind to think. -- Albert Einstein.
    ------------------------------
    Satid S.
    ------------------------------



  • 9.  RE: IBM i Access ODBC for Linux

    Posted Fri July 28, 2023 05:55 AM

    Thank you Satid

    That was what I was afraid off, taking in account how old the system is. If the only option is to use old windows iSeries ODBC drivers our organisation have, I have two potential workarounds:

    1. Create database proxy on windows server with Windows i Series ODBC drivers installed and access proxy from the docker container
    2. Try to use Windows base docker image and install old drivers there and use the image for the application.


    ------------------------------
    Dainis Lubgans
    ------------------------------



  • 10.  RE: IBM i Access ODBC for Linux

    Posted Wed July 26, 2023 01:25 PM

    these have helped me in the past:

    IBM i Access ODBC Installation - IBM i OSS Docs documentation (ibmi-oss-docs.readthedocs.io)
    ibm-iaccess for Linux ODBC Configuration




    ------------------------------
    Bryan Dietz
    ------------------------------