TOAD thinks &String as bind variable

自古美人都是妖i 提交于 2019-12-12 14:31:49

问题


I am developing some ETL with Oracle Data Integrator and sometimes test parts of my code by TOAD. Today I had a problem with TOAD I had a line like

AND column_value like('DEV&PROD')

when I tried to run the SQL which includes filter above, TOAD ask for the value of PROD, it thought like PROD is a bind or substitution variable. Is there any option in TOAD settings to turn this feature of. I am using bind variable with a column (:), and my data includes & so I need to use it.

This code works in ODI perfectly, I only need a solution for TOAD. Thanks in advance.


回答1:


1) start your script with set define off; (and run whole script with F5 key)
or
2) use 'DEV&'||'PROD' instead of 'DEV&PROD'
or
3) set another prefix symbol for variables

set define ~;
select 'drag&drop', ~column_name from ~table_name;

(you will be prompted for column_name and table_name, but not for 'drop')




回答2:


In addition - will work in any tool or SQL prompt:

SELECT ('DEV'||'&'||'PROD') val FROM dual
/

-- Q-quote operator introduced in Oracle 10g --
SELECT 'DEV' || q'[&]'||'PROD' AS val FROM dual
/

Using Egor's or my examples - copy/paste, enter 1 for :bind_var :

SELECT 'DEV&'||'PROD' val FROM dual
 WHERE :bind_var = 1
/


来源:https://stackoverflow.com/questions/15066558/toad-thinks-string-as-bind-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!