How to create stored procedure in PostgreSQL?

Started by Yolanda Valverdeabout 23 years ago5 messagesgeneral
Jump to latest
#1Yolanda Valverde
yvalverde@chiusac.com

Holas:

Me gustaría saber como crear procedimientos almacenados en PostgreSQL, yo
he trabajado con funciones, pero el problema que tengo es que la funcion
retorna un solo valor; lo que a mi me interesa saber es como retornar
varios valores.

Gracias

#2Lee Kindness
lkindness@csl.co.uk
In reply to: Yolanda Valverde (#1)

Yolanda, I think the following page should help you do what you want:

http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=xfunc-tablefunctions.html

Lee.

Yolanda Valverde writes:

Show quoted text

Holas:

Me gustaría saber como crear procedimientos almacenados en PostgreSQL, yo
he trabajado con funciones, pero el problema que tengo es que la funcion
retorna un solo valor; lo que a mi me interesa saber es como retornar
varios valores.

Gracias

#3Jason Hihn
jhihn@paytimepayroll.com
In reply to: Yolanda Valverde (#1)
Re: How to create stored procedure in PostgreSQL?

I'd like to know how to create stored procedures in PostgreSQL, I am working
with functions, but the problem that I have is with the function returning
one variable. I am interested in knowing how to return multiple variables.

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Yolanda Valverde
Sent: Thursday, February 13, 2003 10:45 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] How to create stored procedure in PostgreSQL?

Holas:

Me gustaría saber como crear procedimientos almacenados en PostgreSQL, yo
he trabajado con funciones, pero el problema que tengo es que la funcion
retorna un solo valor; lo que a mi me interesa saber es como retornar
varios valores.

Gracias

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

#4Brandon Craig Rhodes
brandon@oit.gatech.edu
In reply to: Yolanda Valverde (#1)
Re: How to create stored procedure in PostgreSQL?

Yolanda Valverde <yvalverde@chiusac.com> writes:

Me gustaría saber como crear procedimientos almacenados en PostgreSQL, yo
he trabajado con funciones, pero el problema que tengo es que la funcion
retorna un solo valor; lo que a mi me interesa saber es como retornar
varios valores.

create table two_integers (integer1 int, integer2 int);

create function square_and_cube(int) RETURNS setof two_integers
AS 'select $1*$1, $1*$1*$1;' LANGUAGE SQL;

SELECT * FROM square_and_cube(3);
-->
integer1 | integer2
----------+----------
9 | 27

http://www3.us.postgresql.org/users-lounge/docs/7.3/postgres/xfunc-tablefunctions.html

--
Brandon Craig Rhodes http://www.rhodesmill.org/brandon
Georgia Tech brandon@oit.gatech.edu

#5Andres Ledesma
aledes@telefonica.net
In reply to: Yolanda Valverde (#1)
Re: How to create stored procedure in PostgreSQL?

Just thinking out loud cause don't know very well if this is heretic or
something ..

define a new structured datatype, and make your function fill and return
this datatype..

Andres