Reputation: 5761
I'm using GetSchema to load a list of procedures from my Oracle environment, however I only see root procedures, no package procedures. Looking through the documentation though, I don't see how else they could be returned. Does anyone know if there is a filter/restriction to get package procs, or should I be calling a different object type?
Dim ObjectType= "Procedures"
Dim Options As String()
Dim ObjectsTable = OracleConnection.GetSchema(ObjectType, Options)
Sample 'Packages' Results
?RefinedPackageSchemaData(10)
Count = 12
(0): {[OWNER, #REDACTED SCHEMA NAME#]}
(1): {[OBJECT_NAME, #REDACTED PACKAGE NAME#]}
(2): {[SUBOBJECT_NAME, ]}
(3): {[OBJECT_ID, 130652]}
(4): {[DATA_OBJECT_ID, ]}
(5): {[LAST_DDL_TIME, 4/27/2015 3:52:26 PM]}
(6): {[TIMESTAMP, 2015-04-27:15:52:26]}
(7): {[STATUS, VALID]}
(8): {[TEMPORARY, N]}
(9): {[GENERATED, N]}
(10): {[SECONDARY, N]}
(11): {[CREATED, 1/9/2015 9:47:50 AM]}
The number of rows corresponds to exactly the number of packages, not package+procedure combinations
Sample 'PackageBodies' Result
?RefinedPackageBodySchemaData(10)
Count = 12
(0): {[OWNER, #REDACTED SCHEMA NAME#]}
(1): {[OBJECT_NAME, #REDACTED PACKAGE NAME#]}
(2): {[SUBOBJECT_NAME, ]}
(3): {[OBJECT_ID, 130653]}
(4): {[DATA_OBJECT_ID, ]}
(5): {[LAST_DDL_TIME, 4/27/2015 4:19:44 PM]}
(6): {[TIMESTAMP, 2015-04-27:16:19:44]}
(7): {[STATUS, VALID]}
(8): {[TEMPORARY, N]}
(9): {[GENERATED, N]}
(10): {[SECONDARY, N]}
(11): {[CREATED, 1/9/2015 9:48:02 AM]}
The number of rows corresponds to exactly the number of packages, not package+procedure combinations
MSDN Oracle GetSchema Reference
Upvotes: 1
Views: 160
Reputation: 5761
It looks like the only way to do this is to query the Arguments or ProcedureParameters schema, and group the results, discarding the actual Argument/Parameter information.
I did it like this:
Dim ArgumentsSchemaData =
GetSchemaDictionary(Connection, "Arguments", New String() {"#REDACTED SCHEMA NAME#"})
Dim GroupedArguments = (
From ASD In ArgumentsSchemaData
Let FullObjectName =
String.Format("{0}.{1}", ASD("PACKAGE_NAME"), ASD("OBJECT_NAME"))
Group ASD By FullObjectName Into ON_Group = Group
Order By FullObjectName
Select FullObjectName
).ToList
With a separate helper function to pivot from DataTable to a List of dictionaries:
Private Shared Function GetSchemaDictionary(
ByRef Connection As IDbConnection,
ByVal ObjectType As String,
ByRef Options As String()
) As List(Of Dictionary(Of String, Object))
Dim SchemaObjectsList = GetSchemaObjectsList(Connection, ObjectType, Options)
Dim Columns = (
From C In SchemaObjectsList.Columns
Let ColumnName = C.ToString
Select ColumnName
).ToList
Return (
From OL In SchemaObjectsList
Select Columns.ToDictionary(
Function(C) C,
Function(C) OL.Item(C)
)).ToList
End Function
Upvotes: 1