From: | Uros Gruber <uros(at)sir-mag(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | don't know how to get SELECT |
Date: | 2002-05-13 14:54:16 |
Message-ID: | 9280206080.20020513165416@sir-mag.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi!
i have some problems with plpgsql. Here is my function
create or replace function rm_cat(varchar,int) returns boolean as '
declare
table alias for $1;
id alias for $2;
data RECORD;
begin
******************************************************************
SELECT INTO data lft,rgt FROM d_categories WHERE id_category=id;
******************************************************************
IF NOT FOUND THEN
RAISE EXCEPTION ''id % does not exist'',id;
return 0;
end if;
-- deleting the leftmost node does not lower lft for all
execute ''update '' || quote_ident(table) || '' set level=level-1 where lft > '' || data.lft || ''and rgt < '' || data.rgt || '';'';
execute ''update '' || quote_ident(table) || '' set lft=lft-1 where lft >= '' || data.lft || '';'';
execute ''update '' || quote_ident(table) || '' set lft=lft-1 where lft >= '' || data.rgt || '';'';
execute ''update '' || quote_ident(table) || '' set rgt=rgt-1 where rgt >= '' || data.lft || '';'';
execute ''update '' || quote_ident(table) || '' set rgt=rgt-1 where rgt >= '' || data.rgt || '';'';
execute ''delete from '' || quote_ident(table) || '' where id_category = '' || id || '';'';
return 1;
end;
'language 'plpgsql';
My problems is in line wraped with ***. What i want is that
SELECT have to be dinamyc because i want with an argument to
saj for what table do this select. I tried many ways and i
think i don't understand something. Can somebody help me
solve this.
--
bye,
Uros mailto:uros(dot)gruber(at)sir-mag(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2002-05-13 15:00:23 | Re: can Function return a row ??? |
Previous Message | Jérôme Tollet | 2002-05-13 14:53:34 | INT UNSIGNED problem |