Amphibous SPL call
Posted in 2005
Topics: Stored Procedures & SPL
Is it supposed to do this?
create function myfunc( DATE ) etc
create function myfunc( DATETIME YEAR TO FRACTON(3) ) etc
Call myfunc("31/05/2005")
and I get a 9700 amphibous function. I didn't think there were implicit
casts between these types but do forget things
--
Paul Watson #
Oninit Ltd # Growing old is mandatory
Tel: +44 1436 672201 # Growing up is optional
Fax: +44 1436 678693 #
Mob: +44 7818 003457 #
www.oninit.com #
Paul Watson wrote:
> Is it supposed to do this?
>
> create function myfunc( DATE ) etc
> create function myfunc( DATETIME YEAR TO FRACTON(3) ) etc>
> Call myfunc("31/05/2005")
>
> and I get a 9700 amphibous function. I didn't think there were implicit
> casts between these types but do forget things
The trouble is that there's a cast from string to DATE and a cast from
string to DATETIME - assuming the FRACTON is only a typo in the posting
- and that the server has no basis on which to choose either as the
preferred function, so it can't make its mind up whether to call the
frog or the toad. (Err...is CALL supported?)
So:
CALL MYFUNC(DATE("31/05/2005")) will work in the UK but not the US (in
general).
CALL MYFUNC(EXTEND("31/05/2005", YEAR TO FRACTION(3))) will probably
work - I haven't formally tested it.
You probably can't use DATETIME("31/05/2005") YEAR TO FRACTION(3)
because the data in the parentheses is not allowed to be anything very
different from DATETIME(2005-05-31 00:00:00.000) YEAR TO FRACTION(3).
Suggestion: don't take up C++ coding just yet - the ambiguities will get
you into bigger trouble there.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2005.01 -- http://dbi.perl.org/
Fixed by
call myfunc("31/5/2005"::DATE)
call myfunc("2005-05-31 12:00:00.000"::DATETIME YEAR TO FRACTION(3))
just forgot about the implicit casts - long day
Jonathan Leffler wrote:
> Paul Watson wrote:
>
>> Is it supposed to do this?
>>
>> create function myfunc( DATE ) etc
>> create function myfunc( DATETIME YEAR TO FRACTON(3) ) etc>>
>> Call myfunc("31/05/2005")
>>
>> and I get a 9700 amphibous function. I didn't think there were
>> implicit casts between these types but do forget things
>
>
> The trouble is that there's a cast from string to DATE and a cast from
> string to DATETIME - assuming the FRACTON is only a typo in the posting
> - and that the server has no basis on which to choose either as the
> preferred function, so it can't make its mind up whether to call the
> frog or the toad. (Err...is CALL supported?)
>
> So:
>
> CALL MYFUNC(DATE("31/05/2005")) will work in the UK but not the US (in
> general).
>
> CALL MYFUNC(EXTEND("31/05/2005", YEAR TO FRACTION(3))) will probably
> work - I haven't formally tested it.
>
> You probably can't use DATETIME("31/05/2005") YEAR TO FRACTION(3)
> because the data in the parentheses is not allowed to be anything very
> different from DATETIME(2005-05-31 00:00:00.000) YEAR TO FRACTION(3).
>
> Suggestion: don't take up C++ coding just yet - the ambiguities will get
> you into bigger trouble there.
>
--
Paul Watson #
Oninit Ltd # Growing old is mandatory
Tel: +44 1436 672201 # Growing up is optional
Fax: +44 1436 678693 #
Mob: +44 7818 003457 #
www.oninit.com #