protected void ParseProcParams(DataStoredProcedure inputData, Function outputFunc)
        {
            //string paramString = inputData.ParamList;
            //if (string.IsNullOrEmpty(paramString))
            //{
            //    //nothing to parse
            //}
            //else
            //{
            //    string[] parts = paramString.Split(',');

            //    foreach (string part in parts) //part='OUT param1 int'
            //    {
            //        DbLinq.Schema.Dbml.Parameter paramObj = ParseParameterString(part);
            //        if (paramObj != null)
            //            outputFunc.Parameters.Add(paramObj);
            //    }
            //}

            //if (!string.IsNullOrEmpty(inputData.Returns))
            //{
            //    var paramRet = new Return();
            //    paramRet.DbType = inputData.Returns;
            //    paramRet.Type = ParseDbType(null, inputData.Returns);
            //    outputFunc.Return = paramRet;
            //}
        }
        protected void ParseProcParams(DataStoredProcedure inputData, Function outputFunc)
        {
            string paramString = inputData.param_list;

            if (string.IsNullOrEmpty(paramString))
            {
                //nothing to parse
            }
            else
            {
                string[] parts = paramString.Split(',');

                foreach (string part in parts) //part='OUT param1 int'
                {
                    DbLinq.Schema.Dbml.Parameter paramObj = ParseParameterString(part);
                    if (paramObj != null)
                    {
                        outputFunc.Parameters.Add(paramObj);
                    }
                }
            }

            if (!string.IsNullOrEmpty(inputData.returns))
            {
                var paramRet = new Return();
                paramRet.DbType   = inputData.returns;
                paramRet.Type     = ParseDbType(null, inputData.returns);
                outputFunc.Return = paramRet;
            }
        }
 protected virtual DataStoredProcedure ReadProcedure(IDataReader rdr)
 {
     DataStoredProcedure procedure = new DataStoredProcedure();
     int field = 0;
     procedure.procedure_name = rdr.GetAsString(field++);
     procedure.procedure_owner = rdr.GetAsString(field++);
     procedure.text_segment = rdr.GetAsString(field++);
     return procedure;
 }
Exemple #4
0
        protected virtual DataStoredProcedure ReadProcedure(IDataReader rdr)
        {
            DataStoredProcedure procedure = new DataStoredProcedure();
            int field = 0;

            procedure.procedure_name  = rdr.GetAsString(field++);
            procedure.procedure_owner = rdr.GetAsString(field++);
            procedure.text_segment    = rdr.GetAsString(field++);
            return(procedure);
        }
        DataStoredProcedure ReadProcedure(IDataReader rdr)
        {
            DataStoredProcedure procedure = new DataStoredProcedure();
            int field = 0;
            procedure.db = rdr.GetAsString(field++);
            procedure.name = rdr.GetAsString(field++);
            procedure.type = rdr.GetAsString(field++);
            procedure.specific_name = rdr.GetAsString(field++);

            procedure.param_list = rdr.GetString(field++); // for some obscure reasons, GetAsString() doesn't work
            procedure.returns = rdr.GetAsString(field++);
            procedure.body = rdr.GetString(field++);
            return procedure;
        }
        DataStoredProcedure ReadProcedure(IDataReader rdr)
        {
            DataStoredProcedure procedure = new DataStoredProcedure();
            int field = 0;

            procedure.db            = rdr.GetAsString(field++);
            procedure.name          = rdr.GetAsString(field++);
            procedure.type          = rdr.GetAsString(field++);
            procedure.specific_name = rdr.GetAsString(field++);

            procedure.param_list = rdr.GetString(field++); // for some obscure reasons, GetAsString() doesn't work
            procedure.returns    = rdr.GetAsString(field++);
            procedure.body       = rdr.GetString(field++);
            return(procedure);
        }
 protected virtual DataStoredProcedure ReadProcedure(IDataReader rdr)
 {
     DataStoredProcedure procedure = new DataStoredProcedure();
     int field = 0;
     procedure.proowner = rdr.GetAsNumeric<long>(field++);
     procedure.proname = rdr.GetAsString(field++);
     procedure.proretset = rdr.GetAsBool(field++);
     procedure.prorettype = rdr.GetAsNumeric<long>(field++);
     procedure.formatted_prorettype = rdr.GetAsString(field++);
     procedure.proargtypes = rdr.GetAsString(field++);
     procedure.proallargtypes = rdr.GetAsString( field++);
     procedure.proargnames = rdr.GetAsString(field++);
     procedure.proargmodes = rdr.GetAsString(field++);
     return procedure;
 }
