perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Viljo Marrandi <>
Subject DBIx Update
Date Mon, 02 Sep 2002 08:57:26 GMT

I have a problem with DBIx::Recordset Update (or it has a problem with me,
not sure yet ;).

I want to use one subroutine to update data in one table, but this sub is
called from different places and it updates different fields of this
table. Now, the problem is, that when some variables are undefined in this
%hash, but they exist in table, then Update sets them to 'undef' in table
too and I don't like it.

If I want to update ONLY sport and hobbies fields and other fields in
$data are just '' or undef then these will be updated too :(. I searched
the manual, but didn't find anything. Are there any workarounds or
configuration keywords to avoid this?

Here is example of this code:

   *db = DBIx::Recordset->Setup( { '!DataSource'  => $self->{dbh},
                                   '!Table'       => 'contract' } );

   my $where = { 'session_id' => $global_info->{'session_id'},
                 'user_id' => $global_info->{'user_id'},
                 'status' => 'etapp2' };

   my $user_id = ( $user ? $user : 0 );

   $data = { 'user_id' => $user_id,
             'session_id' => $self->{apr}->param('session_id'),
             'sport' => $sport,
             'hobbies' => $hobbies,
             'status' => $status,
             'region'    => $self->{apr}->param('region'),
             'work' => $self->{apr}->param('work'),
             'timestamp'  => 'NOW()',
             'type' => 1 };

   $db->Update( $data, $where );


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message