niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » PostgreSQL
Difference between function and procedure?
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
Anastasios Hatzis
*nix forums beginner


Joined: 04 Apr 2006
Posts: 6

PostPosted: Wed Jul 19, 2006 3:46 pm    Post subject: Difference between function and procedure? Reply with quote

Hi,

I'm diving more into depth of the features outside the typical table
stuff, which I usually need.

I wrote a trigger that fires a function written in PL/Python, both works
fine so far.

But as I browsed my database via pgAdmin3 I recognized that there is
also 'Procedures' under 'public' available, but empty yet. Trying to
create a procedure resulted in the same SQL statement like creating a
function (CREATE FUNCTION ...). I couldn't see any difference. Also
didn't find in the PostgreSQL manual if there is a difference between
functions and procedures. Are there any at all?

Anastasios

PS: Using PostgreSQL 8.1.3 on Windows XP development machine.

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org
Back to top
Merlin Moncure
*nix forums addict


Joined: 19 Oct 2005
Posts: 87

PostPosted: Wed Jul 19, 2006 5:41 pm    Post subject: Re: Difference between function and procedure? Reply with quote

On 7/19/06, Anastasios Hatzis <ahatzis@gmx.net> wrote:
Quote:
Hi,

I'm diving more into depth of the features outside the typical table
stuff, which I usually need.

I wrote a trigger that fires a function written in PL/Python, both works
fine so far.

But as I browsed my database via pgAdmin3 I recognized that there is
also 'Procedures' under 'public' available, but empty yet. Trying to
create a procedure resulted in the same SQL statement like creating a
function (CREATE FUNCTION ...). I couldn't see any difference. Also
didn't find in the PostgreSQL manual if there is a difference between
functions and procedures. Are there any at all?

there are differences. PostgreSQL only really supports functions and
on the lists they are used interchangably. on the -hacker list about
a year back there was a good discussion about implementing true SP and
why they would be needed.

mainly, SP are not externally transactional, making them useful for
maintenance type work, such as vacuum (cant be run from inside a
transaction) or multiple statement data load via 'copy' commands.

i thnk (not sure) that SP can not be inlined into queries like
functions. this would be an important distinction.

merlin

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq
Back to top
Anastasios Hatzis
*nix forums beginner


Joined: 04 Apr 2006
Posts: 6

PostPosted: Wed Jul 19, 2006 6:42 pm    Post subject: Re: Difference between function and procedure? Reply with quote

Merlin Moncure wrote:
Quote:
there are differences. PostgreSQL only really supports functions and
on the lists they are used interchangably. on the -hacker list about
a year back there was a good discussion about implementing true SP and
why they would be needed.

mainly, SP are not externally transactional, making them useful for
maintenance type work, such as vacuum (cant be run from inside a
transaction) or multiple statement data load via 'copy' commands.

i thnk (not sure) that SP can not be inlined into queries like
functions. this would be an important distinction.

Merlin,


thank you for clarifying this. So, given your hint, I didn't miss SP
until now, but this will probably change in future. ;-)

Anastasios

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
Back to top
Paul S
*nix forums beginner


Joined: 20 Jul 2006
Posts: 1

PostPosted: Thu Jul 20, 2006 12:22 am    Post subject: Re: Difference between function and procedure? Reply with quote

I saw the same behavior with Functions and Procedures. At first, I could
not tell what made one go into the Function folder and one go into the
Procedure one. The one thing that clearly distinguishes a Procedure (to be
placed into the Procedures folder in PgAdminIII) is if you include an OUT
parameter. The first time I wrote a Function with an OUT parameter, I could
not find it in the functions folder. I thought at first that it didn't
compile. Then I noticed it in the Procedures folder. Probably a lot of
other characteristics that make it different, but that is at least one. :)

-Paul




On 7/19/06, Anastasios Hatzis <ahatzis@gmx.net> wrote:
Quote:

Merlin Moncure wrote:
there are differences. PostgreSQL only really supports functions and
on the lists they are used interchangably. on the -hacker list about
a year back there was a good discussion about implementing true SP and
why they would be needed.

mainly, SP are not externally transactional, making them useful for
maintenance type work, such as vacuum (cant be run from inside a
transaction) or multiple statement data load via 'copy' commands.

i thnk (not sure) that SP can not be inlined into queries like
functions. this would be an important distinction.

Merlin,

thank you for clarifying this. So, given your hint, I didn't miss SP
until now, but this will probably change in future. ;-)

Anastasios

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Thu Nov 20, 2008 9:53 pm | All times are GMT
navigation Forum index » Databases » PostgreSQL
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Function Pointer Sikandar C 3 Fri Jul 21, 2006 1:23 pm
No new posts How to ALTER a table using the ALTOBJ procedure Serge Rielau IBM DB2 1 Fri Jul 21, 2006 1:06 pm
No new posts Arbitrary function with parameter darknails@gmail.com C++ 2 Fri Jul 21, 2006 9:58 am
No new posts Is there C/C++ corresponding function in Linux for Java's... xiebopublic@gmail.com apps 4 Fri Jul 21, 2006 3:22 am
No new posts Is there C/C++ corresponding function in Linux for Java's... xiebopublic@gmail.com C++ 1 Fri Jul 21, 2006 2:44 am

Loans | Free Credit Report | Refinance | Anime | Free Advertising
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2382s ][ Queries: 16 (0.1500s) ][ GZIP on - Debug on ]