Example #1
0
        /// <summary>
        /// Add Table in DB
        /// </summary>
        /// <param name="md">DB Info</param>
        /// <param name="catalog">current catalog</param>
        /// <param name="schema">schema</param>
        private void AddTable(DatabaseMetaData md, String catalog, String schema)
        {
            DataSet ds = md.GetTables();

            for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
            {
                String tableName = ds.Tables[0].Rows[i]["TABLE_NAME"].ToString();
                String tableType = ds.Tables[0].Rows[i]["TABLE_TYPE"].ToString();

                //	Try to find
                MTable table = MTable.Get(GetCtx(), tableName);
                //	Create new ?
                if (table == null)
                {
                    String tn = tableName.ToUpper();
                    if (tn.StartsWith("T_SELECTION") || //	temp table
                        tn.EndsWith("_VT") ||           //	print trl views
                        tn.EndsWith("_V") ||            //	views
                        tn.EndsWith("_V1") ||           //	views
                        tn.StartsWith("A_A") ||         //	asset tables not yet
                        tn.StartsWith("A_D") ||         //	asset tables not yet
                        (tn.IndexOf("$") != -1          //	oracle system tables
                        ) ||
                        (tn.IndexOf("EXPLAIN") != -1    //	explain plan
                        )
                        )
                    {
                        log.Fine("Ignored: " + tableName + " - " + tableType);
                        continue;
                    }
                    //
                    log.Info(tableName + " - " + tableType);

                    //	Create New
                    table = new MTable(GetCtx(), 0, Get_Trx());
                    table.SetEntityType(p_EntityType);
                    table.SetName(tableName);
                    table.SetTableName(tableName);
                    table.SetIsView("VIEW".Equals(tableType));
                    if (!table.Save())
                    {
                        continue;
                    }
                }
                //	Check Columns
                tableName = tableName.ToUpper();
                DataSet rsC = md.GetColumns(catalog, schema, tableName);
                //addTableColumn(GetCtx(), rsC, table, p_EntityType);
                //SubTableUtil.checkStandardColumns(table, p_EntityType);
            }
        }       //	addTable