Thread: Calling Functions and Stored Procedures

Calling Functions and Stored Procedures

From
"Mark Dexter"
Date:

I understand that functions in Postgres server the purpose of both functions and stored procedures in other db's (e.g., MSSQL and Oracle).  In these other databases, you call a stored procedure with different syntax (e.g., CALL <procedure name>) instead of using it in line in a SELECT statement.

My question is this:  If I write a Postgres function that is not designed to be part of a query (e.g., it should just do something), do I still use a SELECT statement to execute the function?  Is there some other syntax that is the equivalent to CALL or EXEC? 

Thanks for your help.

Re: Calling Functions and Stored Procedures

From
Oliver Elphick
Date:
On Thu, 2004-07-15 at 16:43, Mark Dexter wrote:
...
> My question is this:  If I write a Postgres function that is not
> designed to be part of a query (e.g., it should just do something), do
> I still use a SELECT statement to execute the function?  Is there some
> other syntax that is the equivalent to CALL or EXEC?

No, you always use SELECT to call a function.

For example, to change the value of a sequence (using a built-in
function):

   SELECT nextval('table_field_seq',553);


Oliver Elphick