Please tell me if i'm barking up the wrong forum, but as my script is perl, seemed like a good place to start!
OK, we have had some server issues, which our dedicated host provider said is SQL 2005 having memory bleed, to the point the machine locks up and requires a re-boot after @ two weeks of operation without a reboot.
As I use my own SQL module to access SQL and retreive the recordset as an array of hashes, I would like to eliminate this as the cause of the memory bleed, so your input is appreciated.
Here is an example of my getSQL routine....
One thing I notice is if there is an error executing the SQL statement it dies with the error message.
Does die kill a SQL connection or do I need to issue the $db->Close(); before I kill the script, could this be the cause of the memory bleed?
Having been studying Java, it is clear that any operation that might cause an Exception should be encapsulated in a try/catch/finally clause, so you can gracefully try to close an open file.
I was wondering if the same needs to be done in my SQL module? Though I can't find a try/catch for perl.
Your advice is appreciated.
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Google Rank Extractor -> Perl beta with FusionCharts
OK, we have had some server issues, which our dedicated host provider said is SQL 2005 having memory bleed, to the point the machine locks up and requires a re-boot after @ two weeks of operation without a reboot.
As I use my own SQL module to access SQL and retreive the recordset as an array of hashes, I would like to eliminate this as the cause of the memory bleed, so your input is appreciated.
Here is an example of my getSQL routine....
Code:
###############################################
############## Get SQL Routine ################
###############################################
sub getSQL {
#_0 = Table
#_1 = Columns
#_2 = Where
#_3 = Order By
# Define Record Set Array & Hash
my @rs;
#Build SQL Statement
my $sel = "SELECT $_[1] FROM $_[0] WHERE $_[2]";
# Check for ORDER BY
if($_[3]){$sel .= " ORDER BY $_[3]";}
# Open DB Connection
my $db;
if(!$HLP){
$db = new Win32::ODBC($MDB) || die "getSQL Error Connecting (Web): " . Win32::ODBC::Error();
}
else{
$db = new Win32::ODBC("FILEDSN=$DSN;") || die "getSQL Error Connecting (SBS): " . Win32::ODBC::Error();
}
# Run SQL Command
if(!$db->Sql("$sel")) {
# Loop SQL Record Set
while($db->FetchRow()){
# Build Array of Hashes with SQL Data
my %dt = $db->DataHash();
$rs[@rs] = \%dt;
}
# Close DB Connection
$db->Close();
# Return Record Set Array of Hashes
@rs;
}
else{die "Error in getSQL ($sel)" . Win32::ODBC::Error();}
}
Does die kill a SQL connection or do I need to issue the $db->Close(); before I kill the script, could this be the cause of the memory bleed?
Having been studying Java, it is clear that any operation that might cause an Exception should be encapsulated in a try/catch/finally clause, so you can gracefully try to close an open file.
I was wondering if the same needs to be done in my SQL module? Though I can't find a try/catch for perl.
Your advice is appreciated.
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Google Rank Extractor -> Perl beta with FusionCharts