Обсуждение: Porting from PL/SQL to PLPGSQL

Поиск
Список
Период
Сортировка

Porting from PL/SQL to PLPGSQL

От
Jomon Skariah
Дата:
Hi,

We are in the process of migrating of our application from Oracle to
PostGreSQL.


we are  facing a few problems with PL/SQL Code..

1)     In Exceptions ORACLE have something called WHEN OTHERS THEN cluase.I
can't find a replacement for that in            PostGreSQL.
2    Oracle have a function USERENV to get the user session
information.Is there any replacement available in PostGres. ?

3    Is there any replace available for INSTEAD OF INSERT/DELETE/UPDATE
for triggers in PostGreSQL.




Regards

Jomon Skariah.



Re: Porting from PL/SQL to PLPGSQL

От
Josh Berkus
Дата:
Jomon,

> 1)     In Exceptions ORACLE have something called WHEN OTHERS THEN cluase.I
> can't find a replacement for that in
>             PostGreSQL.

PL/pgSQL currently does not handle exceptions at all.  This is on the TODO
list.

> 2    Oracle have a function USERENV to get the user session
> information.Is there any replacement available in PostGres. ?

There are several variables and tools which provide current user and session
information.  See the "PostgreSQL Administration" section of the
documentation.

> 3    Is there any replace available for INSTEAD OF INSERT/DELETE/UPDATE
> for triggers in PostGreSQL.

In Postgres, this is generally done through the RULES system instead of
triggers.  Please lookup CREATE RULE in the online docs.

--
-Josh BerkusAglio Database SolutionsSan Francisco



Re: Porting from PL/SQL to PLPGSQL

От
Rod Taylor
Дата:
> we are  facing a few problems with PL/SQL Code..
>
> 1)     In Exceptions ORACLE have something called WHEN OTHERS THEN cluase.I
> can't find a replacement for that in
>             PostGreSQL.

What does it do?

> 2    Oracle have a function USERENV to get the user session
> information.Is there any replacement available in PostGres. ?

CURRENT_USER (I believe this is per spec)

> 3    Is there any replace available for INSTEAD OF INSERT/DELETE/UPDATE
> for triggers in PostGreSQL.

You might have some luck with Rules (CREATE RULE) if you are writing
data to a different table.  Otherwise you're stuck with somewhat more
complicated triggers.