-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python IBM_DB Array Enhancement #928
Comments
@op123singh, Array support is already provided for ibm_db [ The test suite for the array is available in: https://github.com/ibmdb/python-ibmdb/blob/master/ibm_db_tests/test_alltypesarray.py].
Kindly run the above test program and let me know the result. Thanks |
@Earammak, above stored procedure is taking one value at a time and does insert of one value at a time. So, say if we have an array of 50 elements, then stored procedure will be called 50 times for 50 elements insertion. CREATE OR REPLACE PROCEDURE PROCEDURE ( But actual requirement is to take all 50 elements as array into db2 z/OS and then unnest and insert to table with single array stored procedure execution. This type of array stored procedure execution is not being supported in python. Please find example of array stored procedure. Table Definition:CREATE TABLE MANOJKU.SIMPLE(INT_COLUMN int, STRING_COLUMN varchar(100)); Array Definition:CREATE TYPE MANOJKU.INTARRAY CREATE TYPE MANOJKU.VARCHARARRAY2 Stored Procedure Definition:CREATE OR REPLACE PROCEDURE MANOJKU.INSERTER2 INSERT INTO MANOJKU."SIMPLE"(INT_COLUMN , STRING_COLUMN) Sample Program:from faker import Faker crsp1 = """CREATE TYPE MANOJKU.INTARRAY crsp2 = """CREATE TYPE MANOJKU.VARCHARARRAY2 crsp3 = """CREATE OR REPLACE PROCEDURE MANOJKU.INSERTER2 INSERT INTO MANOJKU."SIMPLE"(INT_COLUMN , STRING_COLUMN) def rand_data_gen(rows): data2 = list(rand_data_gen(100)) arra_data1, arra_data2 = [], [] conn=ibm_db.connect(conn_str,'','') create1 = ibm_db.exec_immediate(conn, crsp1) stmt = ibm_db.prepare(conn, "CALL MANOJKU.INSERTER2(?, ?)") Kindly please let me know, if you need any additional information. Regards, |
Problem statement:
Above Python programs generates random values as array using random package
arra_data1 ,arra_data2,arra_data3,arra_data4,arra_data5 = [],[],[],[],[]
arra_data6,arra_data7,arra_data8,arra_data9 = [],[],[],[]
Stored procedure INSERTARRSP003 takes array as input and insert into table TABLE_INSERT_BASE1_001 using UNNEST array function.
These array values are passed as input to stored procedure MANOJKU.INSERTARRSP003 using python program with IBM_DB.
try:
stmt = ibm_db.prepare(conn, "CALL MANOJKU.INSERTARRSP003(?, ?, ?, ?, ?, ?, ?, ?, ?)")
Python programs is getting stuck with ibm_db.execute(stmt) , where it is trying to execute INSERTARRSP003 with array as input .
And it runs for hours without any progress nor abend , as currently IBM_DB does not provide support for array processing.
The text was updated successfully, but these errors were encountered: