RE: Inserting an Email Address fails.

speattle_at_yahoo.com
Date: 09/24/04


To: "Reidy, Ron" <Ron.Reidy@arraybiopharma.com>;"Hamilton, Kent" <KHamilton@Hunter.COM>;dbi-users@perl.org;
Date: Thu, 23 September 2004 17:57:02 -0700

Scroll down. :)
he does have insert as well as update queries embedded,

unfortunately neither doing what he's telling to do.

-----Original Message-----
From: "Reidy, Ron" <Ron.Reidy@arraybiopharma.com>
Date: 09/23/04 01:02 PM
To: "Hamilton, Kent" <KHamilton@Hunter.COM>, <dbi-users@perl.org>
Subject: RE: Inserting an Email Address fails.

Isn't the syntax for INSERT ...

INSERT INTO tab [(col_list)] values (value_list);

??

-----------------
Ron Reidy
Lead DBA
Array BioPharma, Inc.

-----Original Message-----
From: Hamilton, Kent [mailto:KHamilton@Hunter.COM]
Sent: Thursday, September 23, 2004 1:16 PM
To: dbi-users@perl.org
Subject: Inserting an Email Address fails.

I'm trying to insert an email address into a mysql database and it seems
to fail no matter what I do. Here are two different cuts at the code,
neither of which works and both return pretty much the same error message.

sub update_Unprocessed
{
        my $From = shift; # From
        my $MsgID = shift; # MsgID
        my $Subject = shift; # Subject
        my $Date = shift; # Date
        my $Reason = shift; # Reason
        my $Attachment = shift; # Body or attachment
        $rows = $dbh->do("INSERT INTO UnprocessedMail SET
                From = '$From',
                MsgID = '$MsgID',
                Subject = '$Subject',
                Date = \'$Date\',
                Reason = '$Reason',
                Attachment = '$Attachment'");
        if ( $DBI::errstr ) {
                $errmsg = 'Can not updated UnprocessedMail. Error: ' .
$DBI::errstr . "\n";
                doerror($errmsg);
                if ( $DEBUG ) {
                        print STDERR "Can not update UnprocessedMail.
Error: $DBI::errstr\n";
                }
        }
}

This produces this error message:

Can not update UnprocessedMail. Error: You have an error in your SQL
syntax. Check the manual that corresponds to your MySQL server version
for the right syntax to use near 'From = 'KHamilton@Hunter.COM',
                MsgID = '<BB7A3D4475F89F4696DC

Changing the subroutine to look like:

sub update_Unprocessed
{
        my $count = 0;
        $values[$count++] = shift; # From
        $values[$count++] = shift; # MsgID
        $values[$count++] = shift; # Subject
        $values[$count++] = shift; # Date
        $values[$count++] = shift; # Reason
        $values[$count] = shift; # Body or attachment
        $sth = $dbh->prepare(q{INSERT INTO UnprocessedMail
                (From, MsgID, Subject, Date, Reason, Attachment )
                VALUES ( ?, ?, ?, ?, ?, ? )});
        if ( $DBI::errstr ) {
                $errmsg = 'Can not prepare UnprocessedMail. Error: ' .
$DBI::errstr . "\n";
                doerror($errmsg);
                if ( $DEBUG ) {
                        print STDERR "Can not prepare UnprocessedMail.
Error: $DBI::errstr\n";
                }
        }
        $sth->execute(@values);
        if ( $DBI::errstr ) {
                $errmsg = 'Can not update UnprocessedMail. Error: ' .
$DBI::errstr . "\n";
                doerror($errmsg);
                if ( $DEBUG ) {
                        print STDERR "Can not update UnprocessedMail.
Error: $DBI::errstr\n";
                }
        }
}

Gives me THIS error message

Can not update UnprocessedMail. Error: You have an error in your SQL
syntax. Check the manual that corresponds to your MySQL server version
for the right syntax to use near 'From, MsgID, Subject, Date, Reason,
Attachment )
                VALUES ( 'KH

If I change the insert order it still blows up on the email address, IE if
I put MsgID first and the email address last it still dies on the mail
address.

I've tried various $sth->quote(), perl quotemeta, qq, q, etc., options.

I'm sure it's something

 
These words brought to you by Ogo. Find out more at www.ogo.com



Relevant Pages

  • RE: Inserting an Email Address fails.
    ... Isn't the syntax for INSERT ... ... Inserting an Email Address fails. ... neither of which works and both return pretty much the same error message. ... Check the manual that corresponds to your MySQL server version ...
    (perl.dbi.users)
  • Re: Not able to execute the CopyFolder method
    ... It fails on the line with CopyFolder. ... Is this wrong syntax? ... What's the error message you see? ...
    (microsoft.public.scripting.wsh)
  • Re: pkg_create examples...
    ... Can one of you provide me the syntax on how to do ... Each time you type a command and it fails, ... You should read the manpage. ...
    (comp.unix.bsd.openbsd.misc)
  • Re: Range Object error
    ... I guess I am still confused by the syntax highlighted by this example ... and this fails too ... Excel not agreeing on exactly which Range/Cells are being referenced. ... I am obviously referencing the RANGE object incorrectly but I dont see ...
    (microsoft.public.excel.programming)
  • Re: Cant insert Continuous Break into the Word Document
    ... Doug Robbins - Word MVP ... > In order to save each document's formating I am trying to insert> continuous breaks in the begining of each document but it fails. ... > When I manually move cursor to the regular text area the insert break> works fine. ... > Is there some kind of check I can do before inserting the break to> make sure that it will not fail or is there any areas of word doc> where it cannot be inserted. ...
    (microsoft.public.word.vba.general)