【问题标题】:Encountered symbol "DROP" when expecting one of the following预期以下情况之一时遇到符号“DROP”
【发布时间】:2019-01-25 07:27:53
【问题描述】:

您好,我正在编写一组简单的 oracle 语句,但我收到一条错误消息,提示“PLS-00103:在预期以下情况时遇到符号 DROP”。我不确定我的陈述有什么问题。任何帮助表示赞赏。

DECLARE
table_exists number := 0;  
BEGIN
    SELECT COUNT(*) INTO table_exists FROM dba_tables WHERE owner = 'ABC' 
AND table_name = 'XYZ';
   If (table_exists = 1) then     
      DROP TABLE "ABC"."XYZ";
    End If;
End;

【问题讨论】:

    标签: oracle


    【解决方案1】:

    如果你想在 PL/SQL 块中使用 DDL 语句,你必须使用动态 SQL。 试试这个:

    execute immediate 'DROP TABLE ' || owner.table_name
    

    【讨论】:

      猜你喜欢
      • 2015-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-19
      • 2014-09-18
      • 2012-10-26
      • 2021-02-03
      • 1970-01-01
      相关资源
      最近更新 更多