pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedINOUT PARAMETERS WITH RETURN TABLES IN FUNCTION
4+ messages / 3 participants
[nested] [flat]
* INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION
@ 2019-11-08 08:18 İlyas Derse <ilyasderse@gmail.com>
2019-11-08 12:40 ` Re: INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION Thomas Kellerer <spam_eater@gmx.net>
2019-11-08 15:25 ` Re: INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 2 replies; 4+ messages in thread
From: İlyas Derse @ 2019-11-08 08:18 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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.
Its like ;
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 ?
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION
2019-11-08 08:18 INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION İlyas Derse <ilyasderse@gmail.com>
@ 2019-11-08 12:40 ` Thomas Kellerer <spam_eater@gmx.net>
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Kellerer @ 2019-11-08 12:40 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
İ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.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION
2019-11-08 08:18 INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION İlyas Derse <ilyasderse@gmail.com>
@ 2019-11-08 15:25 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-11-14 15:45 ` Re: INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 1 reply; 4+ messages in thread
From: Adrian Klaver @ 2019-11-08 15:25 UTC (permalink / raw)
To: İlyas Derse <ilyasderse@gmail.com>; pgsql-general@lists.postgresql.org
On 11/8/19 12:18 AM, İlyas Derse wrote:
> 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.
Can you show an example of a SQL Server procedure that demonstrates what
you want to achieve?
>
> Its like ;
>
> 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 ?
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION
2019-11-08 08:18 INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION İlyas Derse <ilyasderse@gmail.com>
2019-11-08 15:25 ` Re: INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION Adrian Klaver <adrian.klaver@aklaver.com>
@ 2019-11-14 15:45 ` Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 4+ messages in thread
From: Adrian Klaver @ 2019-11-14 15:45 UTC (permalink / raw)
To: İlyas Derse <ilyasderse@gmail.com>; +Cc: pgsql-general
On 11/13/19 11:58 PM, İlyas Derse wrote:
Please reply to list also.
Ccing list.
> I want to do like this ;
I can't make sense of the below. I don't see where "x" and "y" are used
in the function, unless they supposed to be "id" and "filesize". I have
no idea what the QUERY is doing? Pretty sure you don't want an
unconstrained select on a table. Can you provide a working example of
what you are doing in SQL Server with sample output from same?
>
> |CREATEorREPLACE FUNCTIONpublic."test"(INOUT "x"integer,INOUT
> "y"text)RETURNS TABLE("id"integer,"filesize"character
> varying(36))AS$$BEGINRETURNQUERY
> SELECT*FROMpublic."tbl_employees";END;$$LANGUAGE plpgsql;|
>
> |I need to call table and inout parameters together at another place.|
>
>
> Adrian Klaver <adrian.klaver@aklaver.com
> <mailto:adrian.klaver@aklaver.com>>, 8 Kas 2019 Cum, 18:25 tarihinde
> şunu yazdı:
>
> On 11/8/19 12:18 AM, İlyas Derse wrote:
> > 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.
>
> Can you show an example of a SQL Server procedure that demonstrates
> what
> you want to achieve?
>
> >
> > Its like ;
> >
> > 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 ?
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2019-11-14 15:45 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 08:18 INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION İlyas Derse <ilyasderse@gmail.com>
2019-11-08 12:40 ` Thomas Kellerer <spam_eater@gmx.net>
2019-11-08 15:25 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-11-14 15:45 ` Adrian Klaver <adrian.klaver@aklaver.com>
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