Represents a reference to the object (REF).
This example demonstrates how to retrieve OracleRef object from server and display its elements. To create required type and table and fill it with data you can use the following script:
CREATE OR REPLACE TYPE TCar AS OBJECT (
Model VARCHAR2(20),
Color VARCHAR2(20),
Year NUMBER
);
CREATE TABLE CarTable of TCar;
INSERT INTO CarTable
(Model, Color, Year)
VALUES
('Mersedes Bens','Black',1999);
INSERT INTO CarTable
(Model, Color, Year)
VALUES
('Ford Taurus','Blue',1998);
INSERT INTO CarTable
(Model, Color, Year)
VALUES
('Renault Cleo','Red',2003);
INSERT INTO CarTable
(Model, Color, Year)
VALUES
('BMW 500','Black',2004);
OracleConnection connection = new OracleConnection("User Id=scott;Password=tiger;Data Source=ora");
OracleCommand command = new OracleCommand("SELECT REF(car) FROM CarTable car", connection);
connection.Open();
OracleDataReader dataReader = command.ExecuteReader();
try{
while (dataReader.Read()) {
OracleRef oraRef = dataReader.GetOracleRef(0);
if (!oraRef.IsNull) {
OracleObject oraObj = (OracleObject)oraRef.GetObject();
Console.WriteLine(oraObj["Model"]);
Console.WriteLine("\tColor: " + oraObj["Color"]);
Console.WriteLine("\tYear: " + oraObj["Year"].ToString());
}
}
}
catch (Devart.Data.Oracle.OracleException ex) {
Console.WriteLine(ex.Message);
}
finally{
dataReader.Close();
connection.Close();
}
Dim connection As New OracleConnection("User Id=scott;Password=tiger;Data Source=ora")
Dim command As New OracleCommand("SELECT REF(car) FROM CarTable car", connection)
connection.Open()
Dim dataReader As OracleDataReader = command.ExecuteReader()
Try
While dataReader.Read()
Dim oraRef As OracleRef = dataReader.GetOracleRef(0)
If Not oraRef.IsNull Then
Dim oraObj As OracleObject = oraRef.GetObject()
Console.WriteLine(oraObj("Model"))
Console.WriteLine(Chr(9) & "Color: " & oraObj("Model"))
Console.WriteLine(Chr(9) & "Year: " & oraObj("Year"))
End If
End While
Catch ex As Devart.Data.Oracle.OracleException
Console.WriteLine(ex.Message)
Finally
dataReader.Close()
connection.Close()
End Try
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2