Re: Newbie questions, diff between functions and

From: "Milen A(dot) Radev" <milen(at)radev(dot)net>
To: pgadmin-support(at)postgresql(dot)org
Subject: Re: Newbie questions, diff between functions and
Date: 2006-11-26 03:58:36
Message-ID: 456910EC.40206@radev.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

novnov написа:
> I am still very confused by pgsql's approach to functions vs procedures.
>
> In my testing using pgAdmin III, if I create both In and Out args it's
> listed as a proc. If I add only a In or only an Out, both are listed as
> functions and the args are 'gone'. Does that make sense?
>
> I am puzzled by the fact that I don't find many references to 'stored
> procedures' in the pgsql docs. One of the oft heard reasons to chose pgsql
> over mysql is the supposed presence of stored procedures.

Well, stored procedures in Postgres are implemented as server-side
functions (that could be written in several different languages). They
are discussed at length in chapter 35 ("Procedural Languages") and the
subsequent chapters.

>
> The kind of use I have for stored procedures is to pass in a couple params,
> use them in an append or update query, possibly call other procedures, and
> return some value (success etc).
>
> Thomas wrote that the IN OUT INOUT arg stuff is as of 8.1, that's the
> current stable version of pgsql...but pgsql has supposedly had stored
> procedures for a long time. It ends up being very confusing to a newbie.
[...]

Yes, the functions (stored procedures) have very long history in
Postgres (unlike some other well-known DBMS). The addition that confuses
you, namely the argument mode (IN, OUT, INOUT), is very recent - they
were introduced in version 8.1.

A functions takes 0 or more parameters and returns a value. Most people
would argue that a procedure is special case for a function that returns
nothing (void, none, null). Sometimes it's useful for a function to
return more than one value. There are several ways to achieve this - one
is to introduce the OUT and INOUT parameters.

I consider the decision to distinguish between functions and procedures
in pgAdmin's UI very unfortunate.

--
Milen A. Radev

In response to

Responses

Browse pgadmin-support by date

  From Date Subject
Next Message Joost Kraaijeveld 2006-11-26 11:21:11 vacuum tip question
Previous Message novnov 2006-11-26 02:07:16 Re: Newbie questions, diff between functions and