Forum Stats

  • 3,727,632 Users
  • 2,245,422 Discussions
  • 7,852,901 Comments

Discussions

Is there something special with lines that start with #?

Ray007
Ray007 Member Posts: 28 Bronze Badge

Compile this procedure in:

create or replace procedure test_case is
  l_garbage varchar2(500);
BEGIN

    l_garbage := q'[
    #CT_TITLE#
    #CT_SUBTITLE_LINE1#
    #CT_SUBTITLE_LINE2#
    #CT_SUBTITLE_LINE3#
    #CT_TOP_RIGHT#
    ]';

    raise_application_error(-20001, 'What are you running this for? Want to see garbage? ' || l_garbage);
END;

The output of compiling this procedure is:

ERROR at line 1:
unknown command "CT_TITLE#" - rest of line ignored.
ERROR at line 1:
unknown command "CT_SUBTIT..." - rest of line ignored.
ERROR at line 1:
unknown command "CT_SUBTIT..." - rest of line ignored.
ERROR at line 1:
unknown command "CT_SUBTIT..." - rest of line ignored.
ERROR at line 1:
unknown command "CT_TOP_RI..." - rest of line ignored.
Procedure created.

If I then look at the procedure that now exists in the database, it is:

CREATE OR REPLACE procedure test_case is
  l_garbage varchar2(500);
BEGIN

    l_garbage := q'[
    ]';

    raise_application_error(-20001, 'What are you running this for? Want to see garbage? ' || l_garbage);
END;

So what happened with the #STRING# lines?

Answers

  • Christian.Shay -Oracle
    Christian.Shay -Oracle Posts: 1,852 Employee

    I will need to check with our engineering team, but it looks like you've hit a parser bug.

    Here are two potential workarounds I could find:

    1) Run the script without the values that are causing the problem (or create a stub procedure with nothing in it). Then use the Edit menu item in Oracle Explorer, modify the procedure to fill in the procedure code. Then use the "Save to Database" menu item.

    2) Don't allow those # signs to be the first character on their own line... put all the text in a single line.

    Do either of those workarounds work for you? If not I will search for others.

  • Ray007
    Ray007 Member Posts: 28 Bronze Badge

    I hit the bug even if I have another file that has this in it.

    @test_case.plsql
    

    My current workaround is to use SqlDeveloper for this file. I can't exactly restructure the code as it's a template that has the #STRING# values replaced at runtime; written by someone else.

Sign In or Register to comment.