Ejemplo n.º 1
0
        /// <summary>
        /// Store Spotfire SQL and associated fields returning the sequence number of the row
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>

        public static int InsertSpotfireSql(
            string name,
            int version,
            string sqlStmt,
            string keyColName,
            string keys,
            string owner)
        {
            int v0 = version;

            if (version < 0)
            {
                version = SequenceDao.NextVal("dev_mbs_owner.mbs_spotfire_sql_seq");
                if (v0 == -2)                 // append version to name
                {
                    name += version;
                }
            }

            else
            {
                DeleteSqlStatement(name, version);              // delete if matching version
            }
            string sql = @"
				insert into dev_mbs_owner.mbs_spotfire_sql
				(name, version, sql, key_col_name, keys, ownr_id)
				values (:0,:1,:2,:3,:4,:5)"                ;

            DbCommandMx drDao = new DbCommandMx();

            OracleDbType[] pa = new OracleDbType[6];

            pa[0] = OracleDbType.Varchar2;
            pa[1] = OracleDbType.Int32;
            pa[2] = OracleDbType.Clob;
            pa[3] = OracleDbType.Varchar2;
            pa[4] = OracleDbType.Varchar2;
            pa[5] = OracleDbType.Varchar2;

            drDao.Prepare(sql, pa);

            object[] p = new object[6];

            p[0] = name;
            p[1] = version;
            p[2] = sqlStmt;
            p[3] = keyColName;
            p[4] = keys;
            p[5] = owner;

            int count = drDao.ExecuteNonReader(p);             // insert the row

            drDao.Dispose();

            return(version);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Insert row into log table
        /// </summary>
        /// <param name="uo"></param>
        /// <returns></returns>

        public static bool Insert(
            UserObject uo)
        {
            if (DbConnectionMx.NoDatabaseAccessIsAvailable)
            {
                return(true);                // don't try to write
            }
            try
            {
                int    t1  = TimeOfDay.Milliseconds();
                string sql = @"
					insert into mbs_owner.mbs_log (
						obj_id, 
						obj_typ_id, 
						ownr_id, 
						obj_nm, 
						obj_desc_txt, 
						fldr_typ_id, 
						fldr_nm, 
						acs_lvl_id, 
						obj_itm_cnt, 
						obj_cntnt, 
						chng_op_cd, 
						chng_usr_id, 
						crt_dt, 
						upd_dt) 
					values (:0, :1, :2, :3, :4, :5, :6, :7, :8, :9, 'I', :2, sysdate(), sysdate())"                    ;

                // Note that chng_usr_id is truncated to 12 chars to avoid exceptions for longer user ids. Fix after column is expanded

                DbCommandMx drDao = new DbCommandMx();

                OracleDbType[] pa = new OracleDbType[10];

                pa[0] = OracleDbType.Int32;
                pa[1] = OracleDbType.Int32;
                pa[2] = OracleDbType.Varchar2;
                pa[3] = OracleDbType.Varchar2;
                pa[4] = OracleDbType.Varchar2;
                pa[5] = OracleDbType.Int32;
                pa[6] = OracleDbType.Varchar2;
                pa[7] = OracleDbType.Int32;
                pa[8] = OracleDbType.Int32;
                pa[9] = OracleDbType.Clob;

                drDao.Prepare(sql, pa);

                object[] p = new object[10];
                uo.Id = SequenceDao.NextVal("mbs_owner.mbs_log_seq");
                p[0]  = uo.Id;
                p[1]  = (int)uo.Type;
                p[2]  = (Lex.IsDefined(uo.Owner) ? uo.Owner.ToUpper() : "UNKNOWN");
                p[3]  = uo.Name;
                p[4]  = (Lex.IsUndefined(uo.Description) ? uo.Description : " ");
                p[5]  = uo.ParentFolderType;
                p[6]  = uo.ParentFolder;
                p[7]  = uo.AccessLevel;
                p[8]  = uo.Count;
                p[9]  = uo.Content;
                //					if (uo.Content!="")	p[9] = uo.Content;
                //					else p[9]=null;

                int count = drDao.ExecuteNonReader(p);                 // insert the row
                drDao.Dispose();

                int t2   = TimeOfDay.Milliseconds();
                int time = t2 - t1;                 // 80ms 5/24/05

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }