Oracle® Objects for OLE Developer's Guide 10g Release 1 (10.1) Part Number B10118-01 |
|
OraBlob, OraClob and OraBFile objects can be retrieved using OO4O in the following ways:
Using an OraDynaset object
If a table contains a LOB column and a dynaset's query selects against that LOB column , then the Value property of OraField object will return a OraBlob, OraClob, or a OraBFile object.
The following example selects LOB columns from the part table. PartDesc and PartImage are OraBlob and OraClob objects that are retrieved from the OraField object .
Set OO4OSession = CreateObject("OracleInProcServer.XOraSession")
Set InvDb = OO4OSession.OpenDatabase("INVDB", "scott/tiger", 0)
Set Part = InvDb.CreateDynaset("select * from part", 0&)
Set PartDesc = Part.Fields("part_desc").Value
Set PartImage = Part.Fields("part_image").Value
Using a Parameter object
If a SQL statement or PL/SQL block has a bind variable of type LOB , you create a OraParameter object using the OraParameters Add method. The Value property of the OraParameter object for that bind variable returns an OraBlob, OraClob, or OraBFile object.
The following example illustrates how to use a LOB datatype as a bind variable in a PLSQL anonymous block. This block selects a LOB column from the database.
Set OO4OSession = CreateObject("OracleInProcServer.XOraSession")
Set InvDb = OO4OSession.OpenDatabase("INVDB", "scott/tiger", 0)
InvDb.Parameters.Add "PartDesc", Null, ORAPARM_OUTPUT,ORATYPE_CLOB
InvDb.Parameters.Add "PartImage", Null, ORAPARM_OUTPUT,ORATYPE_BLOB
InvDb.ExecuteSQL ("BEGIN select part_desc, part_image into
:PARTDESC, :PARTIMAGE from part where part_id = 1
for update NOWAIT; END;")
Set PartDesc = InvDb.Parameters("PartDesc").Value
Set PartImage = InvDb.Parameters("PartImage").Value