首页 > 数据库技术 > 详细

ddl in PL/SQL

时间:2014-04-11 00:45:03      阅读:610      评论:0      收藏:0      [点我收藏+]

If you write DDL directly in PL/SQL. You will hit error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  DECLARE
  2     str_sql varchar2(500);
  begin
  4     create table test (id number);
  end;
  6  /
        create table test (id number);
        *
ERROR at line 4:
ORA-06550: line 4, column 2:
PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
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 pipe

  

But you can use dynamic run as below.

1
2
3
4
5
6
7
8
9
10
  DECLARE
  2    str_sql varchar2(500);
  begin
  4    str_sql := ‘create table test (id number)‘;
  5    execute immediate str_sql;
  end
  7      ;
  8   /
 
PL/SQL procedure successfully completed.

  

ddl in PL/SQL,布布扣,bubuko.com

ddl in PL/SQL

原文:http://www.cnblogs.com/kramer/p/3656179.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!