Solved

PL/SQL Procedure Alter Table

Posted on 2004-09-08
1
614 Views
Last Modified: 2013-12-11
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
Comment
Question by:RockyFullen
1 Comment
 
LVL 23

Accepted Solution

by:
seazodiac earned 125 total points
ID: 12011251
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to take different types of Oracle backups using RMAN.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question