Thread: A newbie question

A newbie question

From
"Brian H Mayo"
Date:

I am a newbie to PostgreSQL.  I added plpgsql to the database and wrote a function in the plpgsql language.  How do I execute it?

I read all of the manuals but I cannot seem to figure it out.  I pulled up the pgadmin III SQL and tried different combinations to run the function.  I tried PERFORM and EXECUTE; no good.

 

Thanks

Regards,

Brian H Mayo

bmayo@comcast.net

 

Re: A newbie question

From
Oliver Elphick
Date:
On Wed, 2003-11-19 at 02:43, Brian H Mayo wrote:
> I am a newbie to PostgreSQL.  I added plpgsql to the database and
> wrote a function in the plpgsql language. How do I execute it?
>
> I read all of the manuals but I cannot seem to figure it out.  I
> pulled up the pgadmin III SQL and tried different combinations to run
> the function.  I tried PERFORM and EXECUTE; no good.

You have done

  CREATE FUNCTION myfunction() ... LANGUAGE 'plpgsql';

Now you can say

  SELECT myfunction() FROM mytable;

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "To show forth thy lovingkindness in the morning, and
      thy faithfulness every night."     Psalms 92:2


Re: A newbie question

From
Date:
And in fact you can even do:
SELECT myfunction()

if the function does not rely on data/parameters from a table, which would
be the case if there are no parameters at all to myfunction()

Terry Fielder
Manager Software Development and Deployment
Great Gulf Homes / Ashton Woods Homes
terry@greatgulfhomes.com
Fax: (416) 441-9085


> -----Original Message-----
> From: pgsql-general-owner@postgresql.org
> [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Oliver Elphick
> Sent: Wednesday, November 19, 2003 6:22 PM
> To: Brian H Mayo
> Cc: PostgreSQL general list
> Subject: Re: [GENERAL] A newbie question
>
>
> On Wed, 2003-11-19 at 02:43, Brian H Mayo wrote:
> > I am a newbie to PostgreSQL.  I added plpgsql to the database and
> > wrote a function in the plpgsql language. How do I execute it?
> >
> > I read all of the manuals but I cannot seem to figure it out.  I
> > pulled up the pgadmin III SQL and tried different
> combinations to run
> > the function.  I tried PERFORM and EXECUTE; no good.
>
> You have done
>
>   CREATE FUNCTION myfunction() ... LANGUAGE 'plpgsql';
>
> Now you can say
>
>   SELECT myfunction() FROM mytable;
>
> --
> Oliver Elphick
> Oliver.Elphick@lfix.co.uk
> Isle of Wight, UK
http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "To show forth thy lovingkindness in the morning, and
      thy faithfulness every night."     Psalms 92:2


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)