Difference between revisions of "OracleSQLPreparedStatement"

From Xojo Documentation

(See Also)
Line 1: Line 1:
 
{{ClassBox
 
{{ClassBox
| super=[[PreparedSQLStatement]]
+
| super=[[Object]]
 
| platform=all
 
| platform=all
 
| newinversion = 2010r4
 
| newinversion = 2010r4
Line 8: Line 8:
 
|text = Used to create a PreparedSQLStatement for an Oracle Database. }}
 
|text = Used to create a PreparedSQLStatement for an Oracle Database. }}
  
<dynamicTable id="Methods" super="PreparedSQLStatement" class="methodTable" title="Methods" columns="3" >
+
<dynamicTable id="Methods" interface="PreparedSQLStatement" class="methodTable" title="Methods" columns="3" >
 
</dynamicTable>
 
</dynamicTable>
  
 
==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.}}
 +
 +
'''OracleSQLPreparedStatement''' implements the [[PreparedSQLStatement]] interface.
  
 
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.:

Revision as of 22:39, 11 January 2022

Class (inherits from Object)


New in 2010r4

Used to create a PreparedSQLStatement for an Oracle Database.

Methods
Bind ExecuteSQL
BindType SelectSQL

Notes

fa-info-circle-32.png
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.

OracleSQLPreparedStatement implements the PreparedSQLStatement interface.

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

See Also

Database, OracleDatabase, PreparedSQLStatement classes.