IT'S ALIVE!!!!

        I would swear that I had tried this before, but it now works.  Below
is the UPDATE line that works.  I may, no must, be an idiot.  I would
honestly swear that I did this at least twice before, but here it is
working.

          $dbh->do(qq{UPDATE systems SET $set WHERE Name = '$name'});

        I must say that this is really SWEET.  I have been fighting with
this issue for a lot longer than just this morning.  Anyway, thanks.  Now on
to my next problem.  I will try to straighten this one out without having to
bug you guys again.

-----Original Message-----
From: NIPP, SCOTT V (SBCSI)
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 02, 2002 11:47 AM
To: 'Michael Ragsdale'; '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'
Subject: RE: UPDATE Statement Problem...


        OK.  Sorry for my being stupid.  Everyone keeps telling me the same
thing, and I must be doing something wrong here.  Let me try to make clear
how I am handling the SET parameter.

        The SET parameter ($set) is actually built earlier in the Perl
script.  I scavenged this portion of the code from a book that I picked up.
I am including this portion of the code below, and will briefly explain how
I think it works.  I am doing this so that hopefully someone can tell me
that it does or does not work.

      while (my $ref = $test->fetchrow_hashref ('NAME_lc')) {
        undef $set;
        foreach my $key (keys %$ref) {
          unless ($$key eq $ref->{$key}) {
            $set .= " , " if $set;
            $set .= $key . "=\'$$key\'";
          }
        }

        OK.  The above code tests each field value from the db against the
corresponding value from the text file being processed.  If the values do
NOT match, then the hash key, which is the column name, and the value are
put together and "built" into the $set variable.  This results in the $set
variable holding both the column name and the value in a form such as,
'col_name1 = expr1'.
        I have printed out the SQL statement resulting from this and used it
to successfully UPDATE the db from the MySQL Console.  This is why I keep
"skirting" the issue of the SET parameter in my UPDATE statement.  Now, if I
am fundamentally flawed in my logic (my wife would definitely say this is
the case) and this simply will NOT work, please let me know.
        Once again, I really appreciate all of the assistance.  I also
understand that if I were to spend a few days reading, I might have better
luck resolving some of these issues on my own.  Unfortunately, I am quite
limited on time, as I am sure everyone is.  Thank you all very much for the
help.  Please bear with me, and I will do my best to refrain from being
thick headed.  :)

-----Original Message-----
From: Michael Ragsdale [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 02, 2002 11:15 AM
To: NIPP, SCOTT V (SBCSI); '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'
Subject: RE: UPDATE Statement Problem...


At 12:01 PM 4/2/2002, NIPP, SCOTT V (SBCSI) wrote:
>         New problem now.  I appear have resolved my earlier problems.  The
>final issue appears to have been that the SQL statement was interpreting
the
>WHERE clause as having multiple arguments.  Quoting the where clause seems
>to have resolved the error, but the data still is not making it into the
>database?!?!  Below is the "working" UPDATE line:
>
>          $dbh->do(qq{UPDATE systems SET $set WHERE 'Name = $name'});

No, not a new problem.  You've got the same problem.  The data is not 
making it into the database because you are not telling the data where to 
go!  At least two people have commented on your syntax being incorrect and 
you keep skirting the issue.

Correct syntax:  UPDATE [LOW_PRIORITY] [IGNORE] tbl_name SET col_name1 = 
expr1, ... [WHERE where_definition] [LIMIT #]

Where is your 'col_name = ' part of the statement?  It will not work 
without it!  You'll want to remove those quotes that you placed around the 
where clause as well because once you fix the 'col_name = ' part of the 
syntax, then the quotes are likely to create more problems.  Follow the 
syntax rules - don't make up your own.

-Mike

Reply via email to