0

在 Oracle PL/SQL 中,我有这个编码,它给了我编译器错误。我不知道为什么,看起来我拥有一切......

请帮忙。

谢谢

 ORA-06550: line 6, column 5:
PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:

   ( begin case declare end exit for goto if loop mod null
   pragma raise return select update while with <an identifier>
   <a double-quoted delimited-identifier> <a bind variable> <<
   continue close current delete fetch lock insert open rollback
   savepoint set sql execute commit forall merge pipe purge
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

代码是

begin
  for c in (select id from tmp_A)
  loop
    dbms_output.put_line(c.id);

    create table tmp_c as 
    select B.name from tmp_B B where B.id = c.id;   

    drop table tmp_c;
  end loop;
end;
/
4

1 回答 1

3

您不能直接在 PL/SQL 中调用 ddl 语句(CREATE、DROP、ALTER 等)。但是,您可以使用执行立即语句:

begin
  EXECUTE IMMEDIATE 'CREATE TABLE MYTABLE(DT DATE)';
end;

看:

http://www.orafaq.com/wiki/PL/SQL_FAQ#Can_one_call_DDL_statements_from_PL.2FSQL.3F
于 2012-07-02T15:25:34.963 回答