[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 631
  • Last Modified:

PL/SQL Procedure Alter Table

Hi,
  I am trying to write a PL/SQL function to disable a table constraint. I continue to get syntax errors, and do not understand what I am doing wrong. Any help would be greatly appreciated.

Procedure -
CREATE PROCEDURE TEST()
 AS
BEGIN
   ALTER TABLE CM
   DISABLE CONSTRAINT FK_CM_REFERENCE_USERS;
END TEST;

Error -
Line # = 3 Column # = 1 Error Text = PLS-00103: Encountered the symbol "ALTER" 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    <a single-quoted SQL string> pipe


Thanks
0
RockyFullen
Asked:
RockyFullen
1 Solution
 
seazodiacCommented:
the procedure has incorrect syntax, for DDL you have to use dynamic SQL:

CREATE PROCEDURE TEST           --you don't need parathesis here.
AS
BEGIN
  execute immediate 'ALTER TABLE CM DISABLE CONSTRAINT FK_CM_REFERENCE_USERS';
END TEST;
/
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now