IBM / python-itoolkit

itoolkit is a Python interface to the XMLSERVICE toolkit for the IBM i platform.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

That use itoolkit to run one sql query returns an BADPARSE error.

LiJunBJZhu opened this issue · comments

Recreated steps:

  1. Use iSqlQuery to run a sql "SELECT DATA FROM qusrsys.QATOCTCPIP WHERE KEYWORD='RMTNAMESV';" Below is the code.

    itool = iToolKit()

    itool.add(iSqlQuery('query', sql, {'error': 'on'}))
    itool.add(iSqlFetch('fetch'))
    itool.add(iSqlFree('free'))

    itool.call(itransport)

    command_output = itool.dict_out('fetch')

  2. However, seems there is a BADPARSE error.

The output:
{'error': {u'error1': u' ?xml version='1.0'? xmlservice sql var="query" query error="on" var="query" conn='conn1' stmt='stmt1' success ![CDATA[+++ success SELECT DATA FROM qusrsys.QATOCTCPIP WHERE KEYWORD='RMTNAMESV';]] /success /query /sql sql var="fetch" fetch block="all" error="fast" var="fetch" stmt='stmt1' row data desc='DATA' ![CDATA[9.0.128.50 9.5.178.0 U ', 'fetch': {...}, u'error': u'*BADPARSE'}}"

BTW, this sql "SELECT DATA FROM qusrsys.QATOCTCPIP WHERE KEYWORD='LOCALDMNME';" can be finished successfully. The only difference between the good one and the bad one is the value of KEYWORD.

The error report points to the "fetch" instruction, so there is probably a problem with the data returned.

Running the same SQL statement with keyword "RMTNAMESV" on our server returns some binary data after the 'U' character - so this seems to be the cause of the error.

I think you should be careful when accessing the table QATOCTCPIP - the column DATA is character but with CCSID 65535 which indicates binary data is stored in this column. Better use the "new" DB2 for i Services like QSYS2.TCPIP_INFO if possible...

QSYS2.TCPIP_INFO doesn't contain the info I need. Anyway, use the sql
select cast(data as varchar(100)) from qusrsys.qatoctcpip WHERE KEYWORD='RMTNAMESV' instead. Thanks.