IBM / node-odbc

ODBC bindings for node
MIT License
143 stars 75 forks source link

Rewrite call procedure #376

Open markdirish opened 5 months ago

markdirish commented 5 months ago

This PR changes the procedure workflow from:

SQLProcedures -> SQLProcedureColumns -> SQLExecDirect

to

SQLPrepare -> SQLDescribeParam -> SQLBind -> SQLExecDirect

This will allow users to call a procedure with just the procedure name, even if that procedure exists in multiple schemas/libraries.

brandonp42 commented 5 months ago

Will this allow CLOB parameters on procedure calls? See #355 for context

brandonp42 commented 4 months ago

Hi Mark,

Just curious how close you are to releasing this change?

Thanks! Brandon

brandonp42 commented 3 months ago

Would it make sense to use the old code path for drivers that don't support IPD?

kadler commented 3 months ago

Given the problems we've had with it, I think it'd be a better idea to design a way to have the user specify the direction as-needed.

Maybe something like:

// IN, OUT, INOUT exported by the node-odbc package
params = [
    { data: 1, direction: IN },
    { data: undefined, direction: OUT },
    { data: 'hello', direction: INOUT },
}
const result = await connection.callProcedure(null, null, 'MY_PROC', params);

Not sure if it actually matters on OUT vs INOUT. If not, it could be simplified by just binding them both as INOUT and then the direction field could be changed to a boolean is_output. Although, now that I'm thinking about it could just bind everything as INOUT in that case and not even worry about it. But that all hinges on whether database drivers are ok with binding that way.