Re: Stored Procedures and Functions

From: PFC <lists(at)peufeu(dot)com>
To: "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: Stored Procedures and Functions
Date: 2007-06-02 16:32:20
Message-ID: op.ttayv6e4cigqcu@apollo13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

MySQL supports procedures and functions.

Functions can return results but cannot update the database.
Procedures can update the database but cannot return results.

However :
- a function can call a procedure that updates the database !
- a procedure can return result through OUT parameters !

It's a friggin mess. In pgsql, if you want, a STABLE or IMMUTABLE
procedure is a function since it is repeatable : it will always return the
same results with the same parameters, and has no side-effects. This is
the definition of a function.

It is better not to draw useless lines in the ground with huge "don't
walk over this line" stickers. People will always find a way around.
Better offer features that users need.

>> 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.
>
> Pascal has functions and procedures. C has only functions. That doesn't
> say anything about the relative usability of each language. Those are
> just names.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Erwin Brandstetter 2007-06-02 16:39:47 Re: There can be only one! How to avoid the "highlander-problem".
Previous Message Dawid Kuroczko 2007-06-02 16:31:19 Re: Transactional DDL