f



Overloading || ( text,text ) operator

Hi,

I was trying to overload concat operator ||(text,text) such a way that
it behaves like Oracle. i.e. I want 'abc' || null to return 'abc'
instead of null.
I know that it is not the expected  behaviour in postgres, but since I
am migrating the database from oracle to postgres , I need this
behaviour.

But when I try to drop the existing || operator, I get the following
error
ERROR:  cannot drop operator ||(text,text) because it is required by
the database system

Also I cannot modify the application which runs over the database.
Hence I cannot overload || (varchar,varchar) and use it.

Is there any way of overloading the || operator , such that it behaves
like Oracle? ( I know that Oracle behaviour is wrong , but my aim is
to move an existing application which runs on Oracle to Postgres :-( 
)

Thanks,
Abhiman
0
trisuresh
9/3/2004 1:49:47 PM
comp.postgresql.general 5128 articles. 0 followers. Post Follow

1 Replies
1271 Views

Similar Articles

[PageSpeed] 19

Suresh Tri wrote:
> 
> But when I try to drop the existing || operator, I get the following
> error
> ERROR:  cannot drop operator ||(text,text) because it is required by
> the database system
> 
> Also I cannot modify the application which runs over the database.
> Hence I cannot overload || (varchar,varchar) and use it.
> 
> Is there any way of overloading the || operator , such that it behaves
> like Oracle? ( I know that Oracle behaviour is wrong , but my aim is
> to move an existing application which runs on Oracle to Postgres :-( 
> )

Your best bet might be to define your own type "oraclevarchar" with stub 
implementations of most functions/operators except those you want to 
oracle-ise.

-- 
   Richard Huxton
   Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

0
dev
9/6/2004 2:16:48 PM
Reply: