Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 SQL - Updating with Perl (From ActiveState)

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-18 : 18:01:30
Rich writes "I wrote the subroutine below for an IntraNet attempting to UPDATE
a TABLE. There are 2 fields in the TABLE I am attempting to
UPDATE. The problem (Or question) is, why do I have to do 2 calls
to SQL doing only one field update, rather than just one with
2 fields to update, there are 6 fields in the TABLE. The strange
part of this is that the UPDATE actually works, it just never
comes back after the 'execute' statement. IF I code it the way
it IS below, then it works like it is supposed to, so I found a
way around the problem, although the problem still exists. This
program runs from Netscape(4.7) or IE to a WinNT(4.0) Server running
SQL 7.0.

Tell me what you think, is this a 'Bill' (As in Gates) problem,
SQL, PERL, or am I going Nucki' Futs...???

Here's my code:
# ----- #
sub update_wo
{
if ($func eq "Approve") { $func = "Approved" }
else { $func = "Canceled" }

$x = 0;
while($x < 2)
{
$x = $x + 1;
if ($x == 1) { $line = "SET status = '$func'" }
if ($x == 2) { $line = "SET appr_date = '$newtime'" }
$sql = "UPDATE Cust_WO
$line
WHERE wo_num = '$wo_num' ";
$sth = $dbh->prepare($sql) || errout("$DBI::errstr
$sql\n\n");
$sth->execute();
$sth->finish();
}

print "

\n";
print "$wo_num has been $func on $newtime
\n";
print "

\n";
}
# ----- #

There is code BEFORE/AFTER this, my attempt here was to
show that the UPDATE function is screwy, that's all. Please let
me know what you guys think about this, Hell, I have a ton more
wonderful MS thinks I can show you also...

Thanks...
PS: You need to set AUTOWRAP ON on this question box, Netscape doesn't AUTOWRAP on the form unless you tell it to...."

   

- Advertisement -