Re: Creating functions

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Félix Sánchez Rodríguez <fesanch(at)ciego(dot)cult(dot)cu>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Creating functions
Date: 2009-04-27 05:28:34
Message-ID: dcc563d10904262228tbe23452sa1e72770c9b98253@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

2009/4/26 Félix Sánchez Rodríguez <fesanch(at)ciego(dot)cult(dot)cu>:
> Are the functions in PostgreSQL like the Stored Procedures on SQL Server??
> If so, could someone post a simple function which for instance inserts a new
> record. I just want to have a preview of the syntax of the code. I later
> will look up some documentation on this subject.

There are lots of examples in the docs, but here's a super simple one in sql:

# create table test (a int);
# create function addone(x int) returns int as $$
# insert into test (a) values ($1); select $1;
$$ language sql;
# select addone(5);
addone
--------
5
(1 row)
# select * from test;
a
---
5
(1 row)

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message samana srikanth 2009-04-27 16:12:12 Restore Table Issue
Previous Message Félix Sánchez Rodríguez 2009-04-26 14:49:20 Creating functions