我正在使用sql * Plus.当我使用以下查询时,它给出错误
@H_404_1@Error report:
ORA-06550: line 4,column 1:
PLS-00428: an INTO clause is expected in this SELECT statement
询问
@H_404_1@declare id varchar2(80) :='test123'; begin select test_quote,test_id from order_link where id = 'test123'; end;
不知道你为什么要使用PL / sql块.您没有使用您声明的ID,最好给它一个与列名称不同的名称以避免混淆.
您可以在sql * Plus中声明一个绑定变量,然后选择:
@H_404_1@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:
@H_404_1@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所以你不需要声明那些变数.