Exemple #8
0
        protected virtual DataStoredProcedure ReadProcedure(IDataReader rdr)
        {
            DataStoredProcedure procedure = new DataStoredProcedure();
            int field = 0;

            procedure.proowner             = rdr.GetAsNumeric <long>(field++);
            procedure.proname              = rdr.GetAsString(field++);
            procedure.proretset            = rdr.GetAsBool(field++);
            procedure.prorettype           = rdr.GetAsNumeric <long>(field++);
            procedure.formatted_prorettype = rdr.GetAsString(field++);
            procedure.proargtypes          = rdr.GetAsString(field++);
            procedure.proallargtypes       = rdr.GetAsString(field++);
            procedure.proargnames          = rdr.GetAsString(field++);
            procedure.proargmodes          = rdr.GetAsString(field++);
            return(procedure);
        }
 DataStoredProcedure ReadProcedure(IDataReader rdr)
 {
     DataStoredProcedure procedure = new DataStoredProcedure();
     int field = 0;
     procedure.TableSchema = rdr.GetAsString(field++);
     procedure.Name = rdr.GetAsString(field++).Trim();
     procedure.Type = rdr.GetAsString(field++);
     procedure.ParameterName = rdr.GetAsString(field++).Trim();
     procedure.IsOutputParameter = rdr.GetAsBool(field++);
     procedure.ParameterType = rdr.GetAsString(field++).Trim();
     procedure.Length = rdr.GetAsNullableNumeric<long>(field++);
     procedure.Precision = rdr.GetAsNullableNumeric<int>(field++);
     procedure.Scale = rdr.GetAsNullableNumeric<int>(field++);
     procedure.DefaultValue = rdr.GetAsString(field++);
     procedure.BodyContainsSelectStatement = rdr.GetAsBool(field++);
     return procedure;
 }
Exemple #10
0
        DataStoredProcedure ReadProcedure(IDataReader rdr)
        {
            DataStoredProcedure procedure = new DataStoredProcedure();
            int field = 0;

            procedure.TableSchema                 = rdr.GetAsString(field++);
            procedure.Name                        = rdr.GetAsString(field++).Trim();
            procedure.Type                        = rdr.GetAsString(field++);
            procedure.ParameterName               = rdr.GetAsString(field++).Trim();
            procedure.IsOutputParameter           = rdr.GetAsBool(field++);
            procedure.ParameterType               = rdr.GetAsString(field++).Trim();
            procedure.Length                      = rdr.GetAsNullableNumeric <long>(field++);
            procedure.Precision                   = rdr.GetAsNullableNumeric <int>(field++);
            procedure.Scale                       = rdr.GetAsNullableNumeric <int>(field++);
            procedure.DefaultValue                = rdr.GetAsString(field++);
            procedure.BodyContainsSelectStatement = rdr.GetAsBool(field++);
            return(procedure);
        }
Exemple #11
0
        protected void ParseProcParams(DataStoredProcedure inputData, Function outputFunc)
        {
            //string paramString = inputData.ParamList;
            //if (string.IsNullOrEmpty(paramString))
            //{
            //    //nothing to parse
            //}
            //else
            //{
            //    string[] parts = paramString.Split(',');

            //    foreach (string part in parts) //part='OUT param1 int'
            //    {
            //        DbLinq.Schema.Dbml.Parameter paramObj = ParseParameterString(part);
            //        if (paramObj != null)
            //            outputFunc.Parameters.Add(paramObj);
            //    }
            //}

            //if (!string.IsNullOrEmpty(inputData.Returns))
            //{
            //    var paramRet = new Return();
            //    paramRet.DbType = inputData.Returns;
            //    paramRet.Type = ParseDbType(null, inputData.Returns);
            //    outputFunc.Return = paramRet;
            //}
        }
