wankdanker / node-odbc

ODBC bindings for node
MIT License
174 stars 79 forks source link

Binding parameters using a key value type #43

Open ranjithchev opened 5 years ago

ranjithchev commented 5 years ago

Hi

I understand that currently this library supports binding parameters but expects it be in the right order. select a,b from table1 where a=? and b=? and the binding parameters should be an array in the right order like ["abc", 2]

Is there a way we can support or have support to give the binding parameters as below (This is supported in mssql library).

select a,b from table1 where a=@v1 and b=@v2 request.add(paramname, paramvalue, paramtype) In the above example it would translate to request.add("v1", "abc", sql.Varchar) request.add("v2", 2, sql.Int)

Thanks Ranjith

asztal commented 5 years ago

I don't think this is possible. See the below quote from MSDN (emphasis mine):

Certain DBMSs allow an application to specify the parameters to a stored procedure by name instead of by position in the procedure call. Such parameters are called named parameters. ODBC supports the use of named parameters. In ODBC, named parameters are used only in calls to stored procedures and cannot be used in other SQL statements.

https://docs.microsoft.com/en-us/sql/odbc/reference/develop-app/binding-parameters-by-name-named-parameters?view=sql-server-2017

ranjithchev commented 5 years ago

Thank you.