Re: How can I test a function in the SQL window?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Rob Richardson <RDRichardson(at)rad-con(dot)com>
Cc: "pgadmin-support(at)postgresql(dot)org" <pgadmin-support(at)postgresql(dot)org>
Subject: Re: How can I test a function in the SQL window?
Date: 2015-04-02 17:17:58
Message-ID: CAKFQuwarhDn7QL1sf83uSBHXUBDirhcS2tou=9SqmXec3zFLRA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

On Thu, Apr 2, 2015 at 10:02 AM, Rob Richardson <RDRichardson(at)rad-con(dot)com>
wrote:

> Hello!
>
>
>
> I suddenly find myself stumped. A co-worker gave me a function to use in
> my database, but it doesn’t seem to be doing anything. So, I wanted to run
> it from PGAdmin’s SQL window. But I can’t call it. When I try
>
>
>
> select standupdatestatus('12', 'Loaded', 100);
>
>
>
> I get:
>
>
>
> 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 standupdatestatus(text,text,integer) line 44
> at SQL statement
>
> ********** Error **********
>
>
>
> ERROR: query has no destination for result data
>
> SQL state: 42601
>
> Hint: If you want to discard the results of a SELECT, use PERFORM instead.
>
> Context: PL/pgSQL function standupdatestatus(text,text,integer) line 44 at
> SQL statement
>
>
>

​The error is telling you that the query at line 44 inside your function
either needs to be called using PERFORM or needs be modified to output its
result somewhere (INTO variable; FOR record IN SELECT​; etc...)​ or cause
the query result to be returned from the function using RETURN QUERY.

> When I try
>
>
>
> perform standupdatestatus('12', 'Loaded', 100);
>
>
>
> I get:
>
>
>
> ERROR: syntax error at or near "perform"
>
> LINE 1: perform standupdatestatus('12', 'Loaded', 100);
>
> ^
>
>
>
​See my first comment. PERFORM is a pl/pgsql command, not an SQL one. In
SQL you only ever use SELECT and the results always have a destination -
the client. Since functions are black-boxes there is no "client" to send
plain query results back to so you either need to do something with them or
indicate you are executing the statement solely for its side effects - via
PERFORM.

David J.

In response to

Responses

Browse pgadmin-support by date

  From Date Subject
Next Message Leonard Boyce 2015-04-02 18:16:19 Re: How can I test a function in the SQL window?
Previous Message Raymond O'Donnell 2015-04-02 17:12:04 Re: How can I test a function in the SQL window?