|
-
in PL/SQL, you can only do select, insert, update statement, but not alter, create statements. I tried that and it gave me this err message.
--------------
SQL> start patch
ALTER TABLE TEST ADD(EEE VARCHAR2 (50));
*
ERROR at line 11:
ORA-06550: line 11, column 6:
PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
begin declare else elsif end exit for goto if loop mod null
pragma raise return select update while
<<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall
SQL>
--------------
and here is my patch.sql
VARIABLE cur_version VARCHAR2 (10)
VARIABLE target_version VARCHAR2 (10)
DECLARE
version VARCHAR2 (10);
BEGIN
SELECT VALUE INTO version FROM SYSFIELD WHERE SYSKEY='DB_VERS_LOAN';
:cur_version := version;
:target_version := '7.1';
IF :cur_version < :target_version THEN
DBMS_OUTPUT.PUT_LINE('Task is complete, old version = ' || :cur_version);
:cur_version := :target_version;
ALTER TABLE TEST ADD(EEE VARCHAR2 (50));
INSERT INTO TEST VALUES('NOUPDATE', '','','');
DBMS_OUTPUT.PUT_LINE('Task is complete, new version = ' || :cur_version);
ELSE
INSERT INTO TEST VALUES('NOUPDATE', '','','');
DBMS_OUTPUT.PUT_LINE('Task is complete, current db version = ' || :cur_version || ' is already up to date');
END IF;
END;
.
/
print cur_version
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|