dbTalk Databases Forums  

Function error

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Function error in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Vishal Kashyap @ [Sai Hertz And Control Systems]
 
Posts: n/a

Default Function error - 10-26-2004 , 12:35 PM






Dear PostgreSQL enlightened ,

I have an error with this function can anyone suggest me what stupid
thing am i doing

<code>
create type_a as (mnthtot numeric(20,2),monthtxt varchar(20));

CREATE OR REPLACE FUNCTION "public"."func_ca" () RETURNS "public"."type_a" AS'
DECLARE
f_type_a type_a%ROWTYPE;
f_data record;
f_year int8;
f_month int8;
BEGIN
f_year := 2004 ;--hard coded for year 2004-2005
f_month := 4 ;--hard coded for year 2004-2005
f_type_a.mnthtot := 0;-- Month total
f_type_a.monthtxt:= ''MONTH''::varchar;-- Month text
for f_data IN select sum(cust_wdrwl_amt) as total,4 as month from
cust_lon_dtls where (select extract(MONTHS from
cust_lon_dtls.curr_rn_dt)) = f_month AND (select extract(YEARS from
cust_lon_dtls.curr_rn_dt)) = f_year
LOOP
f_type_a.mnthtot := f_data.total;
f_type_a.monthtxt := (f_data.month || ''MONTH'')::varchar;
f_month := f_month + 1;
IF f_month = 13 THEN
f_month := 1 ;
f_year := 2005;
elsif f_month = 5 AND f_year = 2005 THEN
return f_type_a;
END IF;
END LOOP;
return f_type_a;
END;
'LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
</code>


The error is

somedata =# select sai_func_ca();
ERROR: cannot display a value of type record




--
With Best Regards,
Vishal Kashyap.
Did you know SaiPACS is one and only PACS
Management tool.
http://saihertz.com

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: Function error - 10-26-2004 , 01:13 PM






"Vishal Kashyap @ [Sai Hertz And Control Systems]" <vishalonlist (AT) gmail (DOT) com> writes:
Quote:
CREATE OR REPLACE FUNCTION "public"."func_ca" () RETURNS "public"."type_a" AS'
...
somedata =# select sai_func_ca();
ERROR: cannot display a value of type record
Try
select * from sai_func_ca();

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
  #3  
Old   
Vishal Kashyap @ [Sai Hertz And Control Systems]
 
Posts: n/a

Default Re: Function error - 10-26-2004 , 01:35 PM



Dear Tom


Quote:
...
somedata =# select sai_func_ca();
ERROR: cannot display a value of type record

Try
select * from sai_func_ca();

I knew I was doing something stupid, today was not my day definatly.
Anyways thanks Tom.

--
With Best Regards,
Vishal Kashyap.
Did you know SaiPACS is one and only PACS
Management tool.
http://saihertz.com

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.