pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: iuri de araujo sampaio <iuri.sampaio@gmail.com>
To: pgsql-sql@postgresql.org
Subject: sintax error
Date: Fri, 19 Feb 2010 04:52:17 -0300
Message-ID: <4B7E4331.1050308@gmail.com> (raw)

Hi there,
i have got the followed error in the pgsql function bellow. 
Log messages point to:

********************
ERROR:  syntax error at end of input
LINE 1: SELECT
               ^
QUERY:  SELECT
CONTEXT:  SQL statement in PL/PgSQL function 
"cms_permission__revoke_permission" near line 67

********** Error **********

ERROR: syntax error at end of input
SQL state: 42601
Context: SQL statement in PL/PgSQL function 
"cms_permission__revoke_permission" near line 67

********************

However, I couldn't find any sintax error in those SELECT statements
does anyone have any idea what is wrong with it?

cheers,
iuri


-- procedure revoke_permission
create or replace function cms_permission__revoke_permission 
(integer,integer,varchar,integer,varchar)
returns integer as '
declare
  p_item_id                        alias for $1;
  p_holder_id                      alias for $2;
  p_privilege                      alias for $3;
  p_revokee_id                     alias for $4;
  p_is_recursive                   alias for $5;  -- default ''f''
  -- v_items                          item_array_type;
  v_item_id                        cr_items.item_id%TYPE;
  v_idx                            integer;
  v_count                          integer;
  -- v_perms                          perm_array_type;
  v_perm                           acs_privileges.privilege%TYPE;
  v_perm_idx                       integer;
  v_perm_count                     integer;
  c_perm_cur                       record;
  c_item_cur                       record;
begin

    PERFORM update_permissions(p_item_id, p_is_recursive);

    -- Select the child permissions
    v_perm_count := 0;
    for c_perm_cur in
     select
        child_privilege
      from
        acs_privilege_hierarchy
      where
        privilege = p_privilege
      and
        child_privilege <> p_privilege
    LOOP
      v_perm := c_perm_cur.child_privilege;
   v_perm_count := v_perm_count + 1;
      -- v_perms(v_perm_count) := v_perm;
      update v_perms set value[v_perm_count] = v_perm;
    end LOOP;

    -- Select child items
    v_count := 0;
    for c_item_cur in
     select c1.item_id from cr_items c1, cr_items c2
     where c2.item_id = p_item_id
       and c1.tree_sortkey between c2.tree_sortkey and 
tree_right(c2.tree_sortkey)
      and
        cms_permission__has_revoke_authority (
          item_id,
          p_holder_id,
          p_privilege,
          p_revokee_id
        ) = ''t''
      and
        acs_permission__permission_p (
          item_id,
          p_revokee_id,
          p_privilege
        ) = ''t''
    LOOP
      v_item_id := c_item_cur.item_id;
      v_count := v_count + 1;
      -- v_items(v_count) := v_item_id;
      update v_items set value[v_count] = v_item_id;
      exit when p_is_recursive = ''f'';
    end loop;

    if v_count < 1 then
      return;
    end if;

    -- Grant child permissions
    for v_idx in 1..v_count loop
      for v_perm_idx in 1..v_perm_count loop
        PERFORM acs_permission__grant_permission (
          -- v_items(v_idx), p_revokee_id, v_perms(v_perm_idx)
          v_items.value[v_idx], p_revokee_id, v_perms.value[v_perm_idx]
    );
       end loop;
    end loop;

    -- Revoke the parent permission
    for v_idx in 1..v_count loop
      PERFORM acs_permission__revoke_permission (
        -- v_items(v_idx),
        v_items.value[v_idx],
        p_revokee_id,
        p_privilege
      );
    end loop;

    return 0;
end;' language 'plpgsql';




view thread (5+ messages)  latest in thread

Message-ID: <4B7E4331.1050308@gmail.com>
Permalink:  ../4B7E4331.1050308@gmail.com/
Also on:    postgresql.org/message-id/4B7E4331.1050308@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: iuri.sampaio@gmail.com
  Subject: Re: sintax error
  In-Reply-To: <4B7E4331.1050308@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox