db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeffrey Lichtman <swa...@rcn.com>
Subject Re: [PATCH] (DERBY-582) Dynamic parameter should be allowed to be the operand of unary operator "-". Derby throws exception 42X36: The '-' operator is not allowed to take a ? parameter as an operand."
Date Thu, 29 Sep 2005 05:13:41 GMT

>I have a simple patch to allow dynamic parameters for unary minus 
>and plus. The parameter will be bound to DOUBLE. The patch is 
>attached to JIRA. Can a commiter please commit it if everything 
>looks good? I have run all the tests and no new failures. Have also 
>added a test for this.

I'm not convinced this is a good idea.

The SQL standard limits the use of parameters to those places where 
their types can be determined unambiguously, for example, in an 
insert or update list, or as an argument to the CAST function. I 
don't know of any general way to figure out what the type of a 
parameter "should" be in other places, especially for overloaded 
functions and operators like - (both unary and binary).

What will happen if Cloudscape binds a parameter to a double, and the 
user tries to use it with a fixed-point type like decimal? It's 
likely there will be a loss of precision, and the user won't get what 
he expects.

If the user wants to use a parameter with unary minus, I suggest the 
use of the cast function to make the type unambiguous:

   - (cast ? as <type>)


                        -        Jeff Lichtman
                                 swazoo@rcn.com
                                 Check out Swazoo Koolak's Web Jukebox at
                                 http://swazoo.com/ 


Mime
View raw message