Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个脚本,它只是连接到 sql*plus 中的表并在表中插入一行。
它抛出如下错误:
SP2-0552: Bind variable "BIND" not declared
我无法确切地弄清楚它试图插入的查询中的绑定变量是什么。
您正在尝试运行这样的 sql:
SELECT 1 FROM DUAL WHERE :BIND = 1;
SQL*Plus 标识:BIND为绑定变量,但您尚未在会话中声明一个。要声明绑定变量,请使用VAR(IABLE)命令。
:BIND
VAR(IABLE)
VAR BIND NUMBER
然后,您可以为变量赋值。
EXEC :BIND := 1
再次运行select以确认绑定变量现在已设置。请注意,您还可以使用此变量来保存单行查询的结果。
select
SELECT 1 INTO :BIND FROM DUAL;