Darin McBride
and 1 contributors


DB2::Row Framework wrapper around rows using DBD::DB2


    package myRow;
    use DB2::Row;
    our @ISA = qw( DB2::Row );
    use myDB;
    use myTable;
    my $db = myDB->new;
    my $tbl = $db->get_table('myTable');
    my $row = $tbl->find($id);
    print $row->col_name;



Do not call this - you should get your row through your table object. To create a new row, see DB2::Table::create_row


Save the current row. Will happen automatically if it can. Only really need to call this if you're interested in any generated identity column for a new row.


If you do not want your changes up to this point to be kept, discard_changes will do the obvious


Converts a DB2 timestamp column to a perl ("C") time value


Converts a perl ("C") time value to a DB2 timestamp string.


Convert time to date. Converts a C/perl time to DB2's DATE format.


Override this if you need to validate changes to a column. Normally you can leave this to the database itself, but you may want to do this earlier than that. You can also use this to massage the value before it is kept.

The parameters are:

  column name
  new value

To keep the value as given, simply return it. To modify (massage) the value, return the modified value. To prevent the update, die.

Remember to call your SUPER before validating yourself to allow for future enhancements in DB2::Row. The base function may perform massaging such as converting time to timestamp, etc., in the future, so you can get that for free then. Currently this behaviour is done in the column method, but it may move into here in the future.

Beware not to try to update the current column directly or indirectly through this method as you could easily end up with infinite recursion.


This get/set method allows you to retrieve or update any given column for this row. With a single parameter, it will return the current value of that column. The second parameter will be the new value to use. This value will be validated before being used.


This is intended to help template users by returning the current row as a hash/hashref. For example, if you have a set of rows, @rows, you can give them to HTML::Template as:

    loop => [ map { $_->as_hash(1) } @rows ],

The optional parameter will force a scalar return (hashref) despite an array context, such as the map context above.


Shortcut to calling DB2::Table::find_id.


Shortcut to calling DB2::Table::find_where


Shortcut to calling DB2::Table::full_table_name


Shortcut to calling DB2::Table::count


Shortcut to calling DB2::Table::count_where


Shortcut to calling DB2::Table::delete for this ID


Shortcut to calling DB2::Table::SELECT


The relevant variable from DBI for the last problem occurring on this table.


Dumps the current values of this row without any internal variables that Data::Dumper would follow.

AUTOLOADed functions

Any column defined by the corresponding DB2::Table object is also a get/set accessor method for DB2::Row. For example, if you have a column named "LASTNAME" in your table, $row_obj->lastname() will retrieve that column from the $row_obj object, while $row_obj->lastname('Smith') will set that objects' lastname to 'Smith'.