By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,587 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

I'm writing a function which uses cursor and I have an error when executing it

P: 61
when executing the function as follow:
select get_pms_meeting_minute (null)

I get the follwing message:
set-valued function called in context that cannot accept a set

Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE TABLE pms_meeting_minutes
  3. (
  4.   id_meeting_minutes integer NOT NULL,
  5.   location character varying(50),
  6.   date_meeting date,
  7.   time_meeting time without time zone,
  8.   responsible integer,
  9.   name_meeting_minute character varying(50),
  10.   CONSTRAINT pk_pms_meeting_minutes PRIMARY KEY (id_meeting_minutes));
  11.  
  12.  
  13. create function get_pms_meeting_minute (integer) RETURNS SETOF RECORD AS'
  14.  
  15. DECLARE 
  16.     ret_row RECORD;    
  17.  
  18. BEGIN
  19.     IF $1 IS NULL THEN
  20.       FOR ret_row IN SELECT *
  21.                      FROM pms_meeting_minutes
  22.       LOOP
  23.         RETURN NEXT ret_row;
  24.       END LOOP;
  25.  
  26.     ELSE
  27.        IF $1 IS NOT NULL THEN
  28.          FOR ret_row IN SELECT  * 
  29.                         FROM pms_meeting_minutes
  30.                         WHERE id_meeting_minutes = $1
  31.          LOOP
  32.            RETURN QUERY;
  33.          END LOOP;  
  34.        END IF;
  35.     END IF;
  36. END;'
  37.  
  38. LANGUAGE 'plpgsql'; 
  39.  
Sep 7 '10 #1

✓ answered by rski

Maybe try calling it like that
Expand|Select|Wrap|Line Numbers
  1. select * from get_pms_meeting_minute (null);
  2.  

Share this Question
Share on Google+
2 Replies


Expert 100+
P: 700
Maybe try calling it like that
Expand|Select|Wrap|Line Numbers
  1. select * from get_pms_meeting_minute (null);
  2.  
Sep 13 '10 #2

P: 61
thanks a lot
it works now.
Sep 14 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.