Re: Stored Procedures and Functions - Mailing list pgsql-general

From Albe Laurenz
Subject Re: Stored Procedures and Functions
Date
Msg-id AFCCBB403D7E7A4581E48F20AF3E5DB203302171@EXADV1.host.magwien.gv.at
Whole thread Raw
In response to Stored Procedures and Functions  ("Harpreet Dhaliwal" <harpreet.dhaliwal01@gmail.com>)
List pgsql-general
Harpreet Dhaliwal wrote:

> Is it true that postgres doesn't have a notion of Stored
> Procedures and functions is what it has instead?
> RDBMS like Sql Server supports both stored procedures and functions.
> So I was wondering what is the difference between a Stored
> Procedure and a function.

I think that your questions have not been answered yet.

Yes, it is true, PostgreSQL doesn't have procedures, only functions.

The difference between a function and a procedure is that the former
has a return value, while the latter does not. Procdures can hand back
results via output parameters.

The lack of procedures in PostgreSQL is mitigated by the fact that you
can achieve everything you need with a function:

- If you don't need to return results at all, you define a function
  with return type "void" (which means that nothing is returned).

- If you need to return more than one result, you can define a
  function with a composite return type (or equivalently with
  what PostgreSQL calls "output parameters").

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: "Islam Hegazy"
Date:
Subject: Re: debugging C functions
Next
From: Klint Gore
Date:
Subject: changing 'mons' in interval?