ORACLE视图传参问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ORACLE视图传参问题相关的知识,希望对你有一定的参考价值。
CREATE OR REPLACE VIEW V_GROUP_SELA_TOTAL ASSELECT (SELECT D.PROD_TYPE_NAME FROM V_PRODUCT_TYPE D WHERE D.PROD_TYPE_ID = A.PROD_TYPE_ID) PROD_TYPE_NAME, (SELECT C.SUPPLY_NAME FROM V_SUPPLY C WHERE C.SUPPLY_ID = A.SUPPLY_ID) SUPPLY_NAME, DECODE(A.RPO_MODEL, NULL, '小计', (SELECT E.PROD_MODEL FROM V_PRODUCT_INFO E WHERE E.PRO_MODEL = A.RPO_MODEL)) PROD_MODEL, A.RPO_MODEL, SUM(NVL(A.T_SALE_NUM, 0)) T_SALE_NUM, SUM(NVL(A.T_SALE_AMT, 0)) T_SALE_AMT, SUM(NVL(A.T_SALE_GROPROFIT, 0)) T_SALE_GROPROFIT, SUM(NVL(A.ACTUAL_PURCH_NUM, 0)) ACTUAL_PURCH_NUM, SUM(NVL(A.ACTUAL_PURCH_AMT, 0)) ACTUAL_PURCH_AMT, SUM(DECODE(B.SALE_CHANNEL, '0101', NVL(B.STAND_NUM, 0), 0)) STAND_NUM, SUM(DECODE(B.SALE_CHANNEL, '0101', NVL(B.AMT, 0), 0)) AMT FROM T_DV_GROUP_SALE_RPT A,T_DV_GROUP_SALE_CHANNEL B WHERE A.RPO_MODEL = B.RPO_MODEL AND A.ORG_NO = B.ORG_NO AND EXISTS (SELECT 1 FROM SY_SPT_PF_ORG_RELA C WHERE C.ORG_RELA_TYPE = 'REPORT_ORG' AND C.ORG_NO = B.ORG_NO START WITH C.ORG_NO = P_VIEW_GROUP.GET_ORG_NO() CONNECT BY PRIOR C.ORG_NO = C.ORG_PARENT_NO) GROUP BY ROLLUP(A.PROD_TYPE_ID, A.SUPPLY_ID, A.RPO_MODEL)HAVING A.SUPPLY_ID IS NOT NULL
创建视图后查询报错
SELECT * FROM V_GROUP_SELA_TOTAL WHERE GAS_KC.P_VIEW_GROUP.SET_ORG_NO('10000008') = '10000008';
SY_SPT_PF_ORG_RELA是同义词。有没有解决办法?
CONNECT BY PRIOR C.ORG_NO = C.ORG_PARENT_NO)
SQL语句有问题,这语句START WITH C.ORG_NO = P_VIEW_GROUP.GET_ORG_NO() 的最后面 多了个 ) 右括号也是导致报错。 参考技术A 你sql语句有问题,貌似不能运行,才报错的
c# 执行调用Oracle Procedure传参及回传值
////定義參數
//IDataParameter[] parameters =
//
// new OracleParameter(":p_stage", OracleDbType.Varchar2,model.Stage, ParameterDirection.Input),//传值
// new OracleParameter(":ReturnValue", OracleDbType.Varchar2, ParameterDirection.Output)//回传
// ;
////參數賦值
////parameters[0].Value = model.Stage;
//string prconn = System.Configuration.ConfigurationManager.AppSettings["DBConnStr_tnboa1insert"];
//OracleConnection conn = new OracleConnection(prconn);
//conn.Open();
//OracleCommand cmd = new OracleCommand("PRO__SETTLEMENT", conn); //Procedure &连接数据库
//cmd.CommandType = CommandType.StoredProcedure;
//cmd.Parameters.AddRange(parameters);
//OracleDataAdapter oda = new OracleDataAdapter(cmd);
//DataTable dt = new DataTable();
//oda.Fill(dt);
//conn.Close();
//string iReturn = cmd.Parameters["RETURNVALUE"].Value.ToString();
////return ds.Tables[0];
// string iReturn = ConnInstance.ExecuteQuery_Sp("PRO_SETTLEMENT", parameters);//执行完成后得到回传的结果
DataTable dt = new DataTable();
string prconn = System.Configuration.ConfigurationManager.AppSettings["DBConnStr_tnboa1insert"];
OracleConnection conn = new OracleConnection(prconn);
conn.Open();
OracleCommand cmd = new OracleCommand("PRO_SETTLEMENT",conn); //Procedure&连接数据库
//cmd.CommandText = "PRO_SETTLEMENT"; //Procedure
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("P_STAGE", OracleDbType.Varchar2).Direction = ParameterDirection.Input;//传值类型定义
cmd.Parameters["P_STAGE"].Value = model.Stage;//赋值
cmd.Parameters.Add("RETURNVALUE", OracleDbType.Varchar2,200).Direction = ParameterDirection.Output;//回传 注:回传定义字符长度,忽略会报错
cmd.ExecuteNonQuery();
string iReturn = cmd.Parameters["ReturnValue"].Value.ToString();////执行完成后得到回传的结果
conn.Close();
以上是关于ORACLE视图传参问题的主要内容,如果未能解决你的问题,请参考以下文章