dbsetupcheck.cs

来自「oracle dal gen,生成.NET ORACLE DAL层代码」· CS 代码 · 共 66 行

CS
66
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Oracle.DataAccess.Client;
using System.Resources;

namespace OracleDALGen.Classes.Database
{
    public class DBSetup
    {
        private const string selectPkgGen = "select * from user_objects where object_name = 'PKG_GEN'";
        private const string selectTableInfo = "select * from table_info where 1=2";
        private const string procPkgGenVersion = "pkg_gen.get_version";

        private OraConnection connection;

        public DBSetup(OraConnection connection)
        {
            this.connection = connection;
        }

        public string CheckPLGenPackage()  
        {
            DataSet ds = DBUtils.LoadSQL(selectPkgGen, null, connection);

            if (ds != null && ds.Tables["data"].Rows.Count == 2)
            {
                List<OracleParameter> op = new List<OracleParameter>();
                op.Add(new OracleParameter("ver", OracleDbType.Clob, ParameterDirection.ReturnValue));

                string version = (string)DBUtils.ExecuteNonQuery(procPkgGenVersion, op, connection, CommandType.StoredProcedure, OracleDbType.Clob);
                return string.Format("pkg_gen version {0} installed", version);
            } 
            else
                return "pkg_gen not installed";
        }

        public string CheckTableInfoView()
        {
            DataSet ds = null;
            try
            {
                ds = DBUtils.LoadSQL(selectTableInfo, null, connection);
            } catch {}


            if (ds != null)
                return "table_info view installed";
            else
                return "table_info view not installed";
        }

        public bool InstallPLGenPackage()
        {            
            bool result = false;

            result &= DBUtils.Execute(SQLResource.table_info, null, CommandType.Text, connection);
            result &= DBUtils.Execute(SQLResource.pkg_gen_header, null, CommandType.Text, connection);
            result &= DBUtils.Execute(SQLResource.pkg_gen_body, null, CommandType.Text, connection);

            return result;
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?