How does one use bind variables in OO4O?
Submitted by admin on Wed, 2005-11-09 23:38.
Use the "OraParameters.Add Name, Value, IOType" method to substitute bind variables with values before executing a statement. If you don't, you will get
error "not all variables bound". The IOType filed can be one of the following:
- ORAPARM_INPUT - Use as input variable only
- ORAPARM_OUTPUT - Use as output variable only
- ORAPARM_BOTH - Use the variable for input and output
Look at this example:
sqlStmt = "SELECT tname FROM tab WHERE tname LIKE :var1"
OraDatabase.Parameters.add "var1", "%A%", 1 ' Substitute Name=Value of type ORAPARM_INPUT
Set osRecordSet = OraDatabase.DbCreateDynaset(sqlStmt, cint(0))
Do While(osRecordset.EOF = FALSE)
' Use data: osRecordset.Fields("TNAME") in this example...
osRecordSet.MoveNext
Loop»
- Login to post comments

