use DBIx::Recordset;
# Setup a new object and select some recods...
*set = DBIx::Recordset -> Search ({'!DataSource' => 'dbi:Oracle:....',
'!Table' => 'users',
'$where' => 'name = ? and age > ?',
'$values' => ['richter', 25] }) ;
# Get the values of field foo ...
print "First Records value of foo is $set[0]{foo}\n" ;
print "Second Records value of foo is $set[1]{foo}\n" ;
# Get the value of the field age of the current record ...
print "Age is $set{age}\n" ;
# Do another select with the already created object...
$set -> Search ({name => 'bar'}) ;
# Show the result...
print "All users with name bar:\n" ;
while ($rec = $set -> Next)
{
print $rec -> {age} ;
}
# Setup another object and insert a new record
*set2 = DBIx::Recordset -> Insert ({'!DataSource' => 'dbi:Oracle:....',
'!Table' => 'users',
'name' => 'foo',
'age' => 25 }) ;
# Update this record (change age from 25 to 99)...
$set -> Update ({age => 99}, {name => 'foo'}) ;
|
|