Skip to Main Content

SQL & PL/SQL

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!

getting DECLARE * ERROR at line 1: ORA-00900: invalid SQL statement

666412Jun 1 2009 — edited Jun 5 2009
This works fine when I use system user to create schema and then run this script.
When I create another user with grant connect, resource, create view permissions I get this error:

DECLARE
*

ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at .....


DECLARE
id MY_TABLE.ID%TYPE;
tname MY_TABLE.TABLENAME%TYPE;
pname MY_TABLE_TWO.PROPERTYNAME%TYPE;
CURSOR c1 IS
SELECT distinct evt.id , evt.TABLENAME , vid.propertyname
FROM MY_TABLE evt, MY_TABLE_TWO vid
WHERE evt.COL_1=1
AND evt.COL_2 = vid.COL_2
and not exists (select 1 FROM MY_TABLE_THREE facts
where evt.id = facts.eventid and facts.displayname=vid.propertyname);
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO id, tname, pname;
EXIT WHEN c1%NOTFOUND;
INSERT INTO MY_TABLE_THREE (ID, COLUMNLENGTH)
VALUES(S_ANALYTICS_SEQUENCE.nextval, 255);
EXECUTE IMMEDIATE 'ALTER TABLE ' || tname || ' add ' || pname || '_ NVARCHAR2(255)';
END LOOP;
CLOSE c1;
END;
This post has been answered by Walter Fernández on Jun 1 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 3 2009
Added on Jun 1 2009
9 comments
3,978 views