I'm trying a simple INSERT statement against an Oracle database. One of the values is a VARCHAR2 field and the insert statement contains an ampersand. How do I do this? I've tried the following methods:
Any other ideas?
How I solved it is escaping the & with another &.
For example:
INSERT INTO Foo (Bar) VALUES ('Up && Away');
Works nicely. Thanks for all the help
One of the features of PL/SQL Developer which it takes time to get familiar with is the plethora of different window types.
One of these is the COMMAND window, which is basically a SQL*Plus emulator. We can run SQL*Plus commands as well as SQL, so SET ESCAPE
, SET DEFINE
and indeed SET SCAN OFF
work in that window.
Have you tried something like this?
INSERT INTO tablex VALUES ('Sid ' || '&' || ' Nancy');
Improving my first answer, your problem is related with PL/SQL Developer. If you execute your block in a PL/SQL Developer Command window, you could also use the standard SET DEFINE OFF, which works the same as in SQL*Plus.
the concat worked perfectly fine for me below is what i did in my select statement:
select FUND_NM
FROM PERFORMANCE
WHERE upper(FUND_DESC) in ('My L&' ||'L FUNDS')
I use chr(38)
where I need an ampersand in PL/SQL.
addr:= 'mysite.com/order.aspx?no=5678' || CHR(38) || 'id=947';
--above line gives you 'mysite.com/order.aspx?no=5678&id=947';
This is just a SQL Editor issue. To resolve this just compile the procedure with SET DEFINE OFF; . Execution which is PL (executing in server) will not face this issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.