pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: İlyas Derse <ilyasderse@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION
Date: Thu, 14 Nov 2019 07:45:34 -0800
Message-ID: <0a7f4566-8b1b-3847-bcd8-6e94f50c0ee3@aklaver.com> (raw)
In-Reply-To: <CALcdmyQp2GKSj=cOC1y5vzmaAoN_JnpaWk-Uh5cGKYjHNQh08g@mail.gmail.com>
References: <CALcdmyQ52ULgGcr706HQHoz9uOoVmGmgf245YauB6j61KKJ_Pw@mail.gmail.com>
	<f9d3d852-c03f-2d62-1eb8-0fd8692b9930@aklaver.com>
	<CALcdmyQp2GKSj=cOC1y5vzmaAoN_JnpaWk-Uh5cGKYjHNQh08g@mail.gmail.com>

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





view thread (4+ messages)

Message-ID: <0a7f4566-8b1b-3847-bcd8-6e94f50c0ee3@aklaver.com>
Permalink:  ../0a7f4566-8b1b-3847-bcd8-6e94f50c0ee3@aklaver.com/
Also on:    postgresql.org/message-id/0a7f4566-8b1b-3847-bcd8-6e94f50c0ee3@aklaver.com

 · 

reply

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: adrian.klaver@aklaver.com, ilyasderse@gmail.com
  Subject: Re: INOUT PARAMETERS WITH RETURN TABLES IN FUNCTION
  In-Reply-To: <0a7f4566-8b1b-3847-bcd8-6e94f50c0ee3@aklaver.com>
  References: <CALcdmyQ52ULgGcr706HQHoz9uOoVmGmgf245YauB6j61KKJ_Pw@mail.gmail.com> <f9d3d852-c03f-2d62-1eb8-0fd8692b9930@aklaver.com> <CALcdmyQp2GKSj=cOC1y5vzmaAoN_JnpaWk-Uh5cGKYjHNQh08g@mail.gmail.com> <0a7f4566-8b1b-3847-bcd8-6e94f50c0ee3@aklaver.com>

* 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