Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PL/SQL Procedure Alter Table

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

792 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