Re: operator is not unique: integer || integer

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: Daniel Schuchardt <daniel_schuchardt(at)web(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: operator is not unique: integer || integer
Date: 2008-05-05 19:22:37
Message-ID: 481F5E7D.30609@wildenhain.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Daniel Schuchardt wrote:
> Tino Wildenhain schrieb:
>> Hi,
>>
>> Daniel Schuchardt wrote:
>> ...
>>> in 81:
>>>
>>> postgres=# SELECT 1::INTEGER||1::INTEGER;
>>> ?column?
>>> ----------
>>> 11
>>> (1 row)
>>
>> *shudder* is this actually a port of an application originally
>> targeted at M*Sql? ;)
>>
>> Are you using those columns somewhere with their real type - as
>> integer? I mean if you use them as text everywhere why not change
>> the type once?
>>
>> T.
> *g*
>
> yes, sure we have to CAST it now. thats no problem. but the problem is
> to find all the places where to cast. and you see that there are many
> possiblilitys.
>
> another example?:
>
> RAISE NOTICE "error during validation % :",
> 'ks:"'||ks||'"@"'||loopdate||'"'; (here LoopDate is a DateTime)
>
> another one:
>
> here we need to add 4 CASTS. you see.....
>
> CREATE OR REPLACE FUNCTION date_to_yearmonth_dec(TIMESTAMP) RETURNS
> INTEGER AS $$
> DECLARE R INTEGER;
> BEGIN
> IF extract(month FROM $1)<11 THEN
> R:=extract(year FROM $1)||0||extract(month FROM $1)-1;
> ELSE
> R:=extract(year FROM $1)||extract(month FROM $1)-1;
> END IF;
> RETURN R;
> END$$LANGUAGE plpgsql IMMUTABLE;

RETURN extract(year FROM $1)*100+extract(month FROM $1)-1;

was too clean and easy? ;))

Looks like a good oportunity to clean up your code before anything
unexpected happens :-)

Cheers
T.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dan Armbrust 2008-05-05 19:28:47 checkpoint_segments warning?
Previous Message Leandro Casadei 2008-05-05 19:09:56 Re: Extract only numbers from a varchar column