oracle-databaseoracle11goraclereports

Count the day where 'CL' In oracle report what I tried is this :


Hi dear I want to count the CL from rows how many CL and Multiply it with this 827 what I tried is this its generating error what will be correct please

function CF_CLFormula return Number is
A NUMBER;
begin
  IF :DAY_COUNT = 'CL'
    THEN
    A := COUNT(:DAY_COUNT)*827;
    RETURN A; 
    END IF;
end;

it gives me error of count function is used only in select, yes it is but what I can use for this and get my answer


Solution

  • It won't work that way. You probably have to actually count rows from the table in a separate SELECT statement. Something like this:

    function CF_CLFormula return Number is
       A NUMBER;
    begin
      IF :DAY_COUNT = 'CL'
        THEN
    
          select count(*) * 827             --> this
            into a
            from some_table
            where day_count = 'CL';
    
        RETURN A; 
        END IF;
    end;