I am using SQL*Plus. When I am using the below query, it is giving error
Error report:
ORA-06550: line 4, column 1:
PLS-00428: an INTO clause is expected in this SELECT statement
Query
declare
id varchar2(80) :='test123';
begin
select test_quote,test_id from order_link where id = 'test123';
end;
Not sure why you’re using a PL/SQL block for that. You aren’t using the
idyou declare, and it would be better to give it a name different to the column name to avoid confusion.You can declare a bind variable in SQL*Plus though, and select into that:
Note the
:before the references to the variables defined outside the block, indicating they are bind variables.l_idis declared inside the block so it does not have a preceding:.In this case you could also define
l_idoutside the block, and avoid PL/SQL while still using a bind variable for that:Because the main query isn’t PL/SQL any more (although the
execis; that’s just a shorthand for a one-line anonymous block), you don’t need toselect ... intoso you don’t need to declare those variables.