Retrieving an hierarchical tree recursively with PL/PgSQL

From PostgreSQL 8.4 you can write WITH queries using the optional RECURSIVE modifier to make a query refer to its own output.

Ok, but if I’m using a previous version of PostgreSQL? What can I do? I had this same question and, after some research, I found a solution based on functions.

Below I’ll explain how the functions works. Continue reading “Retrieving an hierarchical tree recursively with PL/PgSQL”