ParameterStatement
ODBC parametrized statement that supports SQL variables
Operations
- Close
- GetLastError
- Select
- SetBigInt
- SetBit
- SetBlob
- SetBytes
- SetDate
- SetDouble
- SetInt
- SetReal
- SetSmallInt
- SetTimestamp
- SetVarchar
- Update
GetLastError #
Gets the last error message from the statement.
method : public : GetLastError() ~ StringReturn
| Type | Description |
|---|---|
| String | error message string, or empty if no error |
Select #
Executes a SQL select statement
method : public : Select() ~ ResultSetReturn
| Type | Description |
|---|---|
| ResultSet | result set |
Example
conn := Database.ODBC.Connection->New("mydsn", "user", "pass");
stmt := conn->CreateParameterStatement("SELECT name FROM users WHERE age > ?");
stmt->SetInt(1, 25);
rs := stmt->Select(); # execute prepared select
while(rs->Next()) { rs->GetVarchar("name")->PrintLine(); };
rs->Close();
conn->Close();SetBigInt #
Sets a big integer type to NULL
method : public : SetBigInt(pos:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetBigInt #
Sets a big integer type
method : public : SetBigInt(pos:Int, value:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
| value | Int | big integer value |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetBit #
Sets a bit type to NULL
method : public : SetBit(pos:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetBit #
Sets a bit type
method : public : SetBit(pos:Int, value:Bool) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
| value | Bool | bit value |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetBlob #
Sets a blob type to NULL
method : public : SetBlob(pos:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetBlob #
Sets a blob type
method : public : SetBlob(pos:Int, buffer:Byte[]) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
| buffer | Byte | byte buffer |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetBytes #
Sets a stream of bytes
method : public : SetBytes(pos:Int, buffer:Byte[], length:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
| buffer | Byte | byte buffer |
| length | Int | number of bytes to write |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetDate #
Sets a date type to NULL
method : public : SetDate(pos:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetDate #
Sets a date type
method : public : SetDate(pos:Int, value:Date) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
| value | Date | date value |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetDouble #
Sets a double type to NULL
method : public : SetDouble(pos:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetDouble #
Sets a double type
method : public : SetDouble(pos:Int, value:Float) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
| value | Float | double value |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetInt #
Sets a integer type to NULL
method : public : SetInt(pos:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetInt #
Sets a integer type
method : public : SetInt(pos:Int, value:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
| value | Int | integer value to set |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetReal #
Sets a real type to NULL
method : public : SetReal(pos:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetReal #
Sets a real type
method : public : SetReal(pos:Int, value:Float) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
| value | Float | real value |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetSmallInt #
Sets a small integer type to NULL
method : public : SetSmallInt(pos:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetSmallInt #
Sets a small integer type
method : public : SetSmallInt(pos:Int, value:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
| value | Int | small integer value |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetTimestamp #
Sets a timestamp type to NULL
method : public : SetTimestamp(pos:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetTimestamp #
Sets a timestamp type
method : public : SetTimestamp(pos:Int, value:Timestamp) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
| value | Timestamp | timestamp value |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetVarchar #
Sets varchar type to NULL
method : public : SetVarchar(pos:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
SetVarchar #
Sets varchar type
method : public : SetVarchar(pos:Int, value:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| pos | Int | parameter position |
| value | String | string value |
Return
| Type | Description |
|---|---|
| Bool | true if set, false otherwise |
Example
conn := Database.ODBC.Connection->New("mydsn", "user", "pass");
stmt := conn->CreateParameterStatement("INSERT INTO users(name) VALUES(?)");
stmt->SetVarchar(1, "Bob"); # bind string to first parameter
stmt->Update();
conn->Close();Update #
Executes a SQL update statement. Statement is closed after calling.
method : public : Update() ~ IntReturn
| Type | Description |
|---|---|
| Int | result code |
Example
conn := Database.ODBC.Connection->New("mydsn", "user", "pass");
stmt := conn->CreateParameterStatement("UPDATE users SET age=? WHERE name=?");
stmt->SetInt(1, 31);
stmt->SetVarchar(2, "Alice");
rc := stmt->Update(); # execute and close statement
"rows={$rc}"->PrintLine();
conn->Close();