Re: Can we overload = operator to word numeric = text

From: venkatrao(dot)b(at)tcs(dot)com
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: Can we overload = operator to word numeric = text
Date: 2010-03-09 11:47:26
Message-ID: OF907808F8.618F3AA8-ON652576E1.0040B27D-652576E1.0040C4C8@tcs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

Dear Pavel,

Thanks a lot...

It worked.

Regards,
Venkat

From:
Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To:
venkatrao(dot)b(at)tcs(dot)com
Cc:
pgsql-novice(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Date:
03/09/2010 04:07 PM
Subject:
Re: [GENERAL] Can we overload = operator to word numeric = text

2010/3/9 <venkatrao(dot)b(at)tcs(dot)com>:
>
> Hello,
>
> We have migrated oracle database to postgre.
> In oracle char to numeric type conversion is explicit (i.e. we can
compare
> char = numeric); but in postgre it is throwing errors. There are so many
> functions - around 2000, and we can not go and do explict type casting
in
> every function , where there is problem.
>
> Is there any way to come out of this problem. I mean is there any way to
> make = operator work for numeric = charater varying .
> Your suggestions are highly appreciated.

try

create or replace function num_text_eq(numeric, varchar)
returns bool as $$
select $1 = $2::numeric$$
language sql;

create operator = ( leftarg=numeric, rightarg=varchar,
procedure=num_text_eq);
postgres=# select 10='10';
?column?
----------
t
(1 row)

regards
Pavel Stehule

>
> Venkat
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you

In response to

Browse pgsql-general by date

  From Date Subject
Next Message zhong ming wu 2010-03-09 12:04:19 warm standby possible with 8.1?
Previous Message Pavel Stehule 2010-03-09 10:37:22 Re: Can we overload = operator to word numeric = text

Browse pgsql-novice by date

  From Date Subject
Next Message venkatrao.b 2010-03-09 13:51:31 Urgent help needed- alias name in update statement
Previous Message Pavel Stehule 2010-03-09 10:37:22 Re: Can we overload = operator to word numeric = text