camenix has asked for the wisdom of the Perl Monks concerning the following question:
#!perl -w
use strict;
use File::Basename;
use File::Spec;
use Data::Dump;
use Text::Template;
use Win32::OLE;
use Adoscan;
my $SourceDataConnectionString;
$SourceDataConnectionString='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=GF_GG;Data Source=BEEB';
my $zc='select * from T_2001B0clcp';
#------------------ Main ----------------
print "Begin...at ".localtime()."\n";
# Begin to Convert SQL's Data to text file
Db2Text(\&Action,$SourceDataConnectionString,$zc);
print "$zc Complete! at".localtime()."\n";
# Begin to transefer Data's index to web's database
}#---------------- End Main --------------
sub Db2Text
{
my $Action=shift;
my $DataConnectionString=shift;
my $string=shift;
# Cycle DataBase TABLE
Adoscan::scandb($Action,$DataConnectionString,$string);
}
sub Action
{
my $linehash=shift;
if( ! $linehash )
{
print "Not Define Function! parameter is $linehash \n";
return;
}
my $mark=GetTemplateFile($linehash);
my $Template=Text::Template->new(TYPE=>'FILE',SOURCE=>$mark);
my $Text=$Template->fill_in(HASH=>$linehash);
return;
}
File:Adoscan # It is my personal lib
package Adoscan;
use strict;
use Data::Dump;
use Win32::OLE::Lite;
use Win32::OLE;
use Win32::OLE::Const;
# despite you do noting,it cost 4k every cycle
sub scandb
{
my $function=shift;
my $oledbstring=shift;
my $commandstring=shift;
my $conn = Win32::OLE->new('ADODB.Connection');
# my $RS = Win32::OLE->new('ADODB.Recordset');
$conn->Open($oledbstring);
if (Win32::OLE->LastError()){
print "This didn't go well: ", Win32::OLE->LastError(), "\n";
}
my $rst=$conn->Execute($commandstring);
if (Win32::OLE->LastError()){
print "This didn't go well: ", Win32::OLE->LastError(), "\n";
}
# my $rows=[];
while(!($rst->{EOF}))
{
my $currentrow={};
my $count = $rst->Fields->{Count};
for(my $i=0;$i<$count;$i++)
{
my $columnname=$rst->Fields($i)->{Name};
my $columnvalue=$rst->Fields($i)->{Value};
if(defined($columnvalue))
{
$columnvalue=~s/^\s+//;
$columnvalue=~s/\s+$//;
}
else
{
#$null||($columnvalue='');
}
$currentrow->{$columnname}=$columnvalue;
}
#push(@$rows,$currentrow);
($debug eq '1')&&(print (caller().$currentrow."\n"));
&$function($currentrow);
$rst->MoveNext;
}
$conn->Close;
#return $rows;
}
1;
#END
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: memory leak
by Celada (Monk) on Dec 11, 2005 at 18:21 UTC | |
by camenix (Acolyte) on Dec 12, 2005 at 02:59 UTC | |
|
Re: memory leak
by BrowserUk (Patriarch) on Dec 12, 2005 at 05:20 UTC | |
by camenix (Acolyte) on Feb 08, 2006 at 12:10 UTC |