oracle – 在SQL * Plus中声明绑定变量
发布时间:2020-12-12 13:50:03 所属栏目:百科 来源:网络整理
导读:我正在使用SQL * Plus.当我使用以下查询时,它给出错误 Error report:ORA-06550: line 4,column 1:PLS-00428: an INTO clause is expected in this SELECT statement 询问 declare id varchar2(80) :='test123'; beginselect test_quote,test_id from order_l
我正在使用SQL * Plus.当我使用以下查询时,它给出错误
Error report: ORA-06550: line 4,column 1: PLS-00428: an INTO clause is expected in this SELECT statement 询问 declare id varchar2(80) :='test123'; begin select test_quote,test_id from order_link where id = 'test123'; end;不知道你为什么要使用PL / SQL块.您没有使用您声明的ID,最好给它一个与列名称不同的名称以避免混淆. 您可以在SQL * Plus中声明一个绑定变量,然后选择: var l_test_quote varchar2(80); -- or whatever type/size you need var l_test_id varchar2(80); declare l_id varchar2(80) :='test123'; begin select test_quote,test_id into :l_test_quote,:l_test_id from order_link where id = l_id; end; / print l_test_quote print l_test_id 注意:在引用块之外定义的变量之前,表明它们是绑定变量. l_id在块内声明,因此它没有前面的:. 在这种情况下,您还可以在块外部定义l_id,并在仍然使用绑定变量时避免使用PL / SQL: var l_id varchar2(80); exec :l_id := 'test123'; select test_quote,test_id from order_link where id = :l_id; 因为主查询不再是PL / SQL(虽然exec是;这只是一行匿名块的简写),你不需要选择… into所以你不需要声明那些变数. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |