Link to home
Start Free TrialLog in
Avatar of Rahul Bagal
Rahul BagalFlag for India

asked on

Escape Character for &

I am writing following Program to Access HTTP url

DECLARE
  req   utl_http.req;
  resp  utl_http.resp;
  value VARCHAR2(1024);
  URL VARCHAR2(1024);
BEGIN
  url := 'http://10.202.12.17:8080/login.asp?user=XYZ&pass=yzx123';
  req := utl_http.begin_request(url);
  utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
  resp := utl_http.get_response(req);
  LOOP
    utl_http.read_line(resp, value, TRUE);
    dbms_output.put_line(value);
  END LOOP;
  utl_http.end_response(resp);
EXCEPTION
  WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
END;


in this Program I need Escape Character for & at line
  url := 'http://10.202.12.17:8080/login.asp?user=XYZ&pass=yzx123';

when I run the code it asks
Enter value for pass:

Instead & is part of string

Thanks in advance

Avatar of oogooglies
oogooglies

Hi

Are you running this from SQL Plus? If so you can set the enviroment variables. Try set define off

Thanks
Hello rahulbagal,

one of the solutions is to concatenate the string - i.e.

variable url varchar2;
exec :url := 'http://10.202.12.17:8080/login.asp?user=XYZ' || '&' || 'pass=yzx123';
print url;
url
---------
http://10.202.12.17:8080/login.asp?user=XYZ&pass=yzx123

HTH

I
Either set define off

Or set escape off
 url := 'http://10.202.12.17:8080/login.asp?user=XYZ\&pass=yzx123';

should work for you
you can also use

set scan off

Hi rahulbagal,

you could use
set define off before DECLARE

and
set define on
after END;

regards

I
Avatar of Rahul Bagal

ASKER

Thanks a lot
this works in SQL plus  
How can I use it in toad ..
I am planning to execute this code in a trigger
rahulbagal

If you are going to use it as a storwed proc or part of a trigger the best solution would be the concant shown above.
You can always concat with CHR(38)...
Hi rahulbagal,

escape it with '\&', i.e.
url := 'http://10.202.12.17:8080/login.asp?user=XYZ\&pass=yzx123';

regards

I
Avatar of Acton Wang
>>How can I use it in toad ..
    I think that you don't need to do anything in toad for this.

    & is just for sql*plus variable.
ASKER CERTIFIED SOLUTION
Avatar of MohanKNair
MohanKNair

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot that worked perfectly