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
Solved

Escape Character for &

Posted on 2006-07-05
12
1,437 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

809 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