当前位置: 代码迷 >> Oracle技术 >> 存储过程求解,有个变量怎么办
  详细解决方案

存储过程求解,有个变量怎么办

热度:83   发布时间:2016-04-24 08:28:40.0
存储过程求解,有个变量怎么处理
table
id name number
1 fdfdfd 3223
2 dfdfdf 4566
存过程如下:
create procedure Ptest(in id int)
begin
select * from table where id=id;
end;//
此过程,就是依id号,显示信息,没有错语,我要改进一下。
安给的id来,称王筛选一下信息:
我要实现安name一列group by 应该怎么写
SQL code
create procedure Ptest2(in id int,in Paixu varchar(20))
begin
select * from table where id=id group by Paixu;
end;//


错在何处?
就是,那个变量要怎么处理
select * from table where id=id group by Paixu;
还是这样:
select * from table where id=id group by '.Paixu.';

------解决方案--------------------
1:你传入的PAIXU是字段的话,要用到动态SQL执行
2:用GROUP BY ,好好看看用法吧,感觉你用的是ORDER BY
  相关解决方案