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!

Combination that leads to an error: Illegal use of a type before its declaration

user5935717May 7 2021

/* Reposting to proper category as moderator points out */
Hello,
I think I have encountered some kind of internal parser error:

Error report -
ORA-24344: success with compilation error
ORA-06512: at line 11
24344. 00000 - "success with compilation error"
*Cause: A sql/plsql compilation error occurred.
*Action: Return OCI_SUCCESS_WITH_INFO along with the error code

Errors for TRIGGER foo_trg:

LINE/COL ERROR
-------- -------------------------------------------------------
1/5 PLS-00498: illegal use of a type before its declaration
1/5 PL/SQL: Item ignored

It occurs in specific case for combination of CHR(13) and object name of length less that 4 characters;
In order to remove this error, I need to either add space before or after CHR(13), remove CHR(13), or increase object name to min. 4 characters.

Test case:

create table foo(sysid number(12, 0));
/
declare stmt varchar2(4000);
begin
stmt := 'CREATE OR REPLACE TRIGGER foo_trg AFTER UPDATE' || CHR(13)
||'ON foo FOR EACH ROW' || CHR(13)
||'DECLARE' || CHR(13)
||'TYPE arr_type IS TABLE OF BOOLEAN INDEX BY PLS_INTEGER;' || CHR(13)
||'arr arr_type;' || CHR(13)
||'BEGIN' || CHR(13)
||' NULL;' || CHR(13)
||'END;';
execute immediate stmt;
end;
/
show errors trigger foo_trg;
/
declare stmt varchar2(4000);
begin
stmt := 'CREATE OR REPLACE TRIGGER foo_trg AFTER UPDATE' || CHR(13)
||'ON foo FOR EACH ROW' || CHR(13)
||'DECLARE' || CHR(13)
||'TYPE arr_type IS TABLE OF BOOLEAN INDEX BY PLS_INTEGER;' || CHR(13)
||'arrr arr_type;' || CHR(13)
||'BEGIN' || CHR(13)
||' NULL;' || CHR(13)
||'END;';
execute immediate stmt;
end;
/
declare stmt varchar2(4000);
begin
stmt := 'CREATE OR REPLACE TRIGGER foo_trg AFTER UPDATE' || CHR(13)
||'ON foo FOR EACH ROW' || CHR(13)
||'DECLARE' || CHR(13)
||'TYPE arr_type IS TABLE OF BOOLEAN INDEX BY PLS_INTEGER;' || CHR(13) || CHR(10)
||'arr arr_type;' || CHR(13)
||'BEGIN' || CHR(13)
||' NULL;' || CHR(13)
||'END;';
execute immediate stmt;
end;
/
drop table foo;

Thanks in advance.

This post has been answered by BluShadow on May 11 2021
Jump to Answer
Comments
Post Details
Added on May 7 2021
19 comments
1,098 views