我正在对 Oracle 数据库尝试一个简单的 INSERT 语句。其中一个值是 VARCHAR2 字段,并且插入语句包含一个 & 符号。我该怎么做呢?我尝试了以下方法:
- 将 & 转义为 \& 并设置转义
- 设置扫描关闭(这会导致 ORA-00922 丢失或无效选项错误)
- 设置定义关闭(这会导致 ORA-00922 丢失或无效选项错误)
还有其他想法吗?
我正在对 Oracle 数据库尝试一个简单的 INSERT 语句。其中一个值是 VARCHAR2 字段,并且插入语句包含一个 & 符号。我该怎么做呢?我尝试了以下方法:
还有其他想法吗?
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
需要时间熟悉的 PL/SQL Developer 的特性之一是过多的不同窗口类型。
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.
你有没有尝试过这样的事情?
INSERT INTO tablex VALUES ('Sid ' || '&' || ' Nancy');
改进我的第一个答案,您的问题与 PL/SQL Developer 有关。如果您在 PL/SQL Developer 命令窗口中执行您的块,您还可以使用标准的 SET DEFINE OFF,它的工作方式与 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.