ODB - a Perl module for accessing database via DBI. Means easier handling of the DBI routines via this layer.
use ODB;
This module contains functions that are used to connect, disconnect, select, insert and delete rows from database. Note that HZB has the copyright on this software. It may not be used or copied without permission from HZB.
interview
$dbhandle = ODB::login(%config{
"dbase"=>ORACLE_SID,
"user"=>dbuser,
"passwd"=>dbuserpasswd},
);
This function connect to a Oracle database instance and give back the database handle.
interview
ODB::logoff();
This function disconnect fairly a Oracle database handle
interview
ODB::END();
This function abort the database connection. No rollback!
interview
ODB::debug();
This function sets trace level to 2 and wrote a logfile to /tmp including the verbose option.
interview
ODB::verbose();
Set info output on.
interview
ODB::silent();
Set debugging output off.
interview
$colstr = ODB::col_aliases($@columns,
$@aliases);
Give the list of real selected columnnames and the aliases as refernces of lists. Every column name will be expanded with quoted aliases at the same list position.
interview
ODB::ins($table,
%row{
columnname=>columnvalue,
...}
);
Insert a new row into the given table on the database handle is connected. The hash contains the named list as name to value association.
interview
ODB::del($table,
$keycolumn,
@keys
);
Delete one or more rows from table of the connected handle where the keycolumn values in the keys list as select secures the content more.
interview
ODB::selone($result);
Returns the single dataset of a resultset.
interview
%resultset = ODB::sel($table,
$col_names,
$cond,
@bind_values
);
Executing the generated select statement on the given handle by using the $table as the object clause, columnnames for detecting the returned tablecolumns, the filtering conditions and the binded variables. In addition is a little buggy feature inside. The resultset is returned do NOT return alised column table prefixes such as "tbl_test.firstsign". Only "firstsign" will be set as hashkey! Use for aliasing the function col_aliases. The resultset is returned shows the content like that:
%resultset = ( { row1col1=>row1colval1, row1col2=>row1colval2 ...}, { row2col1=>row2colval1, row1col2=>row2colval2 ...}, ... )
interview
%resultset = ODB::new_row($table,
$pk,
%res,
);
If you insert a new row you have to give the tablename the primary key column and the content of the new row. This function trusts to have a simple trigger for the given table generated. For example:
create trigger tbl_name_key_before_insert
on tbl_name before insert
for each row
begin
if :new.keycolumn is null or :new.keycolumn <= 0
then
select tbl_name_seq.nextval into :new.keycolumn from dual;
end if;
end;
/
Hey! The above document had some coding errors, which are explained below:
=over without closing =back