Exemple #1
0
        public void LookupDesc()
        {
            using (StatementBase lookup = DB.CreateStatement(Transaction))
            {
                lookup.Prepare(GetArrayDesc());
                lookup.Execute();

                _descriptor = new ArrayDesc();
                DbValue[] values = lookup.Fetch();
                if (values != null && values.Length > 0)
                {
                    _descriptor.RelationName = _tableName;
                    _descriptor.FieldName    = _fieldName;
                    _descriptor.DataType     = values[0].GetByte();
                    _descriptor.Scale        = values[1].GetInt16();
                    _descriptor.Length       = values[2].GetInt16();
                    _descriptor.Dimensions   = values[3].GetInt16();
                    _descriptor.Flags        = 0;

                    _rdbFieldName = values[4].GetString().Trim();
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
        }
Exemple #2
0
        public void LookupBounds()
        {
            this.LookupDesc();

            StatementBase lookup = this.DB.CreateStatement(this.Transaction);

            lookup.Prepare(this.GetArrayBounds());
            lookup.Execute();

            int i = 0;

            this.descriptor.Bounds = new ArrayBound[16];
            DbValue[] values;

            while ((values = lookup.Fetch()) != null)
            {
                this.descriptor.Bounds[i].LowerBound = values[0].GetInt32();
                this.descriptor.Bounds[i].UpperBound = values[1].GetInt32();

                i++;
            }

            lookup.Release();
            lookup = null;
        }
Exemple #3
0
        public void LookupDesc()
        {
            // Initializa array descriptor information
            this.descriptor = new ArrayDesc();

            // Create statement for retrieve information
            StatementBase lookup = this.DB.CreateStatement(this.Transaction);

            lookup.Prepare(this.GetArrayDesc());
            lookup.Execute();

            DbValue[] values = lookup.Fetch();
            if (values != null && values.Length > 0)
            {
                this.descriptor.RelationName = tableName;
                this.descriptor.FieldName    = fieldName;
                this.descriptor.DataType     = values[0].GetByte();
                this.descriptor.Scale        = values[1].GetInt16();
                this.descriptor.Length       = values[2].GetInt16();
                this.descriptor.Dimensions   = values[3].GetInt16();
                this.descriptor.Flags        = 0;

                this.rdbFieldName = values[4].GetString().Trim();
            }
            else
            {
                throw new InvalidOperationException();
            }

            lookup.Release();
            lookup = null;
        }
Exemple #4
0
        public void LookupBounds()
        {
            LookupDesc();

            using (StatementBase lookup = DB.CreateStatement(Transaction))
            {
                lookup.Prepare(GetArrayBounds());
                lookup.Execute();

                _descriptor.Bounds = new ArrayBound[16];
                DbValue[] values;
                int       i = 0;
                while ((values = lookup.Fetch()) != null)
                {
                    _descriptor.Bounds[i].LowerBound = values[0].GetInt32();
                    _descriptor.Bounds[i].UpperBound = values[1].GetInt32();

                    i++;
                }
            }
        }
Exemple #5
0
 public DbValue(StatementBase statement, DbField field)
 {
     _statement = statement;
     _field     = field;
     _value     = field.Value;
 }
Exemple #6
0
 public DbValue(StatementBase statement, DbField field, object value)
 {
     this.statement	= statement;
     this.field		= field;
     this.value		= value ?? DBNull.Value;
 }
Exemple #7
0
 public DbValue(StatementBase statement, DbField field)
 {
     this.statement	= statement;
     this.field		= field;
     this.value		= field.Value;
 }
		public DbValue(StatementBase statement, DbField field, object value)
		{
			this.statement	= statement;
			this.field		= field;
			this.value		= (value == null) ? System.DBNull.Value : value;
		}
Exemple #9
0
		public int Prepare(string sql, short paramCount)
		{
			try
			{
				if (this.statement != null)
				{
					this.Release();
				}

				this.transactionId = this.connection.GetTransactionId();
				if (this.transactionId < 0)
				{
					this.connection.BeginTransaction(this.transactionId, (int)(IsolationLevel.ReadCommitted));
				}

				ITransaction transaction = (ITransaction)this.connection.Transactions[this.transactionId];

				this.statement = this.connection.Database.CreateStatement(transaction);
				
				this.statement.Prepare(sql);
				this.statement.Describe();
				this.statement.DescribeParameters();
			}
			catch (IscException e)
			{
				this.lastError = e;
				this.RollbackImplicitTransaction();
			}

			return this.GetErrorCode();
		}
Exemple #10
0
        internal void Release()
        {
            // Rollback implicit transaction
            this.RollbackImplicitTransaction();

            // If there	are	an active reader close it
            this.CloseReader();

            // Remove the command from the Prepared commands list
            if (this.connection != null && this.connection.State == ConnectionState.Open)
            {
                this.connection.InnerConnection.RemovePreparedCommand(this);
            }

            // Dipose the inner statement
            if (this.statement != null)
            {
                this.statement.Dispose();
                this.statement = null;
            }
        }
Exemple #11
0
 public DbValue(StatementBase statement, DbField field)
 {
     this.statement = statement;
     this.field     = field;
     this.value     = field.Value;
 }
Exemple #12
0
 public DbValue(StatementBase statement, DbField field, object value)
 {
     this.statement = statement;
     this.field     = field;
     this.value     = (value == null) ? System.DBNull.Value : value;
 }
        private void Prepare(bool returnsSet)
        {
#if (DEBUG)
            System.Diagnostics.Debug.WriteLine(string.Format("Command:\n{0}", commandText));
            if (this.parameters != null)
                foreach (FbParameter item in this.parameters)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Name:{0} \t Type:{1} \t Value:{2}", item.InternalParameterName, item.FbDbType, item.InternalValue));
                }
#endif

            FbConnectionInternal innerConn = this.connection.InnerConnection;

            // Check if	we have	a valid	transaction
            if (this.transaction == null)
            {
				if (innerConn.IsEnlisted)
                {
					this.transaction = innerConn.ActiveTransaction;
                }
                else
                {
                    this.implicitTransaction = true;
                    this.transaction = new FbTransaction(this.connection, this.connection.ConnectionOptions.IsolationLevel);
                    this.transaction.BeginTransaction();

                    // Update Statement	transaction
                    if (this.statement != null)
                    {
                        this.statement.Transaction = this.transaction.Transaction;
                    }
                }
            }

            // Check if	we have	a valid	statement handle
            if (this.statement == null)
            {
                this.statement = innerConn.Database.CreateStatement(this.transaction.Transaction);
            }

            // Prepare the statement if	needed
            if (!this.statement.IsPrepared)
            {
                // Close the inner DataReader if needed
                this.CloseReader();

                // Reformat the SQL statement if needed
                string sql = this.commandText;

                if (this.commandType == CommandType.StoredProcedure)
                {
                    sql = this.BuildStoredProcedureSql(sql, returnsSet);
                }

                try
                {
                    // Try to prepare the command
                    this.statement.Prepare(this.ParseNamedParameters(sql));
                }
                catch
                {
                    // Release the statement and rethrow the exception
                    this.statement.Release();
                    this.statement = null;

                    throw;
                }

                // Add this	command	to the active command list
                innerConn.AddPreparedCommand(this);
            }
            else
            {
                // Close statement for subsequently	executions
                this.Close();
            }
        }
		internal void Release()
		{
			this.RollbackImplicitTransaction();

			if (this.connection != null && this.connection.State == ConnectionState.Open)
			{
				this.connection.InnerConnection.RemovePreparedCommand(this);
			}

			if (this.statement != null)
			{
				this.statement.Dispose();
				this.statement = null;
			}
		}
		protected override void Dispose(bool disposing)
		{
			lock (this)
			{
				if (!_disposed)
				{
					try
					{
						// Release any unmanaged resources
						Release();

						// release any managed resources
						_commandTimeout = 0;
						_fetchSize = 0;
						_implicitTransaction = false;
						_commandText = null;
						_connection = null;
						_transaction = null;
						_parameters = null;
						_statement = null;
						_activeReader = null;

						if (_namedParameters != null)
						{
							_namedParameters.Clear();
							_namedParameters = null;
						}

						_disposed = true;
					}
					finally
					{
						base.Dispose(disposing);
					}
				}
			}
		}
Exemple #16
0
 public DbValue(StatementBase statement, DbField field, object value)
 {
     _statement = statement;
     _field     = field;
     _value     = value ?? DBNull.Value;
 }
Exemple #17
0
 public DbValue(StatementBase statement, DbField field, object value)
 {
     this.statement = statement;
     this.field     = field;
     this.value     = value ?? DBNull.Value;
 }
		public DbValue(StatementBase statement, DbField field)
		{
			_statement = statement;
			_field = field;
			_value = field.Value;
		}
Exemple #19
0
        private void Prepare(bool returnsSet)
        {
            LogCommand();

            FbConnectionInternal innerConn = this.connection.InnerConnection;

            // Check if	we have	a valid	transaction
            if (this.transaction == null)
            {
                if (innerConn.IsEnlisted)
                {
                    this.transaction = innerConn.ActiveTransaction;
                }
                else
                {
                    this.implicitTransaction = true;
                    this.transaction = new FbTransaction(this.connection, this.connection.ConnectionOptions.IsolationLevel);
                    this.transaction.BeginTransaction();

                    // Update Statement	transaction
                    if (this.statement != null)
                    {
                        this.statement.Transaction = this.transaction.Transaction;
                    }
                }
            }

            // Check if	we have	a valid	statement handle
            if (this.statement == null)
            {
                this.statement = innerConn.Database.CreateStatement(this.transaction.Transaction);
            }

            // Prepare the statement if	needed
            if (!this.statement.IsPrepared)
            {
                // Close the inner DataReader if needed
                this.CloseReader();

                // Reformat the SQL statement if needed
                string sql = this.commandText;

                if (this.commandType == CommandType.StoredProcedure)
                {
                    sql = this.BuildStoredProcedureSql(sql, returnsSet);
                }

                try
                {
                    // Try to prepare the command
                    this.statement.Prepare(this.ParseNamedParameters(sql));
                }
                catch
                {
                    // Release the statement and rethrow the exception
                    this.statement.Release();
                    this.statement = null;

                    throw;
                }

                // Add this	command	to the active command list
                innerConn.AddPreparedCommand(this);
            }
            else
            {
                // Close statement for subsequently	executions
                this.Close();
            }
        }
		public DbValue(StatementBase statement, DbField field, object value)
		{
			_statement = statement;
			_field = field;
			_value = value ?? DBNull.Value;
		}
Exemple #21
0
        protected override void Dispose(bool disposing)
        {
            lock (this)
            {
                if (!this.disposed)
                {
                    try
                    {
                        // Release any unmanaged resources
                        this.Release();

                        // release any managed resources
                        this.commandTimeout = 0;
                        this.fetchSize = 0;
                        this.implicitTransaction = false;
                        this.commandText = null;
                        this.connection = null;
                        this.transaction = null;
                        this.parameters = null;
                        this.statement = null;
                        this.activeReader = null;

                        if (this.namedParameters != null)
                        {
                            this.namedParameters.Clear();
                            this.namedParameters = null;
                        }

                        this.disposed = true;
                    }
                    finally
                    {
                        base.Dispose(disposing);
                    }
                }
            }
        }
Exemple #22
0
		public int Release()
		{
			try
			{
				this.RollbackImplicitTransaction();
				if (this.statement != null)
				{
					this.statement.Release();
				}
			}
			catch (IscException e)
			{
				this.lastError = e;
			}
			finally
			{
				this.statement = null;
			}

			return this.GetErrorCode();
		}