Обсуждение: how to execute a stored function that returns a boolean?

Поиск
Список
Период
Сортировка

how to execute a stored function that returns a boolean?

От
"J.V."
Дата:
I have created a stored function and wish to execute in pgadmin but keep
getting an error.

create or replace function myfunc() returns boolean
as $$
declare
begin
...
end;
$$ language plpgsql;

compiles and works just find, however when I run (in pgadmin III)

select myfunc();

I get errors telling me I need to use 'perform' instead, but when I run:

perform myfunc(); it says : syntax error at or near "perform"
LINE 1: perform myfunc();



Re: how to execute a stored function that returns a boolean?

От
Raymond O'Donnell
Дата:
On 27/04/2012 20:43, J.V. wrote:
> I have created a stored function and wish to execute in pgadmin but keep
> getting an error.
>
> create or replace function myfunc() returns boolean
> as $$
> declare
> begin
> ...
> end;
> $$ language plpgsql;
>
> compiles and works just find, however when I run (in pgadmin III)
>
> select myfunc();
>
> I get errors telling me I need to use 'perform' instead, but when I run:

Can you show us the rest of your function? In pl/pgsql, you use PERFORM
instead of SELECT when you don't need the result of a query; you
probably have a SELECT in there somewhere.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

Re: how to execute a stored function that returns a boolean?

От
Merlin Moncure
Дата:
On Fri, Apr 27, 2012 at 2:43 PM, J.V. <jvsrvcs@gmail.com> wrote:
> I have created a stored function and wish to execute in pgadmin but keep
> getting an error.
>
> create or replace function myfunc() returns boolean
> as $$
> declare
> begin
> ...
> end;
> $$ language plpgsql;
>
> compiles and works just find, however when I run (in pgadmin III)
>
> select myfunc();
>
> I get errors telling me I need to use 'perform' instead, but when I run:


that error is being thrown from indie the function.  somewhere inside
the function body you are using select where you should be using
perform.

> perform myfunc(); it says : syntax error at or near "perform"
> LINE 1: perform myfunc();

perform only makes sense inside functions. it has not meaning except inside sql.

merlin