How to cal function in in another function

From: "VivekanandaSwamy R(dot)" <VivekanandaSwamyr(at)infics(dot)com>
To: <pgadmin-support(at)postgresql(dot)org>
Cc: <pgsql-admin-owner(at)postgresql(dot)org>
Subject: How to cal function in in another function
Date: 2006-06-28 08:53:16
Message-ID: A70AE049E81A6A40879D5DC0AC8C38C9068C7FA4@venus.infics.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support pgsql-admin


Hi,
i have written these functions....,please go through this...

table emp: It contains

empno ename mgr sal dept
------------------------------------------------------------------------
-
22 swarna 23 2600 20

Now i wrote function(sub function)

create or replace function subfun1(int8,out p_mgr int8,out p_name
varchar) as
'
begin
select ename,mgr into p_name,p_mgr from emp where empno=$1 ;
end;
'
language'plpgsql';

When i executing this function,it returns like....
select subfun1(22); returns (23,swarna) as record type

Now i want use/call this function in main function

create or replace function mainfun(int8,out p_sal int8,out p_dept
varchar) as
'
declare
no record;
begin
select subfun1($1) into no;
select sal,dept into p_sal,p_dept from emp where mgr=no.p_mgr limit 1;
end;
'
language'plpgsql';

Now when i am executing this function like....

select mainfun(22); returns error message like....

ERROR: record "no" has no field "p_mgr"
CONTEXT: PL/pgSQL function "mainfun" line 5 at select into
variables

So,how to solve this problem?

Thanks & Regards

Vivekananda.R | Software Engineer

Infinite Computer Solutions | Exciting Times...Infinite Possibilities...

SEI-CMMI level 5 | ISO 9001:2000

Tel +91-80-5193-0000| Fax +91-80-51930009 | Cell No
+91-9986463365|www.infics.com

Information transmitted by this e-mail is proprietary to Infinite Computer Solutions and / or its Customers and is intended for use only by the individual or the entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at info(dot)in(at)infics(dot)com and delete this email from your records.

Browse pgadmin-support by date

  From Date Subject
Next Message Sébastien Lardière 2006-06-29 10:10:02 Re: pgadmin and red hat enterprise 4
Previous Message VivekanandaSwamy R. 2006-06-28 08:28:23 How to install ODBC driver

Browse pgsql-admin by date

  From Date Subject
Next Message Chris Hoover 2006-06-28 14:24:17 Re: 8.1.3 - autovacuum question
Previous Message Jim C. Nasby 2006-06-28 04:47:38 Re: 8.1.3 - autovacuum question