Skip site navigation (1) Skip section navigation (2)

Re: query has no destination for result data

From: Alan Hodgson <ahodgson(at)simkin(dot)ca>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: query has no destination for result data
Date: 2010-04-26 16:31:05
Message-ID: (view raw or whole thread)
Lists: pgsql-novice
On Friday 23 April 2010, Patta <pmuthuz(at)gmail(dot)com> wrote:
> Hi,
> I'm a beginner in postgresql. I get the below error. Could you help me
> to fix this one?
> ERROR:  query has no destination for result data
> HINT:  If you want to discard the results of a SELECT, use PERFORM
> instead. CONTEXT:  PL/pgSQL function "insertcommjunction1" line 7 at SQL
> statement
> The function is as follows.
>   RETURNS text AS
> $BODY$
>      query_rec record;
>      idxfti tsvector;
>      c1 cursor for select * from <table>;
> Begin
> open c1;
> Loop
> fetch c1 into query_rec;
> begin
> raise notice 'Record %', query_rec.field1;
> end;
> End loop;
> Return 'ok';
> end;
> $BODY$
>   LANGUAGE 'plpgsql' VOLATILE;

Just do something like:

FOR  query_rec IN SELECT * FROM <table> 
     ... actions

pl/pgsql will use a cursor internally without you worrying about it.

"No animals were harmed in the recording of this episode. We tried but that 
damn monkey was just too fast."

In response to

pgsql-novice by date

Next:From: Tom LaneDate: 2010-04-26 16:36:41
Subject: Re: install both i386 and x86_64 libs
Previous:From: Atif JungDate: 2010-04-26 11:37:45
Subject: sqlhdr.h

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group