stored procedures (packages)

Started by J.V.over 14 years ago3 messagesgeneral
Jump to latest
#1J.V.
jvsrvcs@gmail.com

I need to run a series of stored procedures, what is the best way to
organize and run.

Ideally would like something like Oracle PL/SQL where I can put all
methods in one file and create a main() method

then just : select main() to have them all run.

If there is a way to do this, please let me know.

Also is it possible to call a stored function or procedure from another
stored proc/function?

#2John R Pierce
pierce@hogranch.com
In reply to: J.V. (#1)
Re: stored procedures (packages)

On 09/30/11 12:57 AM, J.V. wrote:

I need to run a series of stored procedures, what is the best way to
organize and run.

Ideally would like something like Oracle PL/SQL where I can put all
methods in one file and create a main() method

then just : select main() to have them all run.

in function main, have

select function1();
select function2();
...

Also is it possible to call a stored function or procedure from
another stored proc/function?

see above.

note that postgres doesn't acctually have stored procedures, it only has
functions.

--
john r pierce N 37, W 122
santa cruz ca mid-left coast

#3Laurenz Albe
laurenz.albe@cybertec.at
In reply to: J.V. (#1)
Re: stored procedures (packages)

J.V. wrote:

I need to run a series of stored procedures, what is the best way to
organize and run.

Ideally would like something like Oracle PL/SQL where I can put all
methods in one file and create a main() method

then just : select main() to have them all run.

If there is a way to do this, please let me know.

Don't try to do PostgreSQL things the Oracle way.

To group functions that logically belong together, you can put them
into a separate schema.

You can grant users execute rights on only one of them if you like
(or rather, because by default PUBLIC has execute rights, revoke
that from all others).

Also is it possible to call a stored function or procedure from

another

stored proc/function?

Sure, use them in an SQL statement inside a function.

Yours,
Laurenz Albe