Solved

Escape Character for &

Posted on 2006-07-05
12
1,411 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
 
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
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.

 

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

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.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
custome paging in C# & oracle using inline queries. 12 37
Oracle Pivot 2 35
EXECUTE IMMEDIATE 5 36
Schema creation in Oracle12c 6 25
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now