Exemple #12
0
        Function ParseFunction(DataStoredProcedure pg_proc, Dictionary <long, string> typeOidToName, NameFormat nameFormat)
        {
            var procedureName = CreateProcedureName(pg_proc.proname, null, nameFormat);

            DbLinq.Schema.Dbml.Function dbml_func = new Function();
            dbml_func.Name   = procedureName.DbName;
            dbml_func.Method = procedureName.MethodName;

            if (pg_proc.formatted_prorettype != null && string.Compare(pg_proc.formatted_prorettype, "void") != 0)
            {
                var dbml_param = new Return();
                dbml_param.DbType = pg_proc.formatted_prorettype;
                dbml_param.Type   = MapDbType(null, new DataType {
                    SqlType = pg_proc.formatted_prorettype
                }).ToString();
                dbml_func.Return       = dbml_param;
                dbml_func.IsComposable = true;
            }

            if (pg_proc.proallargtypes != null)
            {
                string[]    argModes  = parseCsvString(pg_proc.proargmodes);
                string[]    argNames  = parseCsvString(pg_proc.proargnames);
                string[]    argTypes1 = parseCsvString(pg_proc.proallargtypes); //eg. {23,24,1043}
                List <long> argTypes2 = (from t in argTypes1 select long.Parse(t)).ToList();

                if (argNames == null)
                {
                    //proc was specified as 'FUNCTION doverlaps(IN date)' - names not specified
                    argNames = new string[argTypes1.Length];
                    for (int i = 0; i < argNames.Length; i++)
                    {
                        argNames[i] = ((char)('a' + i)).ToString();
                    }
                }

                bool doLengthsMatch = (argTypes2.Count != argNames.Length ||
                                       (argModes != null && argModes.Length != argNames.Length));
                if (doLengthsMatch)
                {
                    WriteErrorLine("L238 Mistmatch between modesArr, typeArr and nameArr for func " + pg_proc.proname);
                    return(null);
                }

                for (int i = 0; i < argNames.Length; i++)
                {
                    DbLinq.Schema.Dbml.Parameter dbml_param = new Parameter();
                    long argTypeOid = argTypes2[i];
                    dbml_param.DbType = typeOidToName[argTypeOid];
                    dbml_param.Name   = argNames[i];
                    dbml_param.Type   = MapDbType(argNames[i], new DataType {
                        SqlType = dbml_param.DbType
                    }).ToString();
                    string inOut = argModes == null ? "i" : argModes[i];
                    dbml_param.Direction = ParseInOut(inOut);
                    dbml_func.Parameters.Add(dbml_param);
                }
            }

            return(dbml_func);
        }
        Function ParseFunction(DataStoredProcedure pg_proc, Dictionary<long, string> typeOidToName, NameFormat nameFormat)
        {
            var procedureName = CreateProcedureName(pg_proc.proname, null, nameFormat);

            DbLinq.Schema.Dbml.Function dbml_func = new Function();
            dbml_func.Name = procedureName.DbName;
            dbml_func.Method = procedureName.MethodName;

            if (pg_proc.formatted_prorettype != null && string.Compare(pg_proc.formatted_prorettype, "void") != 0)
            {
                var dbml_param = new Return();
                dbml_param.DbType = pg_proc.formatted_prorettype;
                dbml_param.Type = MapDbType(null, new DataType { SqlType = pg_proc.formatted_prorettype }).ToString();
                dbml_func.Return = dbml_param;
                dbml_func.IsComposable = true;
            }

            if (pg_proc.proallargtypes != null)
            {
                string[] argModes = parseCsvString(pg_proc.proargmodes);
                string[] argNames = parseCsvString(pg_proc.proargnames);
                string[] argTypes1 = parseCsvString(pg_proc.proallargtypes); //eg. {23,24,1043}
                List<long> argTypes2 = (from t in argTypes1 select long.Parse(t)).ToList();

                if (argNames == null)
                {
                    //proc was specified as 'FUNCTION doverlaps(IN date)' - names not specified
                    argNames = new string[argTypes1.Length];
                    for (int i = 0; i < argNames.Length; i++) { argNames[i] = ((char)('a' + i)).ToString(); }
                }

                bool doLengthsMatch = (argTypes2.Count != argNames.Length
                    || (argModes != null && argModes.Length != argNames.Length));
                if (doLengthsMatch)
                {
                    WriteErrorLine("L238 Mistmatch between modesArr, typeArr and nameArr for func " + pg_proc.proname);
                    return null;
                }

                for (int i = 0; i < argNames.Length; i++)
                {
                    DbLinq.Schema.Dbml.Parameter dbml_param = new Parameter();
                    long argTypeOid = argTypes2[i];
                    dbml_param.DbType = typeOidToName[argTypeOid];
                    dbml_param.Name = argNames[i];
                    dbml_param.Type = MapDbType(argNames[i], new DataType { SqlType = dbml_param.DbType }).ToString();
                    string inOut = argModes == null ? "i" : argModes[i];
                    dbml_param.Direction = ParseInOut(inOut);
                    dbml_func.Parameters.Add(dbml_param);
                }
            }

            return dbml_func;
        }
Exemple #14
0
        protected void ParseProcParams(DataStoredProcedure inputData, Function outputFunc)
        {
            string paramString = inputData.param_list;
            if (string.IsNullOrEmpty(paramString))
            {
                //nothing to parse
            }
            else
            {
                string[] parts = paramString.Split(',');

                foreach (string part in parts) //part='OUT param1 int'
                {
                    DbLinq.Schema.Dbml.Parameter paramObj = ParseParameterString(part);
                    if (paramObj != null)
                        outputFunc.Parameters.Add(paramObj);
                }
            }

            if (!string.IsNullOrEmpty(inputData.returns))
            {
                var paramRet = new Return();
                paramRet.DbType = inputData.returns;
                paramRet.Type = ParseDbType(null, inputData.returns);
                outputFunc.Return = paramRet;
            }
        }