Re: Newbie questions, diff between functions and - Mailing list pgadmin-support

From Milen A. Radev
Subject Re: Newbie questions, diff between functions and
Date
Msg-id 456910EC.40206@radev.net
Whole thread Raw
In response to Re: Newbie questions, diff between functions and  (novnov <novnovice@gmail.com>)
Responses Re: Newbie questions, diff between functions and  (Dave Page <dpage@postgresql.org>)
List 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



pgadmin-support by date:

Previous
From: novnov
Date:
Subject: Re: Newbie questions, diff between functions and
Next
From: "Andrus"
Date:
Subject: text_pattern_ops not shown in index command