PostgreSQL: Call a Stored Procedure for Every Row

Posted by in Software

I guess that newbies in PostgreSQL like me have first question when they create a store procedure:

How do I call it?

The answer is simple; you just execute


Then, usually immediately the second question pops up:

I wrote a procedure which I need to call for each row in a table. How do I do that?

The answer is, just as simple; you execute


A Short Explanation

Let’s assume a table:

and a procedure:

The procedure is designed to be called for each row in the REFERENCE_XML_DATA table and perform some processing.

The calling statement is:

Then, the CONTENT and ASIDE fields in the REFERENCE_XML_DATA will be interpreted as PRIMARY_CONTENT and SECONDARY_CONTENT respectively.



A little experiment: If you find this post and ad below useful, please check the ad out :-)