Search Postgresql Archives

Re: Loop in loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



OK, this looks better:


CREATE OR REPLACE FUNCTION getregistrationtagging()
  RETURNS SETOF ty_usertracking AS
$BODY$
DECLARE objReturn ty_usertracking%rowtype;
BEGIN
        for objReturn IN
        SELECT     date_part('day',trackdate) as ty_day,
            date_part('month',trackdate) as ty_month,
            date_part('year',trackdate) as ty_year,
            tag as ty_tag,
            designid as ty_designid
        FROM tbl_usertracking_registration
        GROUP BY     date_part('day',trackdate),
                date_part('month',trackdate),
                date_part('year',trackdate),
                tag,
                designid
           loop
               SELECT INTO objReturn.ty_count count(*) FROM tbl_usertracking_registration
                    WHERE date_part('day',trackdate)=objReturn.ty_day
                    AND date_part('month',trackdate)= objReturn.ty_month
                    AND date_part('year',trackdate)=objReturn.ty_year
                    AND tag=objReturn.ty_tag
                    AND designid=objReturn.ty_designid;
                       SELECT INTO objReturn.ty_date max(trackdate) FROM tbl_usertracking_registration
                    WHERE date_part('day',trackdate)=objReturn.ty_day
                    AND date_part('month',trackdate)=objReturn.ty_month
                    AND date_part('year',trackdate)=objReturn.ty_year
                    AND tag=objReturn.ty_tag
                    AND designid=objReturn.ty_designid;

            return next objReturn;   
     END LOOP;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION getregistrationtagging() OWNER TO postgres;

But still the question:
Is it possible to put a loop into a loop?  Or doesn't it make sense at all?

Kind regards,
Mo


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux