Oracle to Postgres : create type as object in Postgres

Started by Ben Ali Rachidover 16 years ago3 messages
#1Ben Ali Rachid
souliman239@yahoo.fr

Hello,

I've a Oracle type that I must translate to Postgres. This Oracle type is like below :

CREATE OR REPLACE
type D_Temp_Element as object
(
   MEMBER FUNCTION to_string return Varchar2,
   MEMBER FUNCTION duration return D_Interval,
   ...
) ;

How can I do that in Postgres ? Is there something that be equivalent ?
Thanks.

Rachid

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ben Ali Rachid (#1)
Re: Oracle to Postgres : create type as object in Postgres

Ben Ali Rachid <souliman239@yahoo.fr> writes:

I've a Oracle type that I must translate to Postgres. This Oracle type is like below :

CREATE OR REPLACE
type D_Temp_Element as object
(
�� MEMBER FUNCTION to_string return Varchar2,
�� MEMBER FUNCTION duration return D_Interval,
�� ...
) ;

How can I do that in Postgres ? Is there something that be equivalent ?

No, we don't have any concept of member functions. Just create the
composite type (I'm assuming it needs to be composite) and then create
functions that take it as parameter.

Note that because PG allows function overloading, there's no conflict
between, say, to_string(D_Temp_Element) and to_string(Some_Other_Type).
If you were only using member functions to prevent that kind of
conflict, I don't think you need to worry too much.

regards, tom lane

PS: this is not an appropriate question for -hackers. Please direct
simple usage questions to -general in future.

#3Ben Ali Rachid
souliman239@yahoo.fr
In reply to: Tom Lane (#2)
Re: Oracle to Postgres : create type as object in Postgres

No, we don't have any concept of member functions.  Just create the

composite type (I'm assuming it needs to be composite) and then create

functions that take it as parameter.

Note that because PG allows function overloading, there's no conflict

between, say, to_string(D_Temp_Element) and to_string(Some_Other_Type).

If you were only using member functions to prevent that kind of

conflict, I don't think you need to worry too much.

OK thanks.

PS: this is not an appropriate question for -hackers.  Please direct

simple usage questions to -general in future.

Sorry.