17,382
社区成员




create or replace procedure customise(datefrom in varchar2, dateto in varchar2)
Authid Current_User as
vn_ctn number(2);
begin
select count(*) into vn_ctn from user_all_tables a where a.table_name like upper('customise1');
if vn_ctn > 0 then
execute immediate 'drop table customise1';
end if;
execute immediate 'create table customise1 as SELECT 关口点全名,电能量类型,数据 FROM 表底 WHERE datetime BETWEEN to_date(''datefrom'',''yyyy/mm/dd'') AND to_date(''dateto'',''yyyy/mm/dd'') and (电能量类型=''正向有功'' or 电能量类型=''反向有功'') GROUP BY 关口点全名,电能量类型,数据 HAVING COUNT(关口点全名)=trunc((To_date(''dateto'' , ''yyyy/mm/dd hh24-mi-ss'') - To_date(''datefrom'' , ''yyyy/mm/dd hh24-mi-ss'')+2))';
end ;
*
第一行出现错误:
ORA-01841:(完整) 年份值必须介于 -4731 和 +9999 之间,且不为 0
ORA-06512: 在 "ORACLE.CUSTOMISE", line 9
OEA-06512: 在 line 1
execute immediate 'create table customise1 as SELECT 关口点全名,电能量类型,数据 FROM 表底 WHERE datetime BETWEEN to_date('''||datefrom||''',''yyyy/mm/dd'') AND to_date('''||dateto||''',''yyyy/mm/dd'') and (电能量类型=''正向有功'' or 电能量类型=''反向有功'') GROUP BY 关口点全名,电能量类型,数据 HAVING COUNT(关口点全名)=trunc((To_date('''||dateto||''' , ''yyyy/mm/dd hh24-mi-ss'') - To_date('''||datefrom||''' , ''yyyy/mm/dd hh24-mi-ss'')+2))';