dynamic query execution issue with a variable: in pl/sql procedure to create a directory

Want to create a directory in a PL/SQL procedure. If I don't consider the variable in the string to create the directory, it worked. However I have to consider the variable. For example,
declare
   v_str varchar2(6) := 'cat1';
begin
   v_sqltx := 'create or replace directory WK_DIR as ''c:\temp\''||v_str';
   execute immediate (v_sqltx );
end;
/
It did not work. Can any gurus offer some advice?
jl66Asked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
this should do:
declare
   v_str varchar2(6) := 'cat1';
begin
   v_sqltx := 'create or replace directory WK_DIR as ''c:\temp\' ||v_str ||'''';
   execute immediate (v_sqltx );
end;
/

Open in new window

0
 
jl66Author Commented:
Super! Greatly appreciate it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.