Using COUNT(*) and INTO oracle sql

Viewed 1293

I have select statement like this:

    with input as
    (select id,date,quantity
    from
    abc a,xyz z
    .......)
         select count(*)
         from input t
         where .....;

this statement gives me a result of 0 and i want to use this count=0 my part of procedure . I added select count(*) output from which looks like this now:

 select count(*) output
 with input as
    (select id,date,quantity
    from
    abc a,xyz z
    .......)
         select count(*)
         from input t
         where .....);

now the output will not be 0(zero) anymore because it counts the result of zero itself and give the final result as 1..how can i use INTO statment to pass/hold that zero or any other real result in ORACLE/SQL?

1 Answers

You would have something like this:

declare
    v_cnt number;
begin
    with input as (
          select id,date,quantity
          from abc a join
               xyz z
               .......
         )
    select count(*) into v_cnt
    from input t
    where .....;
end;
Related