create or replace procedure ys_sale_dts001
as
d_date date;
v_branchid varchar2(36);
BEGIN
select to_date(to_char(SYSDATe -3,'yyyy-mm-dd'),'yyyy-mm-dd') into d_date from dual;
select branchid into v_branchid from ys_branch where branchcode='Y75614';
delete from ys_sale_dts
where saleid in(select saleid from ys_sale where workdate=to_date('2012-10-17','yyyy-mm-dd')
and branchid='E973F14A-1FE4-465D-A8F6-E3255C4D9607');
/* where saleid in(select saleid from ys_sale where workdate=d_date and branchid=v_branchid);*/
insert into ys_sale_dts(saleid)
select saleid from ys_sale where workdate=to_date('2012-10-17','yyyy-mm-dd')
and branchid='E973F14A-1FE4-465D-A8F6-E3255C4D9607';commit;
END;
as
d_date date;
v_branchid varchar2(36);
BEGIN
select to_date(to_char(SYSDATe -3,'yyyy-mm-dd'),'yyyy-mm-dd') into d_date from dual;
select branchid into v_branchid from ys_branch where branchcode='Y75614';
delete from ys_sale_dts
where saleid in(select saleid from ys_sale where workdate=to_date('2012-10-17','yyyy-mm-dd')
and branchid='E973F14A-1FE4-465D-A8F6-E3255C4D9607');
/* where saleid in(select saleid from ys_sale where workdate=d_date and branchid=v_branchid);*/
insert into ys_sale_dts(saleid)
select saleid from ys_sale where workdate=to_date('2012-10-17','yyyy-mm-dd')
and branchid='E973F14A-1FE4-465D-A8F6-E3255C4D9607';commit;
END;
解决方案 »
- 急!如何从一张表的内容追加到另一张表里(字段不一样)?
- oracle 提示:ora-12542,地址被占用
- orcale数据库向mysql数据库中同步数据中数据乱码问题?
- dblink查询视图产生了事务 求指教
- 高分 求一触发器的写法 急!!
- 菜菜鸟求一数据写入语句
- SQL优化咨询:where子句里日期条件的优化
- oracle查询结果显示格式?
- shared memory realm doesn't exist!!!!!!! ORACLE启动不了!!
- ORACLE在JOB里执行定时清理CDC变更集的存储过程
- 安装了oracle,管理工具-服务 里面却没有OracleServiceDB服务,我的数据库名为DB,
- 求解释!!!!!急求!!!!!!!!!!!!
select saleid from ys_sale where rowid =
(select min(rowid) from ys_sale where workdate=to_date('2012-10-17','yyyy-mm-dd')
and branchid='E973F14A-1FE4-465D-A8F6-E3255C4D9607');
as
d_date date;
v_branchid varchar2(36);
BEGIN
select to_date(to_char(SYSDATe -3,'yyyy-mm-dd'),'yyyy-mm-dd') into d_date from dual;
select branchid into v_branchid from ys_branch where branchcode='Y75614';
delete from ys_sale_dts
where saleid in(select saleid from ys_sale where workdate=to_date('2012-10-17','yyyy-mm-dd')
and branchid='E973F14A-1FE4-465D-A8F6-E3255C4D9607');
/* where saleid in(select saleid from ys_sale where workdate=d_date and branchid=v_branchid);*/
insert into ys_sale_dts(saleid)
select saleid from ys_sale where workdate=to_date('2012-10-17','yyyy-mm-dd')
and branchid='E973F14A-1FE4-465D-A8F6-E3255C4D9607';commit;EXCEPTION WHEN OTHERS
THEN
DBMS_OUTPUT.PUTLINE(SQLERRM); END;
建议把错误信息输出来,更便于调试存储过程