When using SQL Server, the library automatically fetches and caches stored procedure definitions. However, for other ODBC connections (such as Sybase), you must manually register the stored procedure using the procedureMgr to ensure the library understands the parameter mapping.
To register a procedure:
- Access the procedure manager via
connection.procedureMgr(). - Define parameters using
pm.makeParam(spName, paramName, type, size, isOutput). - Add the procedure to the manager using
pm.addProc(spName, params). - Set the appropriate dialect using
proc.setDialect(pm.ServerDialect.Sybase) (or the relevant dialect for your connection).
const pm = connection.procedureMgr();
const params = [
pm.makeParam(spName, '@param1', 'varchar', 30, false),
pm.makeParam(spName, '@param2', 'int', 0, true) // true for output
];
const proc = pm.addProc(spName, params);
proc.setDialect(pm.ServerDialect.Sybase);