How to put result of SQL into bind variable
exec is a PL/SQL block:

SQL&gt; var teste number
SQL&gt; exec select trunc(avg(user_id)) into :teste from dba_users;

PL/SQL procedure successfully completed.

SQL&gt; print :teste

     TESTE
----------
 447392453


It is the same as:

begin
  select trunc(avg(user_id)) into :teste from dba_users;
end;
/


SQL*Plus substitution variable:

SQL&gt; column my_value new_value teste
SQL&gt; select trunc(avg(user_id)) my_value from dba_users;

  MY_VALUE
----------
 447392453

SQL&gt; define teste
DEFINE TESTE           =  447392453 (NUMBER)
SQL&gt;