From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION
Date: Fri, 8 Nov 2019 13:40:27 +0100
Message-ID: <0dd3d441-42f8-daf6-7549-2bde894a3af1@gmx.net> (raw)
In-Reply-To: <CALcdmyQ52ULgGcr706HQHoz9uOoVmGmgf245YauB6j61KKJ_Pw@mail.gmail.com>
References: <CALcdmyQ52ULgGcr706HQHoz9uOoVmGmgf245YauB6j61KKJ_Pw@mail.gmail.com>
İlyas Derse schrieb am 08.11.2019 um 09:18:
> I'm trying to migration to PostgreSql from SQL Server. I have Stored Procedures what have output parameters and return tables. How can i do both together.
>
> CREATE or replace FUNCTION public."test" (INOUT "x" integer, INOUT "y" character varying(36))
> RETURNS TABLE (
> "id" integer,
> "filesize" character varying(36)
> )
> AS $$
> BEGIN
> x=6;
> RETURN QUERY
> SELECT * FROM public."tbl_employees" ;
>
> END;
> $$ LANGUAGE plpgsql;
>
> I can not create that because of inout parameters.
> Another place;
>
> do $$
> DECLARE b integer = 1;
> DECLARE d integer = 2 ;
> BEGIN
> select * from public."test"();
> END;
> $$;
>
> Anybody have an idea ?
Can't you just include the "out" parameters in the result?
CREATE or replace FUNCTION public.test(x integer, y character varying(36))
RETURNS TABLE (id integer, filesize character varying(36), x integer, y varchar)
AS $$
begin
x := 42;
y := 'foo';
RETURN QUERY
SELECT t.*, x, y
FROM public.tbl_employees t;
END;
It's different because x and y are repeated for every row, but that's the only thing I can think of.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: spam_eater@gmx.net
Subject: Re: INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION
In-Reply-To: <0dd3d441-42f8-daf6-7549-2bde894a3af1@gmx.net>
References: <CALcdmyQ52ULgGcr706HQHoz9uOoVmGmgf245YauB6j61KKJ_Pw@mail.gmail.com> <0dd3d441-42f8-daf6-7549-2bde894a3af1@gmx.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox