private static OracleTypeCollection MapCollectionTypeAttributes(IDataRecord reader, IDictionary <OracleObjectIdentifier, OracleSchemaObject> allObjects) { var typeFullyQualifiedName = OracleObjectIdentifier.Create(QualifyStringObject(reader["OWNER"]), QualifyStringObject(reader["TYPE_NAME"])); if (!allObjects.TryGetValue(typeFullyQualifiedName, out OracleSchemaObject typeObject)) { return(null); } var collectionType = (OracleTypeCollection)typeObject; var elementTypeIdentifier = OracleObjectIdentifier.Create(QualifyStringObject(reader["ELEM_TYPE_OWNER"]), QualifyStringObject(reader["ELEM_TYPE_NAME"])); var dataType = new OracleDataType { FullyQualifiedName = elementTypeIdentifier, Length = OracleReaderValueConvert.ToInt32(reader["LENGTH"]), Precision = OracleReaderValueConvert.ToInt32(reader["PRECISION"]), Scale = OracleReaderValueConvert.ToInt32(reader["SCALE"]) }; ResolveDataUnit(dataType, reader["CHARACTER_SET_NAME"]); collectionType.ElementDataType = dataType; collectionType.CollectionType = (string)reader["COLL_TYPE"] == OracleTypeCollection.OracleCollectionTypeNestedTable ? OracleCollectionType.Table : OracleCollectionType.VarryingArray; collectionType.UpperBound = OracleReaderValueConvert.ToInt32(reader["UPPER_BOUND"]); return(collectionType); }
private static KeyValuePair <OracleObjectIdentifier, OracleColumn> MapTableColumn(IDataRecord reader, Version version) { var dataTypeIdentifier = OracleObjectIdentifier.Create(QualifyStringObject(reader["DATA_TYPE_OWNER"]), QualifyStringObject(reader["DATA_TYPE"])); var dataType = new OracleDataType { FullyQualifiedName = dataTypeIdentifier, Length = Convert.ToInt32(reader["DATA_LENGTH"]), Precision = OracleReaderValueConvert.ToInt32(reader["DATA_PRECISION"]), Scale = OracleReaderValueConvert.ToInt32(reader["DATA_SCALE"]) }; ResolveDataUnit(dataType, reader["CHAR_USED"]); var column = new OracleColumn { Name = QualifyStringObject(reader["COLUMN_NAME"]), DataType = dataType, Nullable = String.Equals((string)reader["NULLABLE"], "Y"), Virtual = String.Equals((string)reader["VIRTUAL_COLUMN"], "YES"), DefaultValue = OracleReaderValueConvert.ToString(reader["DATA_DEFAULT"]), CharacterSize = Convert.ToInt32(reader["CHAR_LENGTH"]), UserGenerated = true }; if (version.Major >= 12) { column.Hidden = String.Equals((string)reader["HIDDEN_COLUMN"], "YES"); column.UserGenerated = String.Equals((string)reader["USER_GENERATED"], "YES"); } return(new KeyValuePair <OracleObjectIdentifier, OracleColumn>( OracleObjectIdentifier.Create(QualifyStringObject(reader["OWNER"]), QualifyStringObject(reader["TABLE_NAME"])), column)); }
private static OracleTypeObject MapTypeAttributes(IDataRecord reader, IDictionary <OracleObjectIdentifier, OracleSchemaObject> allObjects) { var typeFullyQualifiedName = OracleObjectIdentifier.Create(QualifyStringObject(reader["OWNER"]), QualifyStringObject(reader["TYPE_NAME"])); if (!allObjects.TryGetValue(typeFullyQualifiedName, out OracleSchemaObject typeObject)) { return(null); } var type = (OracleTypeObject)typeObject; var attributeTypeIdentifier = OracleObjectIdentifier.Create(QualifyStringObject(reader["ATTR_TYPE_OWNER"]), QualifyStringObject(reader["ATTR_TYPE_NAME"])); var dataType = new OracleDataType { FullyQualifiedName = attributeTypeIdentifier, Length = OracleReaderValueConvert.ToInt32(reader["LENGTH"]), Precision = OracleReaderValueConvert.ToInt32(reader["PRECISION"]), Scale = OracleReaderValueConvert.ToInt32(reader["SCALE"]) }; ResolveDataUnit(dataType, reader["CHAR_USED"]); var attribute = new OracleTypeAttribute { Name = QualifyStringObject(reader["ATTR_NAME"]), DataType = dataType, IsInherited = String.Equals((string)reader["INHERITED"], "YES") }; type.Attributes.Add(attribute); return(type); }
private static OracleProgramMetadata MapProgramMetadata(IDataRecord reader, bool isBuiltIn, IDictionary <int, OracleProgramMetadata> metadataDictionary) { var functionId = OracleReaderValueConvert.ToInt32(reader["FUNCTION_ID"]); var identifier = CreateFunctionIdentifierFromReaderValues(reader["OWNER"], reader["PACKAGE_NAME"], reader["PROGRAM_NAME"], reader["OVERLOAD"]); var type = Convert.ToBoolean(reader["IS_FUNCTION"]) ? ProgramType.Function : ProgramType.Procedure; var isAnalytic = String.Equals((string)reader["ANALYTIC"], "YES"); var isAggregate = String.Equals((string)reader["AGGREGATE"], "YES"); var isPipelined = String.Equals((string)reader["PIPELINED"], "YES"); var isOffloadable = String.Equals((string)reader["OFFLOADABLE"], "YES"); var parallelSupport = String.Equals((string)reader["PARALLEL"], "YES"); var isDeterministic = String.Equals((string)reader["DETERMINISTIC"], "YES"); var metadataMinimumArguments = OracleReaderValueConvert.ToInt32(reader["MINARGS"]); var metadataMaximumArguments = OracleReaderValueConvert.ToInt32(reader["MAXARGS"]); var authId = String.Equals((string)reader["AUTHID"], "CURRENT_USER") ? AuthId.CurrentUser : AuthId.Definer; var displayType = (string)reader["DISP_TYPE"]; var metadata = new OracleProgramMetadata(type, identifier, isAnalytic, isAggregate, isPipelined, isOffloadable, parallelSupport, isDeterministic, metadataMinimumArguments, metadataMaximumArguments, authId, displayType, isBuiltIn); if (functionId.HasValue) { metadataDictionary.Add(functionId.Value, metadata); } return(metadata); }
private async Task <string> GetOracleExceptionMessage(int errorCode, CancellationToken cancellationToken) { _debuggerSessionCommand.CommandText = "BEGIN :message := SQLERRM(:errorCode); END;"; _debuggerSessionCommand.Parameters.Clear(); _debuggerSessionCommand.AddSimpleParameter("ERRORCODE", -errorCode); var messageParameter = _debuggerSessionCommand.AddSimpleParameter("MESSAGE", null, TerminalValues.Varchar2, 32767); await _debuggerSessionCommand.ExecuteNonQueryAsynchronous(cancellationToken); return(OracleReaderValueConvert.ToString(((OracleString)messageParameter.Value).Value)); }
private static OracleDatabaseLink MapDatabaseLink(IDataRecord reader) { var databaseLinkFullyQualifiedName = OracleObjectIdentifier.Create(QualifyStringObject(reader["OWNER"]), QualifyStringObject(reader["DB_LINK"])); return (new OracleDatabaseLink { FullyQualifiedName = databaseLinkFullyQualifiedName, Created = (DateTime)reader["CREATED"], Host = (string)reader["HOST"], UserName = OracleReaderValueConvert.ToString(reader["USERNAME"]) }); }
private static OracleDirectory MapDirectory(IDataRecord reader, IDictionary <OracleObjectIdentifier, OracleSchemaObject> allObjects) { var directoryFullyQualifiedName = OracleObjectIdentifier.Create(QualifyStringObject(reader["OWNER"]), QualifyStringObject(reader["DIRECTORY_NAME"])); if (!allObjects.TryGetValue(directoryFullyQualifiedName, out var schemaObject)) { return(null); } var directory = (OracleDirectory)schemaObject; directory.Path = OracleReaderValueConvert.ToString(reader["DIRECTORY_PATH"]); return(directory); }
private static KeyValuePair <OracleConstraint, OracleObjectIdentifier> MapConstraintWithReferenceIdentifier(IDataRecord reader, IDictionary <OracleObjectIdentifier, OracleSchemaObject> allObjects) { var remoteConstraintIdentifier = OracleObjectIdentifier.Empty; var owner = QualifyStringObject(reader["OWNER"]); var ownerObjectFullyQualifiedName = OracleObjectIdentifier.Create(owner, QualifyStringObject(reader["TABLE_NAME"])); if (!allObjects.TryGetValue(ownerObjectFullyQualifiedName, out OracleSchemaObject ownerObject)) { return(new KeyValuePair <OracleConstraint, OracleObjectIdentifier>(null, remoteConstraintIdentifier)); } var rely = OracleReaderValueConvert.ToString(reader["RELY"]); var constraint = OracleObjectFactory.CreateConstraint((string)reader["CONSTRAINT_TYPE"], owner, QualifyStringObject(reader["CONSTRAINT_NAME"]), (string)reader["STATUS"] == "ENABLED", (string)reader["VALIDATED"] == "VALIDATED", (string)reader["DEFERRABLE"] == "DEFERRABLE", rely == "RELY"); var dataObject = (OracleDataObject)ownerObject; constraint.OwnerObject = dataObject; dataObject.Constraints.Add(constraint); if (constraint is OracleReferenceConstraint referenceConstraint) { var cascadeAction = DeleteRule.None; switch ((string)reader["DELETE_RULE"]) { case "CASCADE": cascadeAction = DeleteRule.Cascade; break; case "SET NULL": cascadeAction = DeleteRule.SetNull; break; case "NO ACTION": break; } referenceConstraint.DeleteRule = cascadeAction; remoteConstraintIdentifier = OracleObjectIdentifier.Create(QualifyStringObject(reader["R_OWNER"]), QualifyStringObject(reader["R_CONSTRAINT_NAME"])); } return(new KeyValuePair <OracleConstraint, OracleObjectIdentifier>(constraint, remoteConstraintIdentifier)); }
private static OracleSchemaObject MapMaterializedView(IDataRecord reader) { var refreshModeRaw = (string)reader["REFRESH_MODE"]; var materializedView = new OracleMaterializedView { FullyQualifiedName = OracleObjectIdentifier.Create(QualifyStringObject(reader["OWNER"]), QualifyStringObject(reader["NAME"])), TableName = QualifyStringObject(reader["TABLE_NAME"]), IsPrebuilt = String.Equals((string)reader["OWNER"], "YES"), IsUpdatable = String.Equals((string)reader["OWNER"], "YES"), LastRefresh = OracleReaderValueConvert.ToDateTime(reader["LAST_REFRESH"]), Next = OracleReaderValueConvert.ToString(reader["NEXT"]), Query = (string)reader["QUERY"], RefreshGroup = QualifyStringObject(reader["REFRESH_GROUP"]), RefreshMethod = (string)reader["REFRESH_METHOD"], RefreshMode = String.Equals(refreshModeRaw, "DEMAND") ? MaterializedViewRefreshMode.OnDemand : MaterializedViewRefreshMode.OnCommit, RefreshType = MapMaterializedViewRefreshType((string)reader["TYPE"]), StartWith = OracleReaderValueConvert.ToDateTime(reader["START_WITH"]) }; return(materializedView); }
private static KeyValuePair <OracleProgramIdentifier, OracleProgramParameterMetadata> MapProgramParameterMetadata(IDataRecord reader) { var identifier = CreateFunctionIdentifierFromReaderValues(reader["OWNER"], reader["PACKAGE_NAME"], reader["PROGRAM_NAME"], reader["OVERLOAD"]); var parameterName = OracleReaderValueConvert.ToString(reader["ARGUMENT_NAME"]); var position = Convert.ToInt32(reader["POSITION"]); var sequence = Convert.ToInt32(reader["SEQUENCE"]); var dataLevel = Convert.ToInt32(reader["DATA_LEVEL"]); var dataType = OracleReaderValueConvert.ToString(reader["DATA_TYPE"]); var typeOwner = OracleReaderValueConvert.ToString(reader["TYPE_OWNER"]); var typeName = OracleReaderValueConvert.ToString(reader["TYPE_NAME"]); var isOptional = String.Equals((string)reader["DEFAULTED"], "Y"); var directionRaw = (string)reader["IN_OUT"]; ParameterDirection direction; switch (directionRaw) { case "IN": direction = ParameterDirection.Input; break; case "OUT": direction = String.IsNullOrEmpty(parameterName) ? ParameterDirection.ReturnValue : ParameterDirection.Output; break; case "IN/OUT": direction = ParameterDirection.InputOutput; break; default: throw new NotSupportedException($"Parameter direction '{directionRaw}' is not supported. "); } return(new KeyValuePair <OracleProgramIdentifier, OracleProgramParameterMetadata>( identifier, new OracleProgramParameterMetadata(QualifyStringObject(parameterName), position, sequence, dataLevel, direction, dataType, OracleObjectIdentifier.Create(typeOwner, typeName), isOptional))); }
private static KeyValuePair <string, string> MapParameter(IDataRecord reader) { return(new KeyValuePair <string, string>((string)reader["NAME"], OracleReaderValueConvert.ToString(reader["VALUE"]))); }