Re: Module Comment
- From: dbijcl@xxxxxxxxx (Brad Adkins)
- Date: Thu, 8 Nov 2007 11:04:28 -0800
Examples or pseudo-code would be good.
Here is an example, with proper config entries, this could run and do real
work. This particular example selects rows of data from a data warehouse,
and inserts the result set into a data mart. After that is complete, it
counts rows to verify that eveything performed as expected. Config access,
logging, error notification, all provided from config entries common to the
environment, but overrides on a per job basis supported (not shown here).
#!perl/bin/perl
use strict;
use warnings;
use DBIx::JCL qw( :all );
## initialization
my $jobname = 'sample_job'; ## identifies job config file
sys_init( $jobname );
my $db_ware = 'datawarehouse'; ## warehouse virtual name
my $db_mart = 'datamart'; ## datamart virtual name
my $sql_select = sys_get_sql('select' ); ## get our sql
my $sql_insert = sys_get_sql('insert' ); ## get our sql
my $sql_count = sys_get_sql('count' ); ## get our sql
## main
log_info( sys_get_dbdescr( $db_ware ) ); ## message to the log
log_info( sys_get_dbdescr( $db_mart ) ); ## message to the log
db_connect( $db_ware );
db_connect( $db_mart );
db_prepare( $db_ware, $sql_select );
db_prepare( $db_mart, $sql_insert );
db_truncate( $db_mart, 'SAMPLE_TABLE' ); ## trunc SAMPLE_TABLE
db_execute( $db_ware );
db_insert_from_query( $db_ware, $db_mart ); ## insert result set
db_commit( $db_mart );
## verify results
my $count_ware = db_rowcount_query( $db_ware, $sql_count );
log_info( "Rows retrieved from Data Warehouse: $count_ware" );
my $count_mart = db_rowcount_table( $db_mart, 'SAMPLE_TABLE' );
log_info( "Rows inserted into Data Mart: $count_mart" );
if ( $count_ware != $count_mart ) {
sys_die( 'Error comparing source and target record counts' );
}
## end
sys_end();
exit sys_get_errorlevel();
__END__
--
Brad Adkins
dbijcl@xxxxxxxxx
- References:
- Module Comment
- From: Brad Adkins
- Re: Module Comment
- From: Greg Sabino Mullane
- Module Comment
- Prev by Date: Re: Module Comment
- Next by Date: Re: DBD::Oracle and Perl's internal representation of strings
- Previous by thread: Re: Module Comment
- Next by thread: Re: Error always returned from system() after connecting to Oracle 10 .2 on Solaris 64 bit
- Index(es):