By saying "...of course the app bombs" isn't very descriptive. You need to be a little more clear about just what the problem is and what is happening. Are you saying that the value $::lang_code is not being written to the database? Copy and paste in the exact error that comes up - this will help debug.
Javier, I might be way off here, but looks to me like this statement: my($sql) = "UPDATE GLOBALSettings SET Lang = '$::lang_code'"; has $::lang_code in *single quotes* - I'm not sure about this in this context, but won't the single quotes will keep $::lang_code from being interpolated? Why not make that my($sql) = 'UPDATE GLOBALSettings SET Lang = ?'; and then add the $::lang_code as a parameter in the execute, like this: if ($criteria) { my $rc = $sth->execute ( $::lang_code, $criteria ) or &Error("Unable to execute statement", "$sql with criteria $criteria"); } else { my $rc = $sth->execute ($::lang_code) or &Error("Unable to execute statement", $sql); } HTH. Hardy Merrill >>> "Moreno, Javier" <[EMAIL PROTECTED]> 03/10/05 10:10 AM >>> Hi all, I have a script that writes a single record to a single row on a GLOBALSettings table. I have a web page that does that and it does so successfully. I go into the database with SQL Server Enterprise Manager and see the value on the table. Then I use another page that takes advantage of that value, it selects with no criteria the needed field and the value gets wiped out from the DB and of course the app bombs. I tried using a dbh->commit at the end of the update script but that didn't work either. Does anyone know what is wrong? Sample code below: #### INSERT SCRIPT # Insert into DB my($sql) = "UPDATE GLOBALSettings SET Lang = '$::lang_code'"; my($criteria_var) = ""; my($criteria) = ""; my($reference) = &SQL_Update($sql, $criteria_var, $criteria); # Disconnect from database $::rc = $::dbh->disconnect or &Error("Unable to disconnect from database."); sub SQL_Update { my ($sql, $criteria_field, $criteria) = @_; # Append criteria if present if ($criteria_field && $criteria) { $sql.= " WHERE $criteria_field = ?"; } # Debug the SQL statement (uncomment for testing) &Debug("$sql"); # Prepare a SQL statement my $sth = $::dbh->prepare( $sql ) or &Error("Unable to prepare statement."); # Execute the SQL statement prepared above, use with or without criteria depending on if it is present # or not if ($criteria) { my $rc = $sth->execute ( $criteria ) or &Error("Unable to execute statement", "$sql with criteria $criteria"); } else { my $rc = $sth->execute or &Error("Unable to execute statement", $sql); } # Return a TRUE value just so that the variable which gets assigned to the query execution on the caller # program does not report an empty value. If we got this far then all went OK 1; } # SELECT SCRIPT # Select current language my ($sql)= "SELECT Lang FROM GLOBALSettings"; my ($reference) = &SQL_Select($sql); my ($lang) = @[EMAIL PROTECTED]; sub SQL_Select { my ($sql, $criteria_field, $criteria, $add_criteria) = @_; # Debug the SQL statement (uncomment for testing) &Debug("$sql"); # Append criteria if present if ($criteria_field && $criteria) { $sql.= " WHERE $criteria_field = ?"; } # Any AND, OR or additional clauses if ($add_criteria) { $sql.= " $add_criteria"; } # Prepare a SQL statement my $sth = $::dbh->prepare( $sql ) or &Error("Unable to prepare statement."); # Execute the SQL statement prepared above, use with or without criteria depending on if it is present # or not if ($criteria) { my $rc = $sth->execute ( $criteria ) or &Error("Unable to execute statement", "$sql with criteria $criteria"); } else { my $rc = $sth->execute or &Error("Unable to execute statement", $sql); } # Return an array reference pointing to the results return my $result = $sth->fetchall_arrayref; } Regards, Javier Moreno