Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PL/SQL Special Character & literal???? 1

Status
Not open for further replies.

bgreen

Programmer
Feb 20, 2003
185
CA
I have this variable that I want to be a constant CHAr or VARCHAR2 doesnn't really matter. Like the following:

Init CONSTANT VARCHAR2(60) := "/eE/e&l0o2a7C/e(10U/e(s0p11h0s3b4099T/e&a5L/e&f0s300y4x1S";

When I declare it like this it causes a promt to ask for a user variable. How do I make this variable work in pl/sql?
The value:

/eE/e&l0o2a7C/e(10U/e(s0p11h0s3b4099T/e&a5L/e&f0s300y4x1S




 
I think all you have to do is change the define to a different character and then switch it back at the end.

i.e.

SET DEFINE % (or whatever sybol you want to replace & with)

Let me know if that works for you
 
I think the prompt for user input is caused by the & character. So try replacing it by chr(38) -- that is ASCII code for it.
Code:
Init CONSTANT VARCHAR2(60):=
"/eE/e[b]"||chr(38)||"[/b]l0o2a7C/e(10U/e(s0p11h0s3b4099T/e[b]"||chr(38)||"[/b]a5L/e[b]"||chr(38)||"[/b]f0s300y4x1S";
 
Here's another question.

I have two variables:

ESC CONSTANT VARCHAR2(1) := chr(27);
PrettyFont CONSTANT VArCHAR2(25) := '/e(s1p12v1s3b4197T';

I want to do a replace for any occurence of /e with ESC.

 
Well, if you want to replace, I would use REPLACE!
Code:
SQL> declare
  2  ESC CONSTANT VARCHAR2(1) := chr(27);
  3  PrettyFont CONSTANT VArCHAR2(25) := '/e(s1p12v1s3b4197T';
  4  begin
  5  dbms_output.put_line(prettyfont);
  6  dbms_output.put_line(REPLACE(prettyfont,'/e',ESC));
  7  end;
  8  /
/e(s1p12v1s3b4197T
?(s1p12v1s3b4197T

PL/SQL procedure successfully completed.
 
Thanks for all the help. All your suggestions work!

[2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top