Actually, you probably want

decode(thisfield,'0000000000',null,'
',null,thisfield)

That way anything with the 0 string or the space string will be null, but
everything else will be returned untouched...

Ryan



                                                                                       
                                                       
                    Ryan Hope                                                          
                                                       
                                         To:     [EMAIL PROTECTED]            
                                                       
                    05/30/02 02:30       cc:     [EMAIL PROTECTED]                    
                                                       
                    PM                   Subject:     Re: Inserting NULL in DB2 
DECIMAL Field(Document link: Ryan Hope)                       
                                                                                       
                                                       
                                                                                       
                                                       



Maybe I'm missing something, but why aren't you decoding that special value
into a null, instead of a 0. Try

decode (thisfield,'0000000000', null)

instead.  then, $thisfield should be "undef" by the time you go to do the
$sth->execute($thisfield)

Ryan Hope



|--------+--------------------------------->
|        |          Jeff Seger             |
|        |          <jeffrey.seger@fairchil|
|        |          dsemi.com>             |
|        |                                 |
|        |          05/30/02 02:16 PM      |
|        |                                 |
|--------+--------------------------------->
  
>----------------------------------------------------------------------------------------------------------|
  |                                                                                    
                      |
  |      To:                                                                           
                      |
  |      cc:     , Julia McDevitt <[EMAIL PROTECTED]>                                
                      |
  |      Subject:     Re: Inserting NULL in DB2 DECIMAL Field                          
                      |
  
>----------------------------------------------------------------------------------------------------------|




$sth->execute(undef);



On Thu, 2002-05-30 at 14:01, [EMAIL PROTECTED] wrote:
>
> Howdy,
>
> I've got an application that pulls data from an Oracle database to an IBM

> DB/2 database.  For the IBM database, if the data I'm pulling contains
all
> zeros or all spaces, they want me to insert a NULL into that field.
>
> When selecting from Oracle I use a decode statement:
>
>   decode (thisfield, '0000000000', 0);
>
> When inserting into IBM DB/2 I bind the variable before inserting it:
>
>   $sth = $dbh->prepare('INSERT INTO FOO (THATFIELD) VALUES (?)");
>
>   $sth->execute($thisfield);
>
> Unfortunately, I can't figure out how to tell it to insert a NULL.  The
> word 'NULL' is interpreted as a character string and he cannot accept
> zeros.
>
> How do I tell DBD::DB2 that I want to insert a NULL into a field when
> using binding params?
>
> Thanks!
>
>
> --
> Chris Fuhrman           | Twenty First Century Communications
> [EMAIL PROTECTED] | Software Engineer
> (W) 614-442-1215 x271   |
> (F) 614-442-5662        | PGP/GPG Public Key Available on Request
>
>








Reply via email to