Re: function source code not returning from inside a pgsql function.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Herwig Goemans <herwig(dot)goemans(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: function source code not returning from inside a pgsql function.
Date: 2017-02-09 16:44:46
Message-ID: CAKFQuwaTXC1jbhhP31uwN3bdU=1DVuUo=Ja_Z-8D4qFG2HwobQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Feb 9, 2017 at 9:39 AM, Herwig Goemans <herwig(dot)goemans(at)gmail(dot)com>
wrote:

> Hello,
>
> I have a function in a punlic schema and in psql when I do:
> pg_get_functiondef(oid) from pg_proc where proname = 'xtm_doc_ref';
> I get a result.
> When I do the same in a function:
> CREATE OR REPLACE FUNCTION tm.alter_tbl(
> p_id integer,
> p_type character varying,
> p_lang character varying)
> RETURNS void
>
> ​[...]

> And I call the function with :
> TM=# select alter_tbl('xtm_2_fr_nl_doc');
> NOTICE: input parameters result in xtm_2_fr_nl_doc
> NOTICE: probleem
> alter_tbl
> -----------
>
> (1 row)
> The source code is not fetched.
> the function the public schema is a template for another function that I
> want to create in the TM schema.
> I suppose this has something to do with pgsql nit having acces to public
> schema ?
> Is there something that can be done about it ?
>

You've defined the function as RETURNING void -- which says you don't
intend to return anything to the caller.

You need to redefine the function and then explicitly return whatever
content it is you wish to return - per the documentation at:

​​
https://www.postgresql.org/docs/9.6/static/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2017-02-09 16:57:58 Re: function source code not returning from inside a pgsql function.
Previous Message Herwig Goemans 2017-02-09 16:39:19 function source code not returning from inside a pgsql function.