#!perl # package buildInput; use strict; use Exporter (); use vars qw(@ISA @EXPORT); BEGIN { @ISA = qw(Exporter); @EXPORT = qw(&getInput &doSQLclone &doSQLpaths &doSQLappend &doSQLtalktos &doSQLinstances &doSQLoutput &doSQLgetPaths &doSQLgetStreams &reportDbError); } 1; #----------------------------- sub getInput { use DBI; use strict; open (OUT, ">-") || die "I/O error accessing STDOUT:$!"; # first argument is the stream_name_used flag $main::stream_name_used = shift; # Name of tcl template to use my $template = shift; # these are the names of the physics table and tag # (passed in as arguments) $main::phys_table = shift; $main::phys_table_tag = shift; print OUT "#Physics Table name and tag are: $main::phys_table, $main::phys_table_tag\n"; # Removed use of test.user for connecting to database, using the # cdf_reader login which is READ ONLY. Which database to connect # to is now passed in as an argument - KAT 10/17/00 my $dbname = shift; my $user = "cdf_reader"; my $password = "reader"; # Hard wiring password and username for development database since # a cdf_reader which sees the trigger tables doesn't exist on cdfondev if ($dbname eq "cdfondev") { # $user = "level3_trig_dev"; # $password = "level3"; $user = "cdftrig_dev"; $password = "cdftrig_dev"; } # Read the database, username and password from a file # The file must be three lines with database, username and password # on separate lines. There must be no blank lines at the # end of the file. # open (USERNAME,"test.user") || die "can't open file: $!"; # while (defined ($temp = )) # { # chomp $temp; # $dbname = $temp; # $user=; # chomp $user; # $password=; # chomp $password; ## }; # close (USERNAME) || die "couldn't close file: $!"; #note how connection specifies Oracle here, msql, mysql or any #other DBI driver will work exactly the same # ($main::dbh) = DBI->connect("dbi:Oracle:$dbname",$user,$password) || die "Error connecting $DBI::errstr\n"; my $myfile=$template; my $line; # # now get the unique instances (return list and hash by reference) # ($main::unique_instance_ref,$main::instance_by_instance_ref,$main::class_by_instance_ref) = doSQLinstances(); my $inst; foreach $inst (@$main::unique_instance_ref) { if (exists $$main::instance_by_instance_ref{$inst}) { print "#WARNING: parmSetName $inst for class $$main::class_by_instance_ref{$inst} is the same as parmSetName $$main::instance_by_instance_ref{$inst}\n"; } } open(TEMPLATE, $myfile) or die "unable to open $myfile:$!"; while( $line =