Difference between revisions of "OracleSQLPreparedStatement"
From Xojo Documentation
Line 10: | Line 10: | ||
<dynamicTable id="Methods" interface="PreparedSQLStatement" class="methodTable" title="Methods" columns="3" > | <dynamicTable id="Methods" interface="PreparedSQLStatement" class="methodTable" title="Methods" columns="3" > | ||
</dynamicTable> | </dynamicTable> | ||
+ | |||
+ | ==Interfaces== | ||
+ | '''OracleSQLPreparedStatement''' implements the [[PreparedSQLStatement]] interface. | ||
==Notes== | ==Notes== | ||
{{Information | The use of the prepared statement classes is rare because [[Database.SelectSQL]] and [[Database.ExecuteSQL]] utilize them automatically. See [[PreparedSQLStatement]] for information on cases where using prepared statement classes is appropriate.}} | {{Information | The use of the prepared statement classes is rare because [[Database.SelectSQL]] and [[Database.ExecuteSQL]] utilize them automatically. See [[PreparedSQLStatement]] for information on cases where using prepared statement classes is appropriate.}} | ||
− | |||
− | |||
Oracle prepared statements use the leading colons as markers in the prepared statement, i.e.: | Oracle prepared statements use the leading colons as markers in the prepared statement, i.e.: |
Latest revision as of 23:17, 13 January 2022
Class (inherits from Object)
New in 2010r4
Used to create a PreparedSQLStatement for an Oracle Database.
Methods | ||||
|
Interfaces
OracleSQLPreparedStatement implements the PreparedSQLStatement interface.
Notes
The use of the prepared statement classes is rare because Database.SelectSQL and Database.ExecuteSQL utilize them automatically. See PreparedSQLStatement for information on cases where using prepared statement classes is appropriate. |
Oracle prepared statements use the leading colons as markers in the prepared statement, i.e.:
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.
// "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
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
See Also
Database, OracleDatabase, PreparedSQLStatement classes.