'drop table newtable; create table newtable for select        
             field1, field2  from oldtable'   改为:
'drop table newtable; create table newtable select        
             field1, field2  from oldtable'

解决方案 »

  1.   

    对不起,这不用存贮过程,
    直接在文本编辑器中编辑好两句,
    drop table newtable;
    create table newtable as select field1,field2 from oldtable;
    存入c:\test.sql文件中,
    在sqlplus下:@c:\test.sql
    即可执行。
       
      

  2.   


     在这里 sql_str1 和 sql_str2 是存储过程的两参数  如果只用一个参数
       :做为字符串,就要在过程里判断,截取不就行了?
    sql_str:='drop table newtable; create table newtable for select        
                 field1, field2  from oldtable' 
    sql_str1 := SUBSTR(sql_str,I,INSTR(sql_str,‘;’)。。
    execute immediate sql_str1;  
      

  3.   

    declare 
      sql_str varchar2(100);
    begin
      sql_str:='begin drop table bb; drop table cc; end;';
      execute immediate sql_str;
    end;
    /试试这种方式,来不及测试
      

  4.   

    不好意思 昨天没时间看你们的回贴 beckhambobo(beckham)   这样做我试过了 回报这样的错 
    ---------------------------
    Error
    ---------------------------
    ORA-06550: 第 1 行, 第 7 列: 
    PLS-00103: 出现符号 "DROP"在需要下列之一时:
     begin case declare exit
       for goto if loop mod null pragma raise return select update
       while with <an identifier>
       <a double-quoted delimited-identifier> <a bind variable> <<
       close current delete fetch lock insert open rollback
       savepoint set sql execute commit forall merge
       <a single-quoted SQL string> pipe
    ORA-06512: 在"LD.TESTAAA", line 11
      

  5.   

    LGQDUCKY(飘)  用这种方法只能取第一条SQL 啊 
    如果 sql_str 是 三条以上怎么办?
      

  6.   

    BlueskyWide(谈趣者)  在我的设计中  sql_str 也是存在数据库中的
    为一个 Clob 字段 实现安装软件的 表 及 存储过程 的创建 如果要通过你那种方法
    可能要先在客户端实现生成 .sql 文本