Skip to content

Support for calling stored prcoedure with array parameter#1048

Merged
bimalkjha merged 2 commits intoibmdb:masterfrom
Earammak:sparraysupport_repo
Feb 27, 2026
Merged

Support for calling stored prcoedure with array parameter#1048
bimalkjha merged 2 commits intoibmdb:masterfrom
Earammak:sparraysupport_repo

Conversation

@Earammak
Copy link
Collaborator

@Earammak Earammak commented Feb 26, 2026

Implemented a new API to fetch the results of a stored procedure call using the prepare → bind → execute flow, with support for both scalar and array parameters.

Scalar support:
For procedures with single‑value arguments, ibm_db.fetch_callproc works seamlessly with ibm_db.callproc.
Scalars are bound using ibm_db.bind_param() with SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, or SQL_PARAM_INOUT.
Python values are mapped directly to SQL types.

Array support:
For procedures with array arguments, the implementation applies correct cardinality and buffer allocation using SQLSetDescField() with SQL_DESC_CARDINALITY and SQL_DESC_CARDINALITY_PTR.

INPUT arguments use the Implementation Parameter Descriptor (hIPD).

OUTPUT arguments use the Application Parameter Descriptor (hAPD).

INOUT arguments configure both hIPD and hAPD.

This logic is executed internally after SQLBindParameter, ensuring that both scalar and array parameters are properly bound before execution.

After execution, ibm_db.fetch_callproc retrieves updated parameter values.
For input parameters return the same values passed in and for OUT/INOUT parameters return the modified values produced by the stored procedure.

This enhancement allows to pass either Python lists (for arrays) or scalars (for single values) as parameters and receive the updated values after execution as a tuple containing the statement object followed by the parameters passed to the procedure.

Signed-off-by: Earamma K <ek@rocketsoftware.com>
Signed-off-by: Earamma K <ek@rocketsoftware.com>
@Earammak Earammak changed the title Support for calling stored prcoedure array parameter Support for calling stored prcoedure with array parameter Feb 27, 2026
@bimalkjha bimalkjha merged commit a9ce0d9 into ibmdb:master Feb 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants