Re: [GENERAL] operator is not unique: integer || integer

2008-05-06 Thread Daniel Schuchardt

Alban Hertroys schrieb:

another example?:

RAISE NOTICE "error during validation % :", 
'ks:"'||ks||'"@"'||loopdate||'"';  (here LoopDate is a DateTime)


Ehm... What's wrong with RAISE NOTICE "error during validation 
ks:"%"@"%" :', ks, loopdate; ? (I don't quite understand the purpose 
of that colon at the end, btw).
Allows you to format the date to your liking too, just add a 
to_char(loopdate, ).


I know these were just a few examples of your troubles, but so far it 
appears it's desirable to get rid of them for better code.


may be thats a good thing but its not possible. we have to do a major 
rollout for this. we have to look through all the code.
and our next and more important project is to become .net compatible. we 
have to upgrade our development enviroment because of trouble with 
incompatibilities ;-)

so we have to stay on postgresql81 the next years.
if it is nice or not to work with autocasts doesnt matter, it was able 
to do it so we used it for many years.


here another nice example:
(old.dbrid is INTEGER)

 EXECUTE 'UPDATE '||old.rc_tablename||' SET wvod=NULL WHERE 
dbrid='||old.rc_dbrid;


TIMESTAMP
 f:=EXTRACT(MINUTE FROM new.bd_anf_rund-CAST('0:'||CAST(f3 AS 
VARCHAR) AS TIME));


TIMESTAMP too
 new.bd_anf_rund:=timestamp_to_date(new.bd_anf) || ' ' || f4+f2 || 
':' || f1*tplrund;




PS:

i pick up only some string concatanation examples because i can identify 
them fast. all other things i cant see so easy.

(varcharfield=integerfield ^^)

PSPS:
don't touch a running system ;-)

Daniel.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] operator is not unique: integer || integer

2008-05-06 Thread Daniel Schuchardt

Klint Gore schrieb:
> RAISE NOTICE "error during validation % :", 
'ks:"'||ks||'"@"'||loopdate||'"';  (here LoopDate is a DateTime)


You know you can use more than one % in a raise and it will take care 
of the data types?



yes i know. the real code looks like this:

S:='another ABG found on ks:"'||ks||'"@"'||loopdate||'"';
PERFORM internalcreatemessage(current_user, 'W', S);


greets.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] operator is not unique: integer || integer

2008-05-05 Thread Alban Hertroys

another example?:

RAISE NOTICE "error during validation % :", 'ks:"'||ks||'"@"'|| 
loopdate||'"';  (here LoopDate is a DateTime)


Ehm... What's wrong with RAISE NOTICE "error during validation  
ks:"%"@"%" :', ks, loopdate; ? (I don't quite understand the purpose  
of that colon at the end, btw).
Allows you to format the date to your liking too, just add a to_char 
(loopdate, ).


I know these were just a few examples of your troubles, but so far it  
appears it's desirable to get rid of them for better code.


Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,481ffc80927661001715755!



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] operator is not unique: integer || integer

2008-05-05 Thread Klint Gore

Daniel Schuchardt wrote:

Tino Wildenhain schrieb:


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.




LOL. Yes I don't like such easy things  :-P
> RAISE NOTICE "error during validation % :", 
'ks:"'||ks||'"@"'||loopdate||'"';  (here LoopDate is a DateTime)


You know you can use more than one % in a raise and it will take care of 
the data types?


create function atest() returns integer as $$
declare
  ks integer;
  loopdate timestamp;
begin
  ks := 3;
  loopdate := now();
  raise notice 'blah ks:[EMAIL PROTECTED]', ks, loopdate;
  return 1;
end;
$$ language plpgsql;

postgres=# select atest();
NOTICE:  blah ks:[EMAIL PROTECTED] 09:58:55.812
atest
---
1
(1 row)

klint.

--
Klint Gore
Database Manager
Sheep CRC
A.G.B.U.
University of New England
Armidale NSW 2350

Ph: 02 6773 3789  
Fax: 02 6773 3266

EMail: [EMAIL PROTECTED]


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] operator is not unique: integer || integer

2008-05-05 Thread Daniel Schuchardt

Tino Wildenhain schrieb:


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.




LOL. Yes I don't like such easy things  :-P

But you see i have a function so i simply can change it ;-)

thnx for the hint, i picked up the best example ever :-P

Daniel.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] operator is not unique: integer || integer

2008-05-05 Thread Tino Wildenhain

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.



smime.p7s
Description: S/MIME Cryptographic Signature


Re: [GENERAL] operator is not unique: integer || integer

2008-05-05 Thread Daniel Schuchardt

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;

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] operator is not unique: integer || integer

2008-05-05 Thread Tino Wildenhain

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.


smime.p7s
Description: S/MIME Cryptographic Signature


[GENERAL] operator is not unique: integer || integer

2008-05-05 Thread Daniel Schuchardt
yeah, its clear that an upgrade from 8.1 to 8.3 is impossible for us 
without a major relase.

there are to many changes so the whole project has to be rechecked.

another example:

in 83:

postgres=# SELECT 1::INTEGER||1::INTEGER;
ERROR:  operator does not exist: integer || integer at character 18
HINT:  No operator matches the given name and argument type(s). You 
might need to add explicit type casts.



83 with autocast from peter e:

ERROR:  operator is not unique: integer || integer


in 81:

postgres=# SELECT 1::INTEGER||1::INTEGER;
?column?
--
11
(1 row)

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general