Re: Giving error for function - Mailing list pgsql-general

From Tom Lane
Subject Re: Giving error for function
Date
Msg-id 4361.1452612562@sss.pgh.pa.us
Whole thread Raw
In response to Giving error for function  (Sachin Srivastava <ssr.teleatlas@gmail.com>)
List pgsql-general
Sachin Srivastava <ssr.teleatlas@gmail.com> writes:
> I am getting the below error while I am running the below function
> "add_po_doc_hist", for "c_company" cursor, please suggest what is wrong
> with code.
> ERROR:  relation "c_company" does not exist
> CONTEXT:  compilation of PL/pgSQL function "add_po_doc_hist" near line 11

> CREATE OR REPLACE FUNCTION add_po_doc_hist(subscriberid bigint)
>   RETURNS void AS
> $BODY$
> DECLARE
> --Select All Companies for the subscriber entered
> c_company CURSOR FOR
>                 SELECT company_id
>                 from PSM_COMPANY_PROFILE
>                 where is_BUYER = 1
>   and subscriber_id=subscriberID;
> v_company c_company%ROWTYPE;

The error is pointing you here.  I believe the problem is that c_company
is a cursor, not a table, and as such can't be referenced with %rowtype.

I think you could just use RECORD instead ...

            regards, tom lane


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: PostgreSQL upgrade 9.3.4 -> 9.3.10
Next
From: Adrian Klaver
Date:
Subject: Re: Text parameter is treated as sql query in postgresql function