ibmdb/python-ibmdb

ibm_db.callproc should return the stored procedures return value

sleakehe opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
ibm_db.callproc() currently returns a statement object that can be used to access result sets, and the in/out arguments. However, if the stored procedure returns some custom value via a RETURN statement, there is no way to capture that value.

Example proc:

CREATE OR REPLACE PROCEDURE check_odd_day ()
LANGUAGE SQL
BEGIN
    DECLARE current_day INT;
    DECLARE result INT;
    
    -- Get the current day
    SET current_day = DAY(CURRENT DATE);
    
    -- Check if the current day is odd
    IF MOD(current_day, 2) <> 0 THEN
        SET result = 1000;
    ELSE
        SET result = 2000; 
    END IF;
    
    RETURN result;
END

Describe the solution you'd like
I'd like ibm_db.callproc() to return the stored procedures return value.

Hello @sleakehe 
Please check the examples of ibm_db.callproc: https://github.com/ibmdb/python-ibmdb/wiki/APIs#ibm_dbcallproc.
As you are suggesting that ibm_db.callproc() return the stored procedure return value,
Can you please share a sample script for how ibm_db.callproc() can return the stored procedure return value and be able to display the output?

Please try to give sample output also, so that we can make progress on this enhancement part if required.

Thanks

@sleakehe, Can you please share the update for this?
Thanks