求一个PL/SQL的存储过程

BibleQ 2011-07-11 06:11:59
条件:
1.Java代码调用的时候有一下几个参数:
String []vestAreaName,String problemTypeName,StringproductionTypeName,String samTime,String[]handleDept,
String []sheetTime

2.查询数据的SQL语句:
SELECT *
FROM (SELECT t.main_sheet_flow_no,t.mobile_tele_no,'这里为数组vestAreaName的值','这里为samTime'FROM tbl_main_sheet t,tbl_departments m where t.main_status='22' and t.sheet_category_id in ('1','3')
and to_date(t.deal_time,'yyyy-mm-dd hh24:mi:ss') >= to_date('这里为数组sheetTime[0]','yyyy-mm-dd hh24:mi:ss')
and to_date(t.deal_time,'yyyy-mm-dd hh24:mi:ss') < (to_date('这里为数组sheetTime[1]','yyyy-mm-dd hh24:mi:ss')+10)
and t.handle_dept= m.department_id
and (t.handle_dept='handleDept数组[0]' or t.handle_dept='handleDept数组[1]' or t.handle_dept='handleDept数组[2]') 这里可能为两个 t.handle_dept 所以要判断
ORDER BY dbms_random.value)
WHERE rownum <= 10

end;
3.在存储过程中要将查询出来的值插入到另外一张表TBL_MAIN_SHEET_SAMPLING中


···················解决问题的大哥,100全给。
...全文
33 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
BibleQ 2011-07-11
  • 打赏
  • 举报
回复
其实我在Java中用代码都实现了,但是由于用的Hibernate1,所以他执行
SELECT *
FROM (SELECT t.main_sheet_flow_no,t.mobile_tele_no,'这里为数组vestAreaName的值','这里为samTime'FROM tbl_main_sheet t,tbl_departments m where t.main_status='22' and t.sheet_category_id in ('1','3')
and to_date(t.deal_time,'yyyy-mm-dd hh24:mi:ss') >= to_date('这里为数组sheetTime[0]','yyyy-mm-dd hh24:mi:ss')
and to_date(t.deal_time,'yyyy-mm-dd hh24:mi:ss') < (to_date('这里为数组sheetTime[1]','yyyy-mm-dd hh24:mi:ss')+10)
and t.handle_dept= m.department_id
and (t.handle_dept='handleDept数组[0]' or t.handle_dept='handleDept数组[1]' or t.handle_dept='handleDept数组[2]') ORDER BY dbms_random.value)
WHERE rownum <= 10
会报错,而且这条SQL语句就是Hibernate中打印出来的,可以在数据库中查询并且插入,就是通过程序调用报错,没有办法解决,所以寻求存储过程的思路,
yaoweijq 2011-07-11
  • 打赏
  • 举报
回复
存储过程我就不写了,就给简单思路吧
pl/sql存储过程的in变量就oracle那么几个类型
所以string数组要先转化成oracle认识的,你自己可以定格式
其他的cursor exe_immadiatexxx
查查资料就会写了

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