NAME
TABLEOp - Module for Table level operations
SYNOPSIS
use TABLEop;
$titles = new TABLEop ( $dbh, "titles" );
$titles->insert ( \%data );
$titles->update ( \%data, \%where );
$titles->delete ( \%where );
@all_rows = $titles->select (" where title_id < 10 ");
%one_row = $titles->select ( " where title_id = 4 ");
DESCRIPTION
These routines allow you to treat your data as hashes. They generate
insert, delete, update statments and actually run them against
the server. It does the work of generating sql for you. It puts
the necessary quotes if the datatype is char, datetime etc.
Additionally you could also do select and get all rows as
an array of hash-references or get just one row as a single
hash-reference.
Specification of table follows the usual Sybase conventions,
i.e. if you did not specify absolute name, it looks if the user
has a table by the same name.
The module remembers the full path name of the table and uses it
for all operations. This avoids the risk of inadvertant
changes to your application's database context.
- Creating a handle
-
use TABLEop; $titles = new TABLEop ( $dbh, "titles" );
- Inserting
-
%data = ('title_id' => 50, 'title' => 'Perl Book', 'price' => 50.24, 'pub_date' => 'Jan 1 1900' ); $titles->insert ( \%data );
- Deleting
-
%where = ( 'title_id' => 50 ); $titles->delete ( \%where );
- Updating
-
%data = ('title' => 'Perl New Book', 'price' => 150.24, 'pub_date' => 'Jan 1 2100' ); %where = ('title_id' = 50 ); $titles->update ( \%data, \%where );
- Selecting
-
The select behaves defferently depending on whether you are expecting one row OR many rows. If you wantarray, you get an Array of hash-references, else you get just a single hash-reference. @all_rows = $titles->select ("where title_id < 50"); OR @all_rows = $titles->select (""); #Select all the rows ! foreach $row ( @all_rows) { printf "title is %s\n", $row->{'title'}; } OR you could, $arow = $title->select ( "where title_id = 30"); printf "The title is %s.\n", $arow->{'title');
- Features wanted, unwanted
-
Currently does not handle NULL in update/delete/insert. This will cause an error. All error handling is left to the caller. It would be nice to automatically generate single row updates by figuring out unique key columns. Manish I Shah mshah@bfm.com
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 41:
=over without closing =back
- Around line 110:
Unknown directive: =back1