[HELP] Defining a function as a procedure

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

[HELP] Defining a function as a procedure

От:
"Daniel Caune" <daniel.caune@ubisoft.com>
Дата:

Hi,

 

Is there a way to define a function as a procedure, I mean a function that returns nothing.

 

CREATE OR REPLACE FUNCTION foo(<in-parameters>)

AS $$

BEGIN

  <update-some-tables>

END;

$$ LANGUAGE 'plpgsql';

 

Actually, PostgreSQL complains as a “function result type must be specified”.  I can patch my function so that it compiles but that won’t be really nice:

 

CREATE OR REPLACE FUNCTION foo(<in-parameters>)

  RETURNS int

AS $$

BEGIN

  <update-some-tables>

  RETURN 1;

END;

$$ LANGUAGE 'plpgsql';

 

Is there any other prettier way to do that?

 

Thanks,

 

 

--

Daniel

 

Re: [HELP] Defining a function as a procedure

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Daniel Caune"  writes:
> Is there a way to define a function as a procedure, I mean a function
> that returns nothing.

In recent versions you can say RETURNS VOID, which is a bit of a hack
but it gets the point across...
		regards, tom lane

FAQ