Re: Giving error for function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sachin Srivastava <ssr(dot)teleatlas(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Giving error for function
Date: 2016-01-12 15:29:22
Message-ID: 4361.1452612562@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sachin Srivastava <ssr(dot)teleatlas(at)gmail(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-01-12 15:44:14 Re: Text parameter is treated as sql query in postgresql function
Previous Message Adrian Klaver 2016-01-12 15:06:30 Re: PostgreSQL upgrade 9.3.4 -> 9.3.10