Selecting a count into a variable in oracle Selecting a count into a variable in oracle oracle oracle

Selecting a count into a variable in oracle


The INTO clause is misplaced. It should be:

SELECT COUNT(*) INTO leadscount FROM LEADS_DELETED


you have the into at the wrong place.

Try something like this instead and proceed from there:

declare  cnt number;begin  select count(*)   into cnt  from leads_delete;end;


Another way :

declare  cnt number;  cmd varchar2(100);begin  cmd := 'select count(*) from leads_delete';  execute immediate cmd into cnt;end;