PL/SQL 存储过程如何批量插入数据?

hafoo 2013-04-05 04:31:32
create or replace procedure p_kgl_hoist(p_start_date in date, p_end_date in date) is

begin

insert into kgl_table select QUE_KGL_TIME.NEXTVAL as id, a.PROVINCE_NAME,a.province_id,a.tonnage,a.v_workingmachine,b.TOTALOFMACHINE,a.TOTALWORKTIME,a.AVETIMEOFWORKING,trunc(nvl(a.v_workingmachine/b.TOTALOFMACHINE,0),4) _KGL,
p_start_date,p_end_date

from

(
select i.PROVINCE_NAME ,
i.province_id ,
i.tonnage ,
count(distinct t.C_VEHICLENO) as v_workingmachine,
trunc(nvl(sum(t.c_duration)/3600,0),2) as TOTALWORKTIME,
trunc(trunc(nvl(sum(t.c_duration)/3600,0),2) / count(distinct t.C_VEHICLENO),4) AVETIMEOFWORKING
from hoisting t, csu_info i
where t.C_VEHICLENO = i.vechileno and i.tonnage>0
and t.c_start_time >=p_start_date and t.c_start_time <p_end_date
group by i.PROVINCE_NAME,i.province_id, i.tonnage
order by i.PROVINCE_NAME, i.tonnage, TOTALWORKTIME desc
) a,

(
select i.PROVINCE_NAME , i.tonnage ,count(distinct i.vechileno) as TOTALOFMACHINE from csu_info i,_vehicle v where i.vechileno=v.VMARK
and
v.REGISTEREDDATE <p_end_date
group by i.PROVINCE_NAME, i.tonnage order by i.PROVINCE_NAME, i.tonnage desc

) b
where a.tonnage=b.tonnage and a.PROVINCE_NAME=b.PROVINCE_NAME;

end p_kgl_hoist ;

输入参数后为什么查询不出数据?
...全文
245 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hafoo 2013-04-07
  • 打赏
  • 举报
回复
v.REGISTEREDDATE t.c_start_time 这两个字段确实是 日期型的字段呀,难道要用 to_date(to_char())进行转换,这样的SQL语句应该怎么写?
gaojiebao123 2013-04-05
  • 打赏
  • 举报
回复
错了,是“日期为啥不用数据类型 VARCHAR2,而用DATE??”
gaojiebao123 2013-04-05
  • 打赏
  • 举报
回复
日期为啥要用数据类型??

17,140

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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