Thread: calling a plpgsql procedure

calling a plpgsql procedure

From
s
Date:
Sorry to post such a stupid question.  I have read the "create
function" documentation and searched old mailing lists, but I can't
seem to find an example of how to call a plpgsql procedure that isn't
associated with a trigger.

In Oracle (old platform) I used:

begin update_cur_res('VALUE-HERE'); end

This doesn't work in postgres as far as I can tell.  I've tried some
other things as well and failed, such as

psql $mydb
> update_cur_res('VALUE-HERE');

which gives a message that I have a syntax error near the semi-colon.
Help?

Thanks,

Sarah Mulholland
smarie@ekno.com

P.S. Why does the "search documentation" option on the web page only
accept 15 characters?

____________________________________________________________________________
Lonely Planet's ekno - more than a phonecard
Get ekno before you go!
http://www.ekno.lonelyplanet.com



Re: calling a plpgsql procedure

From
Robert Treat
Date:
select update_cur_res('VALUE-HERE');  // should do the trick.

see also http://www.postgresql.org/idocs/index.php?plpgsql.html

Robert Treat

On Mon, 2002-06-24 at 13:47, s wrote:
> Sorry to post such a stupid question.  I have read the "create
> function" documentation and searched old mailing lists, but I can't
> seem to find an example of how to call a plpgsql procedure that isn't
> associated with a trigger.
>
> In Oracle (old platform) I used:
>
> begin update_cur_res('VALUE-HERE'); end
>
> This doesn't work in postgres as far as I can tell.  I've tried some
> other things as well and failed, such as
>
> psql $mydb
> > update_cur_res('VALUE-HERE');
>
> which gives a message that I have a syntax error near the semi-colon.
> Help?
>
> Thanks,
>
> Sarah Mulholland
> smarie@ekno.com
>
> P.S. Why does the "search documentation" option on the web page only
> accept 15 characters?
>
> ____________________________________________________________________________
> Lonely Planet's ekno - more than a phonecard
> Get ekno before you go!
> http://www.ekno.lonelyplanet.com
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>





Re: calling a plpgsql procedure

From
s
Date:
Thanks to Robert and the others who answered my question.  I'd like to
point out that I searched through all the pages referenced by the URL
below, and I don't an example of the syntax to call a procedure.  It
would be nice to include it as an example.  There is something about
select under expressions that may be intended to give the syntax, but
it's still not clear to me; it's something about SPI.


Robert Treat <rtreat@webmd.net> wrote:

select update_cur_res('VALUE-HERE');  // should do the trick.

see also http://www.postgresql.org/idocs/index.php?plpgsql.html

Robert Treat

On Mon, 2002-06-24 at 13:47, s wrote:
> Sorry to post such a stupid question.  I have read the "create
> function" documentation and searched old mailing lists, but I can't
> seem to find an example of how to call a plpgsql procedure that
isn't
> associated with a trigger.
>
> In Oracle (old platform) I used:
>
> begin update_cur_res('VALUE-HERE'); end
>
> This doesn't work in postgres as far as I can tell.  I've tried some
> other things as well and failed, such as
>
> psql $mydb
> > update_cur_res('VALUE-HERE');
>
> which gives a message that I have a syntax error near the
semi-colon.
> Help?
>
> Thanks,
>
> Sarah Mulholland
> smarie@ekno.com
>
> P.S. Why does the "search documentation" option on the web page only
> accept 15 characters?
>
>
__

____________________________________________________________________________
Lonely Planet's ekno - more than a phonecard
Get ekno before you go!
http://www.ekno.lonelyplanet.com



Re: calling a plpgsql procedure

From
Stephan Szabo
Date:
On Mon, 24 Jun 2002, s wrote:

> Sorry to post such a stupid question.  I have read the "create
> function" documentation and searched old mailing lists, but I can't
> seem to find an example of how to call a plpgsql procedure that isn't
> associated with a trigger.

In general the easiest way is to use it in a select:
select func(args);
(assuming your function isn't defined to return opaque)