It's a SQL error:
scott@dbi:Oracle:nt> select decode( 'N/A', 'N/A', '1', '2') as tst from dual;
TST
'1'

scott@dbi:Oracle:nt> select decode( 'N/B', 'N/A', '1', '2') as tst from dual;
TST
'2'

scott@dbi:Oracle:nt> select decode( 'N/B', 'N/A', '1') as tst from dual;
TST
undef

Without the default value, the decode is returning null (shown as
undef).

Tom


On Tue, Jun 04, 2002 at 12:16:12PM +1000, Stacy Mader wrote:
> 
> Greetings all,
> 
> I'm trying the following INSERT statement with DBI 1.21:
> 
> use DBI;
> use strict;
> 
> DBI->trace(2,'test.log');
> 
> $dbh->do(qq{
>       INSERT INTO TEST
>             VALUES (TEST_SEQ.NEXTVAL,
>                     SUBSTR(?,0,100),                 
>                     DECODE(?,'N/A',''),
                                      ^^^^^ Missing the default value.
>                     SUBSTR(?,0,2000)
>                     )
>          } , undef,
>         $name,$score,$comment);
> 
> Where $score can be 1..5 or the string "N/A" (default). As I understand
> it, if the score defaults to N/A, shouldn't the decode function NULLIFY
> it?
> 
> Looking through the Oracle log output, even when the user
> inputs $score to a number, it is being decoded to NULL.
> 
> Is this an SQL error or a bug in DBI?

-- 
Thomas A. Lowery
See DBI/FAQ http://xmlproj.dyndns.org/cgi-bin/fom

Reply via email to