I want to migrate from MS SQL Server to PostgreSQL, and my final decision depends upon the complexity of stored procedures migration to PostgreSQL.

Nowadays I have lots of stored procedures (T-SQL) that must be translated to PL/pgSQL, so the migration process to PostgreSQL can be accomplished.

Considering this scenario, I have a list of T-SQL language features I use in my app, and I am willing to know whether there are any pgSQL language equivalents, or whether I should consider pgSQL language alternatives to get the same SQL Server functionalities.

I hope someone can help me in this topic.

1) Is it possible to return recordset / subqueries from a PostgreSQL stored procedure?

2) Can I use as many input and output type arguments in PostgreSQL stored procedures as I want?

3) Does it support IF...BEGIN...ELSE.... END flow structures?

4) Does it support WHILE...BEGIN... END flow structures?

5) SQL Server has such global variables as @@rowcount, @@error and @@fetch_status. Does pgSQL have the same functionalities?

6) Does it support global cursors (scope independent cursors)?

7) SQL Server supports SQL declarations like select @var = txVar from table. What about PostgreSQL?

8) Does PostgreSQL support stored procs/functions encryption?

Thanks in advance,