| |

VerySource

 Forgot password?
 Register
Search
View: 1382|Reply: 9

How to escape&

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Invalid IP Address

Post time: 2020-3-12 22:00:02
| Show all posts |Read mode
SELECT * FROM A where A.col1 = 'F&ORG'

Use shell to call sqlplus. The value to be checked is that col1 is 'F&ORG', but it always prompts for the variable&org.
Reply

Use magic Report

0

Threads

71

Posts

50.00

Credits

Newbie

Rank: 1

Credits
50.00

 China

Post time: 2020-6-8 22:00:01
| Show all posts
SQL> insert into test000 values('scott'||chr(38)||'tiger');

1 row inserted

SQL> commit;

Commit complete

SQL> select * from test000;

username
----------------------------------------
scott&tiger
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-9 03:30:01
| Show all posts
SELECT * FROM A where A.col1 ='F' || chr(38) ||'ORG'
Reply

Use magic Report

0

Threads

39

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-6-9 07:00:01
| Show all posts
where A.col1 ='F'||'&'||'ORG'

Does this work
Reply

Use magic Report

0

Threads

71

Posts

50.00

Credits

Newbie

Rank: 1

Credits
50.00

 China

Post time: 2020-6-9 12:15:01
| Show all posts
Also possible

SQL> insert into test000 values('F'||'&'||'ORG');

1 row inserted

SQL> commit;

Commit complete

SQL> select * from test000;

username
----------------------------------------
scott&tiger
F&ORG
Reply

Use magic Report

0

Threads

39

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-6-9 12:30:01
| Show all posts
CREATE TABLE t_01(col1 VARCHAR2(20))
INSERT INTO t_01 VALUES ('F'||'&'||'ORG')
SELECT * FROM t_01
SELECT * FROM t_01 WHERE col1='F'||'&'||'ORG'

I can do this here
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Invalid IP Address

 Author| Post time: 2020-6-9 13:15:01
| Show all posts
Is there no escape character? . .
This is very troublesome to put together
Reply

Use magic Report

0

Threads

71

Posts

50.00

Credits

Newbie

Rank: 1

Credits
50.00

 China

Post time: 2020-6-9 20:30:01
| Show all posts
SQL> select * from test000 where "username"='scott'||chr(38)||'tiger';

username
----------------------------------------
scott&tiger

SQL> select * from test000 where "username"='F'||'&'||'ORG';

username
----------------------------------------
F&ORG
Reply

Use magic Report

0

Threads

39

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-6-10 13:45:02
| Show all posts
zt

Reply: Ask: Which is the escape character in the SQL statement?


I know, to use the escape character '\' in sql*plus, we must first modify the environment variables
set escape on
Then you can use the escape character '\', for example
SQL>set escape on
SQL>select count(*) from employees where name='\[$1']
   COUNT(*)
----------
          0
SQL>select count(*) from employees where name='&1';
  
Enter a value of 1: a
  
Original value 1: select count(*) from employees where name='&1'
New value 1: select count(*) from employees where name='a'
  
  COUNT(*)
---------
         
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Invalid IP Address

 Author| Post time: 2020-6-22 01:30:02
| Show all posts
Positive solution upstairs

SQL> set escape on
SQL> select'F&org' from dual;
Enter value for org:
old 1: select'F&org' from dual
new 1: select'F' from dual

'
-
F

SQL> select'F\&org' from dual;

'F&OR
-----
F&org

SQL>


Thanks everyone for answering
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list