-
Notifications
You must be signed in to change notification settings - Fork 196
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, |
Dozens of variations fail to execute my call to 'stmt' so when I saw this I thought I would try again......but using this very different format just gives the never-ending msg given by a dozen other attempted formats of a call to an SP: My Script after trying to mirror the advice given but my parms are not arrays of course: (watch for comments, it's a clone) import os os.add_dll_directory("C:\HighmarkApps\Python3.12.2\Lib\site-packages\clidriver\bin") os.add_dll_directory("C:\HighmarkApps\Python3.12.2\Lib\site-packages\clidriver\bin\amd64.VC12.CRT") import sys for p in sys.path: import ibm_db conn_string = "DSN=DB2TVIPA;UID=LIDDVDP;PWD=Karjulkenhedstv20;DATABASE=DB2TVIPA;HOSTNAME=DB2TVIPA;PORT=447;PROTOCOL=TCPIP;SECURITY=SOCKETS;AUTHENTICATION=SERVER;CURRENTSCHEMA=DB2TEST;" conn = ibm_db.connect(conn_string, "", "") if not conn: hp_id = "000923196" print ("Values of parameters before CALL:") print(hp_id, user_id, first_code, first_string, second_code, second_string, reason) params = (hp_id, user_id, first_code, first_string, second_code, second_string) #SET SCHEMA DB2TVIPA.DB2TEST; ibm_db.callproc(conn,"DB2TEST.SP_DEN_PRV_GET_PROVIDER_PRACTICE_NAME", params) stmt = ibm_db.prepare(conn, "CALL DB2TEST.SP_DEN_PRV_GET_PROVIDER_PRACTICE_NAME(?, ?, ?, ?, ?, ?)")
ibm_db.close(conn) |
@Dutch58 you should create a separate new issue for your symptom because your question is not about arrays. After you create a new issue, Please follow the instructions below to upload tracefiles that will allow us to see what is really happening. On your ms-windows workstation, open a cmd shell with "Run as administrator", and in that window run the commands below (change to use your real script name, instead of your_script.py): Ensure that db2trc.exe is on your PATH, and if not, then use
Now upload/attach those 3 files to your newly created issue, that is: %temp%\cli0150e.fmtcli , %temp%\cli0150e.fmt, %temp%\cli0150e.flw |
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: