コード例 #1
0
 internal OracleColumn(OciStatementHandle statementHandle, int ordinal, OciErrorHandle errorHandle, OracleConnection connection)
 {
     this._ordinal              = ordinal;
     this._describeHandle       = statementHandle.GetDescriptor(this._ordinal, errorHandle);
     this._connection           = connection;
     this._connectionCloseCount = connection.CloseCount;
 }
コード例 #2
0
        internal OciHandle GetDescriptor(
            int i,
            OciHandle errorHandle
            )
        {
            //  Wraps the OCIParamGet call. We do not expect it to fail, so we
            //  will throw if it does.

            IntPtr paramdesc;
            int    rc = TracedNativeMethods.OCIParamGet(
                this,
                errorHandle,
                out paramdesc,
                i + 1
                );

            if (0 != rc)
            {
                OracleException.Check(errorHandle, rc);
            }

            OciHandle result = new OciParameterDescriptor(this, paramdesc);

            GC.KeepAlive(this);
            return(result);
        }
コード例 #3
0
        protected override DbSqlParserColumnCollection GatherTableColumns(DbSqlParserTable table)
        {
            OciStatementHandle          stmtp       = new OciStatementHandle(this._connection.ServiceContextHandle);
            OciErrorHandle              errorHandle = this._connection.ErrorHandle;
            StringBuilder               builder     = new StringBuilder();
            string                      schemaName  = table.SchemaName;
            string                      tableName   = table.TableName;
            DbSqlParserColumnCollection columns     = new DbSqlParserColumnCollection();

            builder.Append("select * from ");
            if (!System.Data.Common.ADP.IsEmpty(schemaName))
            {
                builder.Append(schemaName);
                builder.Append(".");
            }
            builder.Append(tableName);
            string stmt = builder.ToString();

            if ((TracedNativeMethods.OCIStmtPrepare(stmtp, errorHandle, stmt, OCI.SYNTAX.OCI_NTV_SYNTAX, OCI.MODE.OCI_DEFAULT, this._connection) == 0) && (TracedNativeMethods.OCIStmtExecute(this._connection.ServiceContextHandle, stmtp, errorHandle, 0, OCI.MODE.OCI_DESCRIBE_ONLY) == 0))
            {
                int num3;
                stmtp.GetAttribute(OCI.ATTR.OCI_ATTR_PARAM_COUNT, out num3, errorHandle);
                for (int i = 0; i < num3; i++)
                {
                    string str;
                    OciParameterDescriptor handle = stmtp.GetDescriptor(i, errorHandle);
                    handle.GetAttribute(OCI.ATTR.OCI_ATTR_SQLCODE, out str, errorHandle, this._connection);
                    OciHandle.SafeDispose(ref handle);
                    str = this.QuotePrefixCharacter + str + this.QuoteSuffixCharacter;
                    columns.Add(null, schemaName, tableName, str, null);
                }
            }
            OciHandle.SafeDispose(ref stmtp);
            return(columns);
        }
コード例 #4
0
 internal static void SafeDispose(ref OciParameterDescriptor handle)
 {
     if (handle != null)
     {
         handle.Dispose();
     }
     handle = null;
 }
コード例 #5
0
ファイル: OracleDataReader.cs プロジェクト: pmq20/mono_forked
        DataTable GetSchemaTable()
        {
            StringCollection keyinfo = null;

            if (schemaTable.Rows != null && schemaTable.Rows.Count > 0)
            {
                return(schemaTable);
            }

            string owner = String.Empty;
            string table = String.Empty;

            if ((behavior & CommandBehavior.KeyInfo) != 0)
            {
                keyinfo = GetKeyInfo(out owner, out table);
            }

            dataTypeNames = new ArrayList();

            for (int i = 0; i < statement.ColumnCount; i += 1)
            {
                DataRow row = schemaTable.NewRow();

                OciParameterDescriptor parameter = statement.GetParameter(i);

                dataTypeNames.Add(parameter.GetDataTypeName());

                row ["ColumnName"]       = parameter.GetName();
                row ["ColumnOrdinal"]    = i + 1;
                row ["ColumnSize"]       = parameter.GetDataSize();
                row ["NumericPrecision"] = parameter.GetPrecision();
                row ["NumericScale"]     = parameter.GetScale();

                string sDataTypeName = parameter.GetDataTypeName();
                row ["DataType"] = parameter.GetFieldType(sDataTypeName);

                OciDataType ociType = parameter.GetDataType();
                OracleType  oraType = OciParameterDescriptor.OciDataTypeToOracleType(ociType);
                row ["ProviderType"] = (int)oraType;

                if (ociType == OciDataType.Blob || ociType == OciDataType.Clob)
                {
                    row ["IsLong"] = true;
                }
                else
                {
                    row ["IsLong"] = false;
                }

                row ["AllowDBNull"] = parameter.GetIsNull();

                row ["IsAliased"]    = DBNull.Value;                            // TODO:
                row ["IsExpression"] = DBNull.Value;                            // TODO:

                if ((behavior & CommandBehavior.KeyInfo) != 0)
                {
                    if (keyinfo.IndexOf((string)row ["ColumnName"]) >= 0)
                    {
                        row ["IsKey"] = true;
                    }
                    else
                    {
                        row ["IsKey"] = false;
                    }

                    row ["IsUnique"]       = DBNull.Value;                      // TODO: only set this if CommandBehavior.KeyInfo, otherwise, null
                    row ["BaseSchemaName"] = owner;
                    row ["BaseTableName"]  = table;
                    row ["BaseColumnName"] = row ["ColumnName"];
                }
                else
                {
                    row ["IsKey"]          = DBNull.Value;
                    row ["IsUnique"]       = DBNull.Value;
                    row ["BaseSchemaName"] = DBNull.Value;
                    row ["BaseTableName"]  = DBNull.Value;
                    row ["BaseColumnName"] = DBNull.Value;
                }

                schemaTable.Rows.Add(row);
            }

            return(schemaTable);
        }