Re: Stored Procedures and Functions

From: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
To: "Harpreet Dhaliwal *EXTERN*" <harpreet(dot)dhaliwal01(at)gmail(dot)com>, "Postgres General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Stored Procedures and Functions
Date: 2007-06-04 07:18:26
Message-ID: AFCCBB403D7E7A4581E48F20AF3E5DB203302171@EXADV1.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John Gardner 2007-06-04 08:49:03 Tablespaces
Previous Message Sergei Shelukhin 2007-06-04 06:29:07 Re: insane index scan times