Forum OpenACS Development: A question about postgres-xql file

Collapse
Posted by Sid Widge on
Hi, I am working on the wimpy point pacakge and I just wanted to find out how do you go about declaring a variable in a postgres xql file and whether it is actaully necessary declaring a variable. I have looked at a few oracle files in xql and upon being ported to postgres the declare part is not used at all, I was wondering if someone can let meknow on how to do a loop in postgres: Here is my code(from postgres-xql) and what I think is right, but I am unsure of it.
select          if :role = ''read'' then
            for record in select member_id
              from group_member_map
              where group_id = :group_id;
            loop
                 acs_permission__grant_permission(:pres_item_id,
c.member_id,''wp_view_presentation'');
            end loop;
        else if (:role = ''write'') then
            for record in select member_id
              from group_member_map
              where group_id = :group_id;
              loop
                  acs_permission__grant_permission(:pres_item_id,
c.member_id,  ''wp_view_presentation'');
                  acs_permission__grant_permission(:pres_item_id,
c.member_id,
''wp_edit_presentation'');
            end loop;
        else
            for record in select member_id
              from group_member_map
              where group_id = :group_id;
             loop
          acs_permission__grant_permission(:pres_item_id, c.member_id,
''wp_view_presentation'');
          acs_permission__grant_permission(:pres_item_id, c.member_id,
''wp_edit_presentation'');
          acs_permission__grant_permission(:pres_item_id, c.member_id,
''wp_admin_presentation'');
            end loop;
        end if;