<div class="meta" robots="noindex">

</div>

Class

# OracleSQLPreparedStatement

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2023r2. Please use `ODBCPreparedStatement</api/databases/odbcpreparedstatement>` as a replacement.

</div>

## Description

Used to create a PreparedSQLStatement for an Oracle Database.

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                | Parameters                                                                                | Returns                         | Shared |
|-----------------------------------------------------|-------------------------------------------------------------------------------------------|---------------------------------|--------|
| `Bind<oraclesqlpreparedstatement.bind>`             | index As `Integer</api/data_types/integer>`, value As `Variant</api/data_types/variant>`  |                                 |        |
| `BindType<oraclesqlpreparedstatement.bindtype>`     | index As `Integer</api/data_types/integer>`, type As `Integer</api/data_types/integer>`   |                                 |        |
| `ExecuteSQL<oraclesqlpreparedstatement.executesql>` | `ParamArray</api/language/paramarray>` bindValues() As `Variant</api/data_types/variant>` |                                 |        |
| `SelectSQL<oraclesqlpreparedstatement.selectsql>`   | `ParamArray</api/language/paramarray>` bindValues() As `Variant</api/data_types/variant>` | `RowSet</api/databases/rowset>` |        |

## Method descriptions

<div id="oraclesqlpreparedstatement.bind">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

OracleSQLPreparedStatement.Bind

**Bind**(index As `Integer</api/data_types/integer>`, value As `Variant</api/data_types/variant>`)

Binds a value and its type for the prepared statement.

Use `Database.Prepare<database.prepare>` to set up the bind.

This example creates a SQLite prepared statement to retrieve data from a *Customers* table. It then displays the data in a Listbox:

``` xojo
Var stmt As SQLitePreparedStatement

' note in a prepared statement you DO NOT put in the quotes
stmt = SQLitePreparedStatement(db.Prepare("SELECT * FROM Customers WHERE FirstName like ? "))

' have to tell sqlite what types the items being bound are so it does the right thing
stmt.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
stmt.Bind(0, TextField1.Text)

' perform the search
Var rs As RowSet = stmt.SQLSelect

ListBox1.RemoveAllRows
ListBox1.ColumnCount = rs.ColumnCount
ListBox1.HasHeader = True

Var hasHeadings As Boolean

While rs.AfterLastRow <> True
  ListBox1.AddRow("")

  For i As Integer = 0 To rs.ColumnCount-1
    If Not hasHeadings Then ListBox1.HeaderAt(i) = rs.ColumnAt(i+1).Name
    ListBox1.CellTextAt(ListBox1.LastAddedRowIndex, i) = rs.ColumnAt(i+1).StringValue
  Next

  rs.MoveToNextRow
  hasHeadings = True
Wend
```

<div id="oraclesqlpreparedstatement.bindtype">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

OracleSQLPreparedStatement.BindType

**BindType**(index As `Integer</api/data_types/integer>`, type As `Integer</api/data_types/integer>`)

Specify types for multiple bind values. Each Database plug-in will have its own values.

<div id="oraclesqlpreparedstatement.executesql">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

OracleSQLPreparedStatement.ExecuteSQL

**ExecuteSQL**(`ParamArray</api/language/paramarray>` bindValues() As `Variant</api/data_types/variant>`)

Same as SelectSQL but does not return a result set. Executes and returns the result set of the prepared statement.

BindValues is optional and is intended for convenience only. If bindValues is not empty, ExecuteSQL will use the passed in values instead of the ones specified by calling Bind.

<div id="oraclesqlpreparedstatement.selectsql">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

OracleSQLPreparedStatement.SelectSQL

**SelectSQL**(`ParamArray</api/language/paramarray>` bindValues() As `Variant</api/data_types/variant>`) As `RowSet</api/databases/rowset>`

Executes and returns the result set of the prepared statement.

The bindValues parameter is optional and is intended for convenience only. If bindValues is not empty SelectSQL will use the passed in values instead of the ones specified by calling Bind.

## Interfaces

**OracleSQLPreparedStatement** implements the `PreparedSQLStatement</api/databases/preparedsqlstatement>` interface.

## Notes

<div class="note">

<div class="title">

Note

</div>

The use of the prepared statement classes is rare because `Database.SelectSQL<database.selectsql>` and `Database.ExecuteSQL<database.executesql>` utilize them automatically. See `PreparedSQLStatement</api/databases/preparedsqlstatement>` for information on cases where using prepared statement classes is appropriate.

</div>

Oracle prepared statements use the leading colons as markers in the prepared statement, i.e.:

``` SQL
SELECT * FROM Persons WHERE Name = :name
```

All parameters must have their type specified. These are the constants to use with the BindType method:

| Constant         |
|------------------|
| SQL_TYPE_CLOB    |
| SQL_TYPE_DATE    |
| SQL_TYPE_FLOAT   |
| SQL_TYPE_INTEGER |
| SQL_TYPE_NULL    |
| SQL_TYPE_STRING  |

## Sample code

This code shows how to use database binding.

``` xojo
' "db" is an OracleDatabase object
Var ps As OracleSQLPreparedStatement
ps = OracleSQLPreparedStatement(db.Prepare("SELECT * FROM Persons WHERE Name = :name AND Age >= :age"))

ps.BindType(0, OracleSQLPreparedStatement.SQL_TYPE_STRING)
ps.BindType(1, OracleSQLPreparedStatement.SQL_TYPE_INTEGER)

ps.Bind(0, "John")
ps.Bind(1, 20)

Try
  Var rs As RecordSet = ps.SelectSQL
  ' Use RecordSet as usual
Catch error As DatabaseException
  MessageBox(db.ErrorMessage)
  Return
End Try
```

## Compatibility

All project types on all supported operating systems.

## See also

`Object</api/data_types/additional_types/object>` parent class; `Database</api/databases/database>`, `OracleDatabase</api/deprecated/oracledatabase>`, `PreparedSQLStatement</api/databases/preparedsqlstatement>` classes.
