prepare(String[, Function]) Method
Prepares the specified SQL statement and returns a Statement object.
Parameters
| Type | Name | Description |
|---|---|---|
| String | sql | The SQL statement to be prepared. |
| Function | callback | The optional callback function. |
Returns
If no callback is specified, then a Statement object is returned.
Remarks
This method can be synchronous or asynchronous. Specify a callback function to use this method asynchronously. The callback function is of the form:
function(err, Statement)
{
};
Example
The following synchronous example shows how to use the prepare method.
var hana=require('@sap/hana-client');
var client=hana.createConnection();
client.connect("serverNode=myserver:30015;uid=system;pwd=manager");
stmt=client.prepare("SELECT * FROM Customers WHERE ID >= ? AND ID < ?");
var result=stmt.exec([200, 300]);
console.log(result);
client.disconnect();