Skip Headers

Oracle® Objects for OLE Developer's Guide
10g Release 1 (10.1)

Part Number B10118-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

Example: Describing a Table

See OraMetaData Schema Definitions.

Dim OraSession As OraSession

Dim OraDatabase As OraDatabase

Dim OraDynaset As OraDynaset

Dim OraMetaData As OraMetaData

Dim OraMDAttribute As OraMDAttribute

Dim ColumnList As OraMetaData

Dim Column As OraMetaData

'Create the OraSession Object.

Set OraSession = CreateObject("OracleInProcServer.XOraSession")

'Create the OraDatabase Object by opening a connection to Oracle.

Set OraDatabase = OraSession.OpenDatabase("ExampleDB", "scott/tiger", 0&)

'Use Describe to retrieve the metadata object

Set OraMetaData = OraDatabase.Describe("EMP")

'Display the type of the metadata

MsgBox TypeofMetaData & OraMetaData.Type

'Display the count of attributes belonging to the table

MsgBox NumberOfAttributes & OraMetaData.Count

'Attribute can be accessed using the explicit

' OraMetaData property: Attribute

'The index can be an integer or the attribute name

Set OraMDAttribute = OraMetaData.Attribute(0)

MsgBox "ObjectID: " & OraMDAttribute.Value

'Since Attribute is the default property of OraMetaData,

'an attribute can be accessed as follows.

'Here, we use attribute name as an index

Set OraMDAttribute = OraMetaData("ObjectID")

MsgBox "Name: " & OraMDAttribute.Name

MsgBox "Value: " & OraMDAttribute.Value

'Value is the default property of OraMDAttribute, the following shows

'the Value of property "IsClustered" for the table

MsgBox "Is Clustered: " & OraMetaData!IsClustered

MsgBox "Is Partitioned: " & OraMetaData!IsPartitioned

'Retrieve the Column List

Set OraMDAttribute = OraMetaData!ColumnList

' Use IsMDObject property to check whether

' an attribute's value is an OraMetaData

If (OraMDAttribute.IsMDObject()) Then

Set ColumnList = OraMDAttribute.Value

'Display the name and datatype of each column

For I = 0 To ColumnList.Count - 1

Set Column = ColumnList(I).Value

' Each column is again an OraMetaData

MsgBox "Column: " & Column!Name & " DataType: " & Column!Datatype

Next I

End If