in reply to Re: Placeholders, safety and the relative unimportance of efficiency
in thread SQL in Perl and setting variables
use DBI; use strict; # output file $newfile = "./batch_line_output.txt"; # open the new .txt file open(BATCH, ">>$newfile") || die "Can't open $newfile : the batch_line +_output.txt file. $!"; # sets and prints the system date to the log file $datestamp = `Date /T`; print BATCH $datestamp; # initialize the variable to count the batch lines created $linecount = 0; $asql = "SELECT batch_line FROM xyz.batch_lines WHERE exe_c = 'N' "; $bsql = "UPDATE xyz.batch_lines SET exe_c = 'Y' WHERE exe_c = 'N' "; # connect to oracle and extract data my $dbh1 = DBI->connect("dbi:Oracle:CS001", "admin", "admin123"); my $statement = $dbh1->prepare($asql); $statement ->execute(); while ($newfile= $statement->fetchrow_array) { $newfile=~s/p13/p12/g; $newfile=~s/D:/\nD:/g; $newfile=~s/%/%%/g; # write to the file $timestamp = `Time /T`; chop $timestamp; print BATCH $newfile." ".$timestamp; # writes to screen print $newfile; # counts the batch line being read $linecount++; # executes the batch line system($newfile); # Mark batch lines in table as read $statement2 = $dbh1->prepare($bsql); $statement2 ->execute(); } $statement->finish(); $statement2->finish(); # close oracle connection $dbh1->disconnect(); # print count of batch lines print BATCH $linecount; # close new .txt file close (BATCH);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Placeholders, safety and the relative unimportance of efficiency
by Zo (Scribe) on Apr 22, 2002 at 19:44 UTC | |
|
Re: Re: Re: Placeholders, safety and the relative unimportance of efficiency
by Zo (Scribe) on Apr 23, 2002 at 18:14 UTC | |
by runrig (Abbot) on Apr 24, 2002 at 03:01 UTC | |
|
Re: Re: Re: Placeholders, safety and the relative unimportance of efficiency
by Zo (Scribe) on Apr 26, 2002 at 13:47 UTC |