Solved

Escape Character for &

Posted on 2006-07-05
12
1,442 Views
Last Modified: 2008-01-09
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

0
Comment
Question by:rahulbagal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +5
12 Comments
 

Expert Comment

by:oogooglies
ID: 17042039
Hi

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

Thanks
0
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 17042061
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
0
 
LVL 14

Expert Comment

by:sathyagiri
ID: 17042106
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
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 9

Expert Comment

by:neo9414
ID: 17042132
you can also use

set scan off

0
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 17042141
Hi rahulbagal,

you could use
set define off before DECLARE

and
set define on
after END;

regards

I
0
 
LVL 2

Author Comment

by:rahulbagal
ID: 17042191
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
0
 

Expert Comment

by:oogooglies
ID: 17042222
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.
0
 
LVL 14

Expert Comment

by:GGuzdziol
ID: 17042317
You can always concat with CHR(38)...
0
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 17042347
Hi rahulbagal,

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

regards

I
0
 
LVL 19

Expert Comment

by:actonwang
ID: 17043769
>>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.
0
 
LVL 16

Accepted Solution

by:
MohanKNair earned 125 total points
ID: 17045029
DECLARE
  req   utl_http.req;
  resp  utl_http.resp;
  value VARCHAR2(1024);
  URL VARCHAR2(1024);
  v_amp char(1) := chr(38);
BEGIN
  url := 'http://10.202.12.17:8080/login.asp?user=XYZ'||v_amp||'pass=yzx123';
............


0
 
LVL 2

Author Comment

by:rahulbagal
ID: 17048185
Thanks a lot that worked perfectly
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question