Re: Return Table in StoredProceure/Function

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tony Shelver <tshelver(at)gmail(dot)com>
Cc: Thomas Kellerer <spam_eater(at)gmx(dot)net>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Return Table in StoredProceure/Function
Date: 2019-11-21 06:44:40
Message-ID: CAFj8pRBNpSa=977380VvV9c6z7gXZdeSAhsKmtqdfWyo1RC_eA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

čt 21. 11. 2019 v 7:34 odesílatel Tony Shelver <tshelver(at)gmail(dot)com> napsal:

> Well then SQL Server breaks that rule big time :)
> Most people coming from a SQL Server background expect procedures to
> return a result set that can be queried, and in-out or out parameters to
> return variables for further information.
>

yes, SQL server is absolutely unique in this case. Oracle, DB2, and
Postgres has different design

If you have SQL Server background, and you would to write stored
procedures, start with doc, please
https://www.postgresql.org/docs/current/plpgsql.html

lot of things are really different. Postgres SQL, stored procedures are
close to Oracle, and very far to T-SQL

Regards

Pavel

>
>
> On Wed, 20 Nov 2019 at 17:20, Thomas Kellerer <spam_eater(at)gmx(dot)net> wrote:
>
>> İlyas Derse schrieb am 20.11.2019 um 09:18:
>>
>> > How can I return table in Stored Procedure ? I can do it in function
>> but I
>> > have inout parameters.So I can not create in function. What can I do
>> this
>> > case ?
>> >
>> > I guess,It should be like for function :
>> >
>> > CREATE or REPLACE FUNCTION public."test" (INOUT "x" integer, INOUT "y"
>> text)
>> >
>> > RETURNS TABLE ("id" integer,"filesize" character varying(36))AS $$
>> > BEGINRETURN QUERYSELECT * FROM public."tbl_employees" ;
>> > END;$$ LANGUAGE plpgsql;
>> >
>>
>> Procedures aren't meant to return anything (in Postgres specifically and
>> in Computer Science in general).
>>
>> If you want to return something use a function.
>>
>>
>>
>>
>>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Matthias Apitz 2019-11-21 07:12:17 deep debug log for psql
Previous Message Tony Shelver 2019-11-21 06:33:46 Re: Return Table in StoredProceure/Function