Esempio n. 1
0
        /**
         * Method declaration
         *
         *
         * @param row
         * @param c
         * @param log
         *
         * @throws Exception
         */
        public void insertNoCheck(object[] row, Channel c,
			bool log)
        {
            int i;

            if (iIdentityColumn != -1)
            {
                if (row[iIdentityColumn] == null)
                {
                    if (c != null)
                    {
                        c.setLastIdentity(iIdentityId);
                    }

                    row[iIdentityColumn] = iIdentityId++;
                }
                else
                {
                    i = (int) row[iIdentityColumn];

                    if (iIdentityId <= i)
                    {
                        if (c != null)
                        {
                            c.setLastIdentity(i);
                        }

                        iIdentityId = i + 1;
                    }
                }
            }

            for (i = 0; i < iColumnCount; i++)
            {
                if (row[i] == null &&!getColumn(i).isNullable())
                {
                    throw Trace.error(Trace.TRY_TO_INSERT_NULL);
                }
            }

            try
            {
                Row r = new Row(this, row);

                for (i = 0; i < iIndexCount; i++)
                {
                    Node n = r.getNode(i);

                    getIndex(i).insert(n);
                }
            }
            catch (Exception e)
            {    // rollback insert
                for (--i; i >= 0; i--)
                {
                    getIndex(i).delete(row, i == 0);
                }

                throw e;		      // and throw error again
            }

            if (c != null)
            {
                c.addTransactionInsert(this, row);
            }

            if (lLog != null)
            {
                lLog.write(c, getInsertStatement(row));
            }
        }
Esempio n. 2
0
        /**
         * Method declaration
         *
         *
         * @param row
         * @param c
         * @param log
         *
         * @throws Exception
         */
        public void insertNoCheck(object[] row, Channel c,
                                  bool log)
        {
            int i;

            if (iIdentityColumn != -1)
            {
                if (row[iIdentityColumn] == null)
                {
                    if (c != null)
                    {
                        c.setLastIdentity(iIdentityId);
                    }

                    row[iIdentityColumn] = iIdentityId++;
                }
                else
                {
                    i = (int)row[iIdentityColumn];

                    if (iIdentityId <= i)
                    {
                        if (c != null)
                        {
                            c.setLastIdentity(i);
                        }

                        iIdentityId = i + 1;
                    }
                }
            }

            for (i = 0; i < iColumnCount; i++)
            {
                if (row[i] == null && !getColumn(i).isNullable())
                {
                    throw Trace.error(Trace.TRY_TO_INSERT_NULL);
                }
            }

            try
            {
                Row r = new Row(this, row);

                for (i = 0; i < iIndexCount; i++)
                {
                    Node n = r.getNode(i);

                    getIndex(i).insert(n);
                }
            }
            catch (Exception e)
            {                // rollback insert
                for (--i; i >= 0; i--)
                {
                    getIndex(i).delete(row, i == 0);
                }

                throw e;                                      // and throw error again
            }

            if (c != null)
            {
                c.addTransactionInsert(this, row);
            }

            if (lLog != null)
            {
                lLog.write(c, getInsertStatement(row));
            }
        }