Darin McBride > DB2-db-0.25 > DB2::Row

Download:
DB2-db-0.25.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.23   Source  

NAME ^

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

SYNOPSIS ^

    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;

FUNCTIONS ^

new

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

save

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.

discard_changes

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

timestamp_to_time

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

time_to_timestamp

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

time_to_date

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

validate_column

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:

  self
  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.

column

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.

as_hash

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.

find

Shortcut to calling DB2::Table::find_id.

find_where

Shortcut to calling DB2::Table::find_where

table_name

Shortcut to calling DB2::Table::full_table_name

count

Shortcut to calling DB2::Table::count

count_where

Shortcut to calling DB2::Table::count_where

delete

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

SELECT

Shortcut to calling DB2::Table::SELECT

dbi_err
dbi_errstr
dbi_state

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

Dump

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'.

syntax highlighting: