example of Create Function - Mailing list pgsql-general

From Roberto (SmartBit)
Subject example of Create Function
Date
Msg-id 000101c27974$11fe4940$1501a8c0@NoteBook
Whole thread Raw
List pgsql-general
Hi all

Like I told before, I'm coming from Interdabe!!

so, could anyone send me some examples of CREATE FUNCTION? (using SQL
language)

This is an Interbase sample:

CREATE PROCEDURE MY_PROC( P_DATE_START TIMESTAMP )
RETURNS ( R_DATE_PAYMENT TIMESTAMP, R_DESCRIPTION VHARCHAR(50), R_VALUE
NUMERIC (12,2))
AS
BEGIN
   FOR SELECT DATE_PAYMENT, R_DESCRIPTION,VALUE  FROM PAYMENTS
           WHERE DATE_PAYMENT BETWEEN :P_DATE_STAR AND 'TODAY'
        INTO
         :R_DATE_PAYMENT ,
         :R_DESCRIPTION ,
         :R_VALUE
   DO
   BEGIN
      /*here I can do any check for each row of SELECT below!! */

      SUSPEND; /* Each SUSPEND command returns a row */
   END

END^

I can use this stored proc like this:
    SELECT * FROM MY_PROC( '01/01/2002' )

and it may return many rows ...


tia


Roberto de Amorim


pgsql-general by date:

Previous
From: Patrick Nelson
Date:
Subject: Re: Adding constraint [SOLVED]
Next
From: "Andrew Bartley"
Date:
Subject: ERROR: _mdfd_getrelnfd: cannot open relation pg_temp_15300_53: No such file or directory