I am maintaining an asp page that builds a select query as a plain old string and executes it using oracle odbc.
There is basically too much code to change over to stored proccedures or other nice means.
How can I escape a & ? Using sql+ there is an escape on command, is there a similar concept for odbc? Is this an odbc question rather than oracle?
6 2068
can you kindly post the query for my reference.
can you kindly post the query for my reference.
sorry i did not get an email notification.
That is really the query.
"select a,b from mytable where c=' 1 & 2' ".
c is a varchar, a and b are columns . I don't have the freedom to do a sp or p, or a parameterized command. And worse still, it has to work with Oracle and Access.
I did discover there is an escape concept in sql+ that you can turn on and then \& is interpreted as a character and not a place holder for a parameter.
sorry i did not get an email notification.
That is really the query.
"select a,b from mytable where c=' 1 & 2' ".
c is a varchar, a and b are columns . I don't have the freedom to do a sp or p, or a parameterized command. And worse still, it has to work with Oracle and Access.
I did discover there is an escape concept in sql+ that you can turn on and then \& is interpreted as a character and not a place holder for a parameter.
If you change your query to something like this: -
-
select a,b from mytable where c IN ('1','2')
-
-
If you change your query to something like this: -
-
select a,b from mytable where c IN ('1','2')
-
-
no, sorry c is a varchar that has the literal value '1 & 2'.
like 'burger & fries'.
no, sorry c is a varchar that has the literal value '1 & 2'.
like 'burger & fries'.
Try this way: -
-
SQL> SET SCAN OFF
-
SQL> declare
-
2 c varchar2(20) := '1 & 2 & 3';
-
3 v_output VARCHAR2(2);
-
4 s_sql VARCHAR2(200);
-
5 BEGIN
-
6 c:= CHR(39)||REPLACE(c,' & ',',')||CHR(39);
-
7 s_sql:= 'SELECT ''x'' FROM DUAL WHERE ''x'' NOT IN ('||c||')';
-
8 EXECUTE IMMEDIATE s_sql INTO v_output;
-
9 dbms_output.put_line('Format of IN parameter:'||c);
-
10 dbms_output.put_line('Output using Formatted IN:'||v_output);
-
11 end;
-
12 /
-
Format of IN parameter:'1,2,3'
-
Output using Formatted IN:x
-
-
PL/SQL procedure successfully completed.
-
-
SQL>
-
-
Remember in the above example the 2 single colons are used in the select statement and not a double quote
Something like this also will work: -
-
SQL> SET SCAN OFF
-
SQL> select * from dual where 'x' not in (REPLACE('1 & 2',' & ',','))
-
2 /
-
-
D
-
-
-
X
-
-
SQL>
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ian justice |
last post by:
Before i post actual code, as i need a speedyish reply.
Can i first ask if anyone knows off the top of their head, if there is
a likely obvious cause to the following problem.
For the moment i've...
|
by: lkrubner |
last post by:
Are there any benchmarks on how much an extra, unneeded VARCHAR, CHAR,
INT, BIGINT, TEXT or MEDIUMTEXT slows down a database call with MySql?
PostGre info would also be useful.
I'm trying to...
|
by: Radu |
last post by:
Hi. I have lots of processing to do on the server - from the client
(Access) I call a sproc which returns a recordset (the sproc is
essentially a big "select"). With the obtained data , I need to...
|
by: GSteven |
last post by:
(as formerly posted to microsoft.public.access.forms with no result)
I've created a continuous form which is based on a straightforward table
(ex - customers - 100 records). On the form there is...
|
by: Arne |
last post by:
A lot of Firefox users I know, says they have problems with validation
where the ampersand sign has to be written as & to be valid. I don't
have Firefox my self and don't wont to install it only...
|
by: Henning M |
last post by:
Hi all,
I having some problems with Access and selecting records between dates..
When I try this in access, it works fine!!
"Select * from Bilag Where Mdates Between #1/1/2006# And...
|
by: divya |
last post by:
Hi,
I have a table tblbwday with 2 fields Name and Birthday.I have written
this script for displaying evryday names of the people on that day.
<%
set objConn...
|
by: Ragnar |
last post by:
Hi,
2 issues left with my tidy-work:
1) Tidy transforms a "&" in the source-xml into a "&" in the tidied
version. My XML-Importer cannot handle it
2) in a long <title>-string a wrap is...
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
I need to build a sql string that looks like this:
strSql = "Select * from tbl1 Where x In (123,456,789)"
or
strSql = "Select * from tbl1 Where x In (123,456,789,527,914)"
The numbers...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| | |