ThunderCloud
ThunderCloud

Reputation: 91

How to pass table type in oracle using python(cx_oracle or oracledb)

i want to pass table type in call_proc using python.

But i'm getting error while running.

PLS-00306: wrong number or types of arguments in call to 'REPORT_P'
ORA-06550: line 1, column 7:
PROCEDURE report_p
    (
        OUT_details     OUT SYS_REFCURSOR,
        IN_col      IN col,
        IN_com  IN  VARCHAR2,
        IN_id       IN NUMBER
    )
create or replace TYPE col AS OBJECT
(
    name        VARCHAR2(4000),
    mn        VARCHAR2(4000),
    fil    VARCHAR2(4000)

);

my code

out_val = cur.var(oracledb.CURSOR)
cur.callproc("report_p",(out_val,[],"Radio",21222))

Upvotes: 0

Views: 174

Answers (1)

Anthony Tuininga
Anthony Tuininga

Reputation: 7086

To pass an object like col you need to create one first. Something like this:

typ = conn.gettype("COL")
obj = typ.newobject()
obj.NAME = "NAME value"
obj.MN = "MN value"
obj.FIL = "FIL value"
ref_cursor = conn.cursor()
cursor.callproc("report_p", [ref_cursor, obj, "Radio", 21222])

Upvotes: 3

Related Questions