0

Hi the following statment throws some errors. Its within a stored proc. Is it legal?

V_LONG_STR := 'Text1';
EXECUTE IMMEDIATE 'V_LONG_STR := NULL';

The error I get is ORA-00900: invalid SQL statement

I'm trying to work my way up to

 V_LONG_STR := 'REPLACE (''TEST1'',''TEST'', ''TEXT'')';
 EXECUTE IMMEDIATE V_LONG_STR;

and edventually

 V_LONG_STR := 'REPLACE (''V_LONG_STR := ''TEST1'',''TEST'', ''TEXT'')';
 EXECUTE IMMEDIATE V_LONG_STR;

but first things first

0

2 Answers 2

3
V_LONG_STR := '
  declare
    a varchar2(100);
  begin
    a := REPLACE (''TEST1'',''TEST'', ''TEXT'');
  end;
';
EXECUTE IMMEDIATE V_LONG_STR;
Sign up to request clarification or add additional context in comments.

Comments

2

Alternatively (less hassle with embedded quotes):

V_LONG_STR := q'[
  declare
    a varchar2(100);
  begin
    a := REPLACE ('TEST1','TEST','TEXT');
  end;
]';
EXECUTE IMMEDIATE V_LONG_STR;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.