Re: [SQL] inhibit rounding on numeric columns

2008-02-14 Thread Bart Degryse
You could probably create a before insert trigger which compares the number of fractional digits in the given number with the defined scale (surely some system table can offer you that) and raises an exception if needed. I do agree though with Niklas Johansson's remarks and wonder with him on wh

Re: [SQL] inhibit rounding on numeric columns

2008-02-14 Thread Niklas Johansson
On 15 feb 2008, at 08.28, Horst Dehmer wrote: Is there an easy way to enforce strict handling of numeric values with scales, i.e. raise an exception/error instead of rounding values to the specified scale? insert into dummy values(3.141); -- insert #1 insert into dummy values(3.1415); --

Re: [SQL] inhibit rounding on numeric columns

2008-02-14 Thread Scott Marlowe
On Fri, Feb 15, 2008 at 1:28 AM, Horst Dehmer <[EMAIL PROTECTED]> wrote: > > > Hi! > > Is there an easy way to enforce strict handling of numeric values with > scales, i.e. raise an exception/error instead of rounding values to the > specified scale? I can't think of an easy way. But you can alwa

[SQL] inhibit rounding on numeric columns

2008-02-14 Thread Horst Dehmer
Hi! Is there an easy way to enforce strict handling of numeric values with scales, i.e. raise an exception/error instead of rounding values to the specified scale? In a given schema with 250+ tables I have lots of numeric columns with a scale > 0. The docs (chapter 8.1.2) state clearly that gre

Re: [SQL] FUNCTIONs and CASTs

2008-02-14 Thread Dean Gibson (DB Administrator)
On 2008-02-14 15:19, Tom Lane wrote: It's not exactly clear what you checked, but it works as expected for me. See test case below, proving that indexscan works just fine with a parameter declared using %type. regards, tom lane Consider: CREATE TABLE zzz( aaa CHA

Re: [SQL] FUNCTIONs and CASTs

2008-02-14 Thread Tom Lane
"Dean Gibson (DB Administrator)" <[EMAIL PROTECTED]> writes: > So, is this the best (or only) way to solve this? I haven't done > exhaustive checking, but it appears that specifying the type of > parameters in the function prototype is only used for type-checking (and > function matching), and

[SQL] FUNCTIONs and CASTs

2008-02-14 Thread Dean Gibson (DB Administrator)
Last night I tore my hair out for about three hours with the following problem (v8.3.0): I had a simple scalar query that I wanted to create a function for. However, when I created the function and called it from another query OR the PSQL command line, it was two orders of magnitude SLOWER th

Re: [SQL] PL/pgSQL question

2008-02-14 Thread Milen A. Radev
Sebastian Ritter написа: Hi all, I have a question regarding functions. How can I return zero rows from a function whose return type is a table row? I did the following test and it did not work as expected: [...] CREATE OR REPLACE FUNCTION foobar(boolean) RETURNS SETOF x AS $_$ DECLARE

[SQL] PL/pgSQL question

2008-02-14 Thread Sebastian Ritter
Hi all, I have a question regarding functions. How can I return zero rows from a function whose return type is a table row? I did the following test and it did not work as expected: CREATE OR REPLACE FUNCTION fn_get_user (integer) RETURNS usertable AS ' DECLARE in_userid A