how to pass the array object?
Here I have connected the Oracle DB through Python by using the Oracledb library
#DB connection
connection = oracledb.connect(user="hr", password=userpwd,dsn="dbhost.example.com/orclpdb")
#cursor object
cursor = connection.cursor()
#declare a output variable
out_values = cursor.var(int)
here i need to pass the pass the values to oracle stored procedure
array_values = ['u','U','G']
cursor.callproc('schema.pkg.get_prc',[array_values ,9713979, '2', '2', 'N'])
above array_values I need to pass the array object.how to pass the array object?
"errorMessage": "ORA-06550: l: wrong number or types of arguments in call to 'get_prc
below are the stored procedure
**schema.pkg.get_prc**(pt_enrol_data IN tb_enrol_matching,
p_enrol_log_id IN NUMBER,
p_columns IN VARCHAR2,
p_dynamic_columns IN VARCHAR2)
CREATE OR REPLACE TYPE schema.tb_enrol_matching
IS OBJECT
Email VARCHAR2(4000),
Forename VARCHAR2(4000),
Lastname VARCHAR2(4000),);
how to pass the array object and call the stored procedure i dont know the problem is, I believ. Thanks in advance.`
Your data-type of the column in the database is NOT an array; it is an object. Therefore you do NOT want to pass an array from python; you want to pass an object.
See the "7.12. Changing Bind Data Types using an Input Type Handler" documentation. Which gives the example:
Change
Buildingto match the structure ofTB_ENROL_MATCHING:Note: this is untested as I do not have your tables or procedure to test against but you should get the general idea of how to implement it.
If you wanted to simplify it to the bare minimum code then:
Note 2: Again untested for the same reasons.