Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to create on script file with alter commands and PLSQL block

PavolAlcoholFeb 23 2012 — edited Feb 28 2012
Hi everybody

I need to create one script with three alters and PLSQL block:

Here is my original SQL:

alter table ProjectVersionTab add (AdditionalInfo2 varchar2(4000));

DECLARE
CURSOR c_version
IS
SELECT projectversionid, additionalinfo FROM ProjectVersionTab;
BEGIN
FOR version_rec IN c_version
LOOP
UPDATE ProjectVersionTab
SET additionalinfo2 = version_rec.additionalinfo
WHERE projectversionid = version_rec.projectversionid;
END LOOP;
END;

alter table ProjectVersionTab drop column AdditionalInfo;
alter table ProjectVersionTab rename column AdditionalInfo2 to AdditionalInfo;

But when I run it I got following error in Oracle SQl developer:
RA-06550: line 14, column 1:
PLS-00103: Encountered the symbol "ALTER"
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:


Can somebody help me how to do it? I preffer one script file.

thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2012
Added on Feb 23 2012
12 comments
3,625 views