How to run a stored PL/pgSQL function? - Mailing list pgsql-general

From Ken Winter
Subject How to run a stored PL/pgSQL function?
Date
Msg-id 004d01c5f628$a2ed1ba0$6603a8c0@kenxp
Whole thread Raw
Responses Re: How to run a stored PL/pgSQL function?
Re: How to run a stored PL/pgSQL function?
List pgsql-general

How can I cause a PL/pgSQL function to be executed from a SQL script?

 

I know how to invoke a function using a trigger, but I don’t know any other way.

 

I’m looking at the SQL Command Reference at http://www.postgresql.org/docs/7.4/static/sql-commands.html, but the only command that looks like a candidate to do this, namely EXECUTE, seems to use only the result of a PREPARE statement, which in turn can only accept a SELECT, INSERT, UPDATE, or DELETE statement as input, according to http://www.postgresql.org/docs/7.4/static/sql-prepare.html.

 

I’m not sure if I’m clearly saying what I need to do.  I have a PL/pgSQL “foo (varchar)”.  I have a script containing a bunch of DDL statements.

 

Somewhere in that script, I want to call or invoke (or whatever the right verb is) foo and provide its argument, so that when the script is being executed, at that point foo is executed and has its desired effect on the database.  (I don’t need any return from foo.)  But I don’t know what to put into the script to make this happen.

 

~ TIA

~ Ken

pgsql-general by date:

Previous
From: "Thomas F. O'Connell"
Date:
Subject: Re: SELECT Generating Row Exclusive Locks?
Next
From: Michael Glaesemann
Date:
Subject: Re: How to run a stored PL/pgSQL function?