-
Notifications
You must be signed in to change notification settings - Fork 80
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
Is there SQLBindParameter() equivalent of node ODBC #69
Comments
Hi @SabaKauser , (Everything below is in reference to v2.0 and above, which is a complete rewrite of Does this driver has any SQLBindparameter() equivalent to allow developers to explicitly bind the parameters by passing the input C and SQL type? Just for clarification, When interacting with a table or a view with Is there a way to bind a file to parameter instead of the actual value? i.e I have some data in a file and I would like to bind this file to a parameter marker in my SQL instead of reading the contents and passing it. Currently there is no way to do this. It would be difficult to determine whether the String passed was intended as a String, or indicated a file name. The best thing to do would probably be to use the built-in File System APIs in Node.js and fs.readFile to get your file in a String or Buffer representation, which can then be bound to the parameter. As a side note, I notice that you are calling a stored procedure with |
ODBC supports SQLPutData and SQLGetData to stream large objects into and out of the database - of course that's even more work than SQLBindParameter. I did have both SQLBindParameter and SQLGetData working in the ODBC library I wrote, but it's very out of date now and was too low-level to use for most use cases. |
@markdirish Thank you! Thanks in advance! |
The .callProcedure documentation can be found in the 2.0 README, but it looks like the callback example doesn't actually document it, I will fix. Promise example work though. To use .callProcedure, you call: const result = await connection.callProcedure(<catalog>, <schema>, <procedureName>, [<parameters>]); When passing the array of parameters, the size of the array must match the number of parameters expected by the procedure called. OUT parameters still have to be passed, but can be passed as [ statement: '{ CALL MIRISH.MAXBAL (?) }',
parameters: [ 3987.5 ],
return: undefined,
count: 0,
columns: [] ] In the above example, I passed in [undefined] as my parameter, and because its an OUT parameter in the procedure, the value is placed in the result array's 'parameters' array NOTE It looks like the version on npm has a double free issue that regressed when I was fixing memory leaks. I have solved the problem on my local branch and look to push it today |
@markdirish in reference to the question/answer regarding binding file parameters...
Is there any plan to allow binding a |
Hello,
Does this driver has any SQLBindparameter() equivalent to allow developers to explicitly bind the parameters by passing the input C and SQL type?
or
Is there a way to bind a file to parameter instead of the actual value? i.e I have some data in a file and I would like to bind this file to a parameter marker in my SQL instead of reading the contents and passing it.
e.g:
var callStatement = "call mySP('par1',?);
// file filename has contents that I want to bind to second parameter
ibmdb.query(callStatement, [filename],function (err, result){
if (err) {
console.log(err);
return cb("Error " + err, "-1");
}
else {
console.log("Affected rows = " + result);
//In some cases closing of StatementHandle is also needed stmt.closeSync();
// result.closeSync();
return cb("success", "Rows affected : " + result);
}
Thanks in Advance!
The text was updated successfully, but these errors were encountered: