?
Solved

Escape Character for &

Posted on 2006-07-05
12
Medium Priority
?
1,450 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
Independent Software Vendors: 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!

 
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 500 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

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…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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.
This video shows how to recover a database from a user managed backup

718 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