--将表wip.xwp_seq_daily_total_quantity中数据复制给临时表temp_emp 
--然后删除临时表temp_emp 中日期为20101118的数据,
--再删除表wip.xwp_seq_daily_total_quantity
--再将临时表temp_emp复制给wip.xwp_seq_daily_total_quantity
这些语句怎么写在存储过程中呢
create table temp_emp as (select  * from wip.xwp_seq_daily_total_quantity) ;delete temp_emp where to_char(DATETIME,'YYYYMMDD') ='20101118' ;drop table wip.xwp_seq_daily_total_quantity;create table wip.xwp_seq_daily_total_quantity  as (select  * from temp_emp); 

解决方案 »

  1.   

    --全部动态
    create or replace procedure p
    as
    begin
    execute immediate 'create table temp_emp as (select * from wip.xwp_seq_daily_total_quantity)'
    ....
    end;
      

  2.   

    写什么存储过程啊。。直接写到个文本文件里,直接执行多好(@sqltext.sql)。鄙见。。呵呵create or replace procedure exeDDL() as
    begin
      create table temp_emp as(
        select * from wip.xwp_seq_daily_total_quantity);
      delete temp_emp where to_char(DATETIME, 'YYYYMMDD') = '20101118';
      commit;
      drop table wip.xwp_seq_daily_total_quantity;
      create table wip.xwp_seq_daily_total_quantity as(
        select * from temp_emp);
    exception
      when others then
        dbms_output.put_line('操作失败') ; end;
      

  3.   


    EXECUTE IMMEDIATE 'create table temp_emp as (select * from wip.xwp_seq_daily_total_quantity) ';delete temp_emp where to_char(DATETIME,'YYYYMMDD') ='20101118' ;EXECUTE IMMEDIATE 'drop table wip.xwp_seq_daily_total_quantity';EXECUTE IMMEDIATE 'create table wip.xwp_seq_daily_total_quantity as (select * from temp_emp)';  
      

  4.   


    -------没注意呵呵见谅。。
    create or replace procedure exeDDL() as
    begin
      dbms_utility.exec_ddl_statement('create table temp_emp as(select * from wip.xwp_seq_daily_total_quantity)');
      delete temp_emp where to_char(DATETIME, 'YYYYMMDD') = '20101118';
      commit;
      dbms_utility.exec_ddl_statement('drop table wip.xwp_seq_daily_total_quantity');
      dbms_utility.exec_ddl_statement('create table wip.xwp_seq_daily_total_quantity as(select * from temp_emp');
    exception
      when others then
        dbms_output.put_line('操作失败') ; end;
      

  5.   

     如果临时表存在,就删除drop table temp_emp,语句应该怎么写,是不是
    if temp_emp exits then 
    drop table temp_empend if
      

  6.   

    如果临时表存在,就删除drop table temp_emp,语句应该怎么写,是不是
    if temp_emp exits then  
    drop table temp_empend if
      

  7.   

    如果临时表存在,就删除drop table temp_emp,语句应该怎么写,是不是
    if temp_emp exits then   
    drop table temp_empend if
      

  8.   


    execute immediate 'drop table temp_emp';
    execute immediate 'create table temp_emp as(select .....)'
      

  9.   

    你通过select * from user_tables 查询下吧select count(*) into cnt from user_tables where table_name = 'temp_emp';
    if cnt=0 then
    dbms_utility.exec_ddl_statement('drop table temp_emp');
    end if;
      

  10.   

    ----写错了,查询出来有记录应该是1select count(*) into cnt from user_tables where table_name = 'temp_emp';
    if cnt=1 then
    dbms_utility.exec_ddl_statement('drop table temp_emp');
    end if;
      

  11.   

    user_tables里的table_name注意大写。
      

  12.   

    create or replace procedure p1 as
    num number;
    begin
    select count(*) into num from user_tables where table_name =upper('temp_emp');
    if num>0 then
    EXECUTE IMMEDIATE 'drop table temp_emp';
    else
    EXECUTE IMMEDIATE 'create table temp_emp as (select * from wip.xwp_seq_daily_total_quantity) ';delete temp_emp where to_char(DATETIME,'YYYYMMDD') ='20101118' ;EXECUTE IMMEDIATE 'drop table wip.xwp_seq_daily_total_quantity';EXECUTE IMMEDIATE 'create table wip.xwp_seq_daily_total_quantity as (select * from temp_emp)'; 
    end if;
    end;
      

  13.   


    使用存储过程时,发生了这个错误,
      dim objCmd
    set objCmd =server.createobject("adodb.command")   
    objCmd.ActiveConnection= cn
    objCmd.CommandText="update_total_quantity"  
    objCmd.CommandType=adCmdStoredProc
    objCmd.execute  存储过程如下
    create or replace procedure update_total_quantity() as
    begin
      dbms_utility.exec_ddl_statement('create Global Temporary table temp_emp as(select * from wip.xwp_seq_daily_total_quantity)');
      delete temp_emp where to_char(DATETIME, 'YYYYMMDD') = '20101116';
      commit;
      dbms_utility.exec_ddl_statement('drop table wip.xwp_seq_daily_total_quantity');
      dbms_utility.exec_ddl_statement('create table wip.xwp_seq_daily_total_quantity as(select * from temp_emp');
    exception
      when others then
      dbms_output.put_line('操作失敗') ;
    end;select count(*) into cnt from user_tables where table_name = 'temp_emp';
    if cnt=1 then
    dbms_utility.exec_ddl_statement('drop table temp_emp');
    end if;哪位高手帮帮忙
      

  14.   

    按照你的方法,建了一个存储过程成功,却执行不了,
    EXEC update_total_quantity
    报错:
    ORA-00900:sql叙述句无效
      

  15.   


    --先前写的时候说了 全动态
    --执行的时候还得显示授权
    --grant create any table to 目标用户create or replace procedure update_total_quantity as
    num number;
    begin
    select count(*) into num from user_tables where table_name =upper('temp_emp');
    if num>0 then
    EXECUTE IMMEDIATE 'drop table temp_emp';
    else
    EXECUTE IMMEDIATE 'create table temp_emp as (select * from wip.xwp_seq_daily_total_quantity) ';
    end if;
    EXECUTE IMMEDIATE 'delete temp_emp where to_char(DATETIME,''YYYYMMDD'') =''20101118''' ;EXECUTE IMMEDIATE 'drop table wip.xwp_seq_daily_total_quantity';EXECUTE IMMEDIATE 'create table wip.xwp_seq_daily_total_quantity as (select * from temp_emp)';   end;
      

  16.   

    为什么把A表数据放到B后,之后在B中过滤某些数据,删除A表。之后在根据B表数据创建A表。
    不直接在A表里面操作呢......这个很有问题....