See Also

OracleAttribute Members  | Devart.Data.Oracle Namespace  | OracleAttributeCollection Class  | Item(OracleAttribute) Property

Language

Visual Basic

C#

Show All

See AlsoLanguagesDevart.Data.OracleSend comments on this topic.

OracleAttribute Class

Devart.Data.Oracle Namespace : OracleAttribute Class

Represents an attribute of the OracleObject type.

For a list of all members of this type, see OracleAttribute members.

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      Devart.Data.Oracle.OracleAttribute

Syntax

[Visual Basic]
Public Class OracleAttribute    Inherits MarshalByRefObject
[C#]
public class OracleAttribute : MarshalByRefObject

Remarks

Describes an attribute of the object type. The OracleAttribute object provides only metadata of the type attribute, not the attribute value for the particular object. To get the attribute value, the OracleObject.Item(OracleAttribute) property should be used; note that one of its overloads takes an OracleAttribute object as a parameter.

The full collection of type's attributes may be received from the OracleType.Attributes property of the OracleType object.

Example

This example demonstrates how to retrieve OracleType object from server and display its attributes. To create required type and table and fill it with data you can use the following script:

CREATE TYPE TAddress AS OBJECT (
  Country VARCHAR2(30),
  City VARCHAR2(30),
  Street VARCHAR2(30),
  Apartment NUMBER
);

CREATE TABLE EmpObject (
  Code NUMBER PRIMARY KEY,
  Person VARCHAR2(40),
  Address TAddress,
  Job VARCHAR2(9)
);

INSERT INTO EmpObject
  (Code, Person, Address, Job)
VALUES
  (1, 'SMITH', TAddress('UK', 'London', 'Street', 12), 'CLERK');
INSERT INTO EmpObject
  (Code, Person, Address, Job)
VALUES
  (2, 'JONES', TAddress('USA', 'New York', 'Street', 418), 'MANAGER');
INSERT INTO EmpObject
  (Code, Person, Address, Job)
VALUES
  (3, 'SCOTT', TAddress('CANADA', 'Ottawa', 'Street', 26),'PRESIDENT');
INSERT INTO EmpObject
  (Code, Person, Address, Job)
VALUES
  (4, 'MARTIN', TAddress('FRANCE', 'Paris', 'Street', 162), 'ANALYST');

[C#] 

OracleConnection connection = new OracleConnection("User Id=scott;Password=tiger;Data Source=ora"); 
OracleCommand command = new OracleCommand("SELECT * FROM EmpObject", connection); 
connection.Open(); 
OracleDataReader dataReader = command.ExecuteReader(); 
try{ 
  int index = dataReader.GetOrdinal("Address"); 
  while (dataReader.Read()) { 
    OracleObject oraObj = dataReader.GetOracleObject(index); 
    OracleType oraType = dataReader.GetObjectType(index); 
    if (!oraObj.IsNull && oraType != null) { 
      Console.WriteLine(dataReader.GetString(1) +" - " + dataReader.GetString(3)); 
      Console.WriteLine("Adress:"); 
      for (int i = 0; i < oraType.Attributes.Count; i++) 
        Console.WriteLine( "\t" + oraObj[oraType.Attributes[i]]); 
    } 
  } 

catch (Devart.Data.Oracle.OracleException ex) { 
  Console.WriteLine(ex.Message); 

finally{ 
  dataReader.Close(); 
  connection.Close(); 

[Visual Basic] 

Dim connection As New OracleConnection("User Id=scott;Password=tiger;Data Source=ora")
Dim command As New OracleCommand("SELECT * FROM EmpObject", connection)
connection.Open()
Dim dataReader As OracleDataReader = command.ExecuteReader()
Try
  Dim index As Integer = dataReader.GetOrdinal("Address")
  While dataReader.Read()
    Dim oraObj As OracleObject = dataReader.GetOracleObject(index)
    Dim oraType As OracleType = dataReader.GetObjectType(index)
    If Not oraObj.IsNull And Not oraType Is Nothing Then
      Console.WriteLine(dataReader.GetString(1) & " - " & dataReader.GetString(3))
      Console.WriteLine("Adress:")
      Dim I As Integer
      For I = 0 To oraType.Attributes.Count - 1
        Console.WriteLine(Chr(9) & oraObj(oraType.Attributes(I)))
      Next I
    End If
  End While
Catch ex As Devart.Data.Oracle.OracleException
  Console.WriteLine(ex.Message)
Finally
  dataReader.Close()
  connection.Close()
End Try

See Also

OracleAttribute Members  | Devart.Data.Oracle Namespace  | OracleAttributeCollection Class  | Item(OracleAttribute) Property

 

 


© 2002 - 2013 Devart. All Rights Reserved.