Db2

 View Only
  • 1.  db2 docker container error when convert boolean to uint8

    Posted Wed July 31, 2019 09:16 AM
    Edited by System Fri January 20, 2023 04:13 PM
    Hello,

    Since the db2-developer-c-edition docker image is going to sunset on 7/31, I setup a ibmcom/db2 docker container.  We use this Golang orm GORM (https://github.com/jinzhu/gorm). In our program, one of a class has variable named IS_PUBLIC and data type is uint8. Then, in the DB2 database table, the data type corresponding to  IS_PUBLIC is a boolean. It is fine when saving the value of IS_PUBLIC into database. However, it has error when I retrieve the data out from database.

    The error is
    [2019-07-29 17:09:39] sql: Scan error on column index 6, name "IS_PUBLIC": converting driver.Value type bool ("true") to a uint8: invalid syntax

    When I switch back to  "Db2 Developer-C Edition" docker image, it works fine. Is this a db2 docker image problem or the GORM has problem?
    Thanks,


    ------------------------------
    ERIN MEI
    ------------------------------
    #Db2


  • 2.  RE: db2 docker container error when convert boolean to uint8

    Posted Thu August 01, 2019 10:05 AM

    Hi Yuechang. I'm assuming that the previous version of Db2 you were running was 11.1 and the latest container is 11.5? I know that there were some changes in the client code that may have changed the way that boolean values were being interpreted. Can you update the Db2 environment variable in your Docker container and restart the database to see if this makes any difference to the results?

    db2set DB2_ENABLE_BOOL_DESC=NO

    My understanding is that in Db2 11.5 this value is set to YES which means that the driver code gets a descriptor that says it is a boolean value where in Db2 11.1 is was NO which means it is returned as an integer value. I have seen this error occur with Python and Jupyter notebooks when using 11.5 and this change fixed the errors.



    ------------------------------
    GEORGE BAKLARZ
    ------------------------------



  • 3.  RE: db2 docker container error when convert boolean to uint8

    Posted Thu August 01, 2019 11:27 PM
    Hi George,

    My coworker helped me to verify that setting db2set DB2_ENABLE_BOOL_DESC=NO can fixed the error in Db2 11.5. I don't see this error in Db2 11.1. Thank you very much.



    ------------------------------
    YUECHANG MEI
    ------------------------------