Обсуждение: Oracle to Postgres : create type as object in Postgres
<table border="0" cellpadding="0" cellspacing="0"><tr><td style="font: inherit;" valign="top">Hello, <br /><br />I've a Oracletype that I must translate to Postgres. This Oracle type is like below :<br /><br /><span style="font-style: italic;">CREATEOR REPLACE</span><br style="font-style: italic;" /><span style="font-style: italic;">type D_Temp_Element asobject</span><br style="font-style: italic;" /><span style="font-style: italic;">(</span><br style="font-style: italic;"/><span style="font-style: italic;"> MEMBER FUNCTION to_string return Varchar2,</span><br style="font-style: italic;"/><span style="font-style: italic;"> MEMBER FUNCTION duration return D_Interval,</span><br style="font-style: italic;"/><span style="font-style: italic;"> ...</span><br style="font-style: italic;" /><span style="font-style: italic;">);</span><br style="font-style: italic;" /><br />How can I do that in Postgres ? Is there something that be equivalent?<br />Thanks.<br /><br />Rachid<br /></td></tr></table><br />
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.
<table border="0" cellpadding="0" cellspacing="0"><tr><td style="font: inherit;" valign="top">>No, we don't have any conceptof member functions. Just create the<br /> >composite type (I'm assuming it needs to be composite) and then create<br/> >functions that take it as parameter.<br /> ><br /> >Note that because PG allows function overloading,there's no conflict<br /> >between, say, to_string(D_Temp_Element) and to_string(Some_Other_Type).<br /> >Ifyou were only using member functions to prevent that kind of<br /> >conflict, I don't think you need to worry toomuch.<br /><br />OK thanks.<br /><br /><br /> >PS: this is not an appropriate question for -hackers. Please direct<br/> >simple usage questions to -general in future.<br /><br />Sorry.<br /></td></tr></table><br />