Skip to content

How to use OUT/INPUT params in callproc() ? #75

@liaosnet

Description

@liaosnet

I'm try to call proc with OUT/INPUT params like test_146_CallSPINAndOUTParams.py, but it's not work.
here is my procedure and script

-- procedure match_animal with INOUT and OUT params
CREATE PROCEDURE match_animal(first_name VARCHAR(128), INOUT second_name VARCHAR(128), OUT animal_weight DOUBLE PRECISION )
  DEFINE match_name INT;
  LET match_name = 0;
  LET second_name = 'TRUE';
  LET animal_weight = 10;
END PROCEDURE;
#!/usr/bin/env python3

import sys
import IfxPy

print("Python IfxPy.callproc() start.\n")
connectStr="PROTOCOL=onsoctcp;HOST=192.168.80.70;SERV=9088;PROT=onsoctcp;SRVR=ids1410;DB=testdb;UID=informix;PWD=informix;DLOC=zh_CN.ut
f8;CLOC=zh_CN.utf8"
conn=IfxPy.connect(connectStr, "", "")

if conn:
    name = "Peaches"
    second_name = "Rickety Ride"
    weight = 0

    print("Values of bound parameters _before_ CALL:")
    print("  1: %s 2: %s 3: %d\n" % (name, second_name, weight))

    stmt, name, second_name, weight = IfxPy.callproc(conn, 'match_animal', (name, second_name, weight))

    if stmt is not None:
        print("Values of bound parameters _after_ CALL:")
        print("  1: %s 2: %s 3: %d\n" % (name, second_name, weight))

IfxPy.close(conn)

print("\nPython IfxPy.callproc() finish.")
sys.exit(0)

run it with "python3 T2.py", the output:

Python IfxPy.callproc() start.

Values of bound parameters _before_ CALL:
  1: Peaches 2: Rickety Ride 3: 0

Traceback (most recent call last):
  File "T2.py", line 18, in <module>
    stmt, name, second_name, weight = IfxPy.callproc(conn, 'match_animal', (name, second_name, weight))
Exception: [OneDB][OneDB ODBC Driver][OneDB]Argument must be a Statement Local Variable or SPL variable or argument for an SQLCODE=-9752

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions