oracle 插入 带有“&”符号不成功的问题
高手同志们,我没奈了,我用SQL语句向数据库中插入带有&符号的字符串时,怎么着都不行,也到网上查了说是在SQLPLUS中用命令“ set define off”然后在插入就可以了,可是在我这不管用啊,高手能不能指点下啊
------解决方案--------------------SQL code
1.select 'abc' || chr(38) || 'def' from dual;
2.select 'abc' || '&' || 'def' from dual;
------解决方案--------------------
&可以用chr(38)代替喔
------解决方案--------------------
SQL> create table tt
2 (name varchar2(20)
3 );
Table created
SQL> insert into tt(name) valuse('xxx' ¦ ¦chr(38));
insert into tt(name) valuse('xxx' | |chr(38))
ORA-00926: 缺失 VALUES 关键字
SQL> insert into tt(name) values ('xxx' ¦ ¦chr(38));
1 row inserted
SQL> select * from tt;
NAME
--------------------
xxx&
SQL> insert into tt(name) values ('xxx' ¦ ¦chr(38)||'xx');
1 row inserted
SQL> select * from tt;
NAME
--------------------
xxx&
xxx&xx
SQL> select * from tt;
NAME
--------------------
xxx&
xxx&xx
SQL> insert into tt(name) values (translate('aaa{&}bb','a{}','a'));
1 row inserted
SQL> commit;
Commit complete
SQL> select * from tt;
NAME
--------------------
xxx&
xxx&xx
aaa&bb
SQL>