0

I am writing one sql query as below :-

select a, b, c
from table_name
where b in (
'some string & some string'
,'some other string & some other string'
)

Things I have tried :-

  1. Tried using SET DEFINE OFF. It seemed to work fine but its use is restricted to sql developer only, which is not my requirement. As i need to export this query to other tool for creating report.
  2. Tried using chr(38) like
'some string'|| chr(38) ||'some string'
,'some other string'|| chr(38) ||'some other string'

But it works fine when I use it one time. Using chr(38) multiple times is throwing error.

Any leads over here is aprreciable. Thanks in advance.

acroniks
  • 99
  • 7

1 Answers1

0

You can use the chr(38) as many times as you want. In your example, I can see that spaces are not managed properly. There is space before and after &.

Your actual string: 'some string & some string'

Your string with concatenation: 'some string'|| chr(38) ||'some string' --> 'some string&some string' --> You can see that spaces before and after & is missing in your concatenated string.

so this space must be there after concatenation. Following will help you

SQL> select *
  2  from dual
  3  where 'some string '|| chr(38) ||' some string' in (
  4  'some string '|| chr(38) ||' some string' -- see the space before and after concatanation
  5  ,'some other string ' || chr(38) ||' some other string'
  6  );

D
-
X

SQL>
Popeye
  • 35,427
  • 4
  • 10
  • 31