Re: [BUGS] Function round(double precision, integer) - Fast backward compatibility solution

2003-01-12 Thread Silvio Scarpati
Hi Felipe,

On 04 Jan 2003 13:58:13 -0600, you wrote:

>I am having trouble with a function round that used to work in 7.2.1
>
>PostgreSQL was updated to 7.3.1 from 7.2.1, the data was re-loaded into
>7.3.1 with no complaints from the DB engine but, at application run
>time, we do get the error:
>
>Function round(double precision, integer) does not exists
>
>Code executed and that worked fine in 7.2.1 is:
>
>select
>   clientes.id_cliente,

[...]

have you tried to follow the Tom Lane suggestion to explicit cast the
first parameter in the call to round function ?

Anyway, to avoid writing queries and triggers to port existing
database to newer versions of Postgres you can define the following
very simple function:

-

create function round (double precision, integer) returns double
precision as '

   select cast(round(cast($1 as numeric),$2) as double precision);

' LANGUAGE SQL with(iscachable) ;




I hope this can help someone.


Regards,
Silvio Scarpati




---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])



[BUGS] Bug #872: Cursor scrolling

2003-01-12 Thread pgsql-bugs
Artur Zajac ([EMAIL PROTECTED]) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
Cursor scrolling

Long Description
There is some example in attachment. Sometimes after second fetch I had 0 rows (in 
other query). It seems that there is a bug in cursor scrolling or cursors doesn't let 
to move backward in some cases.


Sample Code
create table abc (a varchar(5),r int);
insert into abc VALUES ('FV','1');
insert into abc VALUES ('WZ','2');
insert into abc VALUES ('RW','3');
insert into abc VALUES ('PF','4');
select * from abc;   returns 4 rows
BEGIN;
DECLARE aaa CURSOR FOR SELECT DISTINCT ON (r) r,a FROM abc WHERE a!='';
FETCH ALL FROM aaa;  returns 4 rows
MOVE BACKWARD 26 IN aaa;   --- returns MOVE 3  (why???)
FETCH ALL FROM aaa;   returns 3 rows


No file was uploaded with this report


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html