Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Novice > Function proble...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 3025 of 3163
Post > Topic >>

Function problem after alter table

by srd1@[EMAIL PROTECTED] (Sean Dooley) Mar 3, 2008 at 12:15 PM

Hi,
I have a function as defined as so...

===========

CREATE OR REPLACE FUNCTION getitemdates(in_item_id integer) RETURNS 
SETOF item_date
     AS $$
DECLARE
	resultset RECORD;
	old_path text;
BEGIN
	old_path := pg_catalog.current_setting('search_path');
	PERFORM pg_catalog.set_config('search_path', 'public, pg_temp', true);
	FOR RESULTSET IN	
		SELECT * FROM item_date WHERE item_id = in_item_id
	LOOP
		RETURN NEXT resultset;
	END LOOP;

	PERFORM pg_catalog.set_config('search_path', old_path, true);

END;
$$
     LANGUAGE plpgsql STABLE SECURITY DEFINER;

===========


This works fine, returns all the matching data from item_date

However, if I alter the table item_date, for example

ALTER TABLE item_date ADD COLUMN foo text;

When I run the function now, I get the error

ERROR:  wrong record type supplied in RETURN NEXT
CONTEXT:  PL/pgSQL function "getitemdates" line 10 at return next

It seems the item_date rowtype isn't being updated when the item_date 
table is altered. If I then drop the added column, I still get the error 
message. The procedure has completely broken.

Any ideas where I am going wrong?
Thanks,
Sean

--
Sent via pgsql-novice mailing list (pgsql-novice@[EMAIL PROTECTED]
)
To make changes to your Subscription:
http://mail.postgresql.org/mj/mj_wwwusr?domain=postgresql.org&extra=pgsql-novice
 




 5 Posts in Topic:
Function problem after alter table
srd1@[EMAIL PROTECTED] (  2008-03-03 12:15:08 
Re: Function problem after alter table
tgl@[EMAIL PROTECTED] (T  2008-03-03 16:40:33 
SQL Question
joshua@[EMAIL PROTECTED]   2008-03-03 16:21:06 
Re: SQL Question
vka@[EMAIL PROTECTED] (&  2008-03-04 02:06:50 
Re: SQL Question
vka@[EMAIL PROTECTED] (&  2008-03-04 12:51:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Tue Jul 8 23:39:59 CDT 2008.