/******************************************************************* /* global variables /* this example only works in SQL*PLUS (or SQL Developer) /******************************************************************/ VARIABLE how_many NUMBER / DECLARE cnt number; BEGIN select count(*) into cnt from student; :how_many := cnt; -- bind variable :how_many to cnt END; / select :y from dual / print y -- you can even use PRINT