Solved

PL/SQL Procedure Alter Table

Posted on 2004-09-08
1
613 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Single ERP VS muttiple Application or Systems 6 62
Parametric query in oracle 6 49
Difference in number of minutes between 2 timestamps 16 39
Schema creation in Oracle12c 6 39
Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to take different types of Oracle backups using RMAN.

919 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now