By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,644 Members | 1,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,644 IT Pros & Developers. It's quick & easy.

problem with update query

100+
P: 154
I got a perl script that i am reading from a txt file
I then parse the data which all works but when i run the update queries
I get an error you have an error in your sql synax

this is the code i am using

Expand|Select|Wrap|Line Numbers
  1.         foreach (@rows) {
  2.         @_ = split;
  3.  
  4.  
  5.  
  6.       # EXECUTE THE QUERY FUNCTION
  7. #$execute = $connect->query($myquery);
  8.  #$connect->disconnect  or warn $dbh->errstr;
  9.  
  10.  
  11.  my $sth = $dbh->prepare("UPDATE JMS_PROD SET queuename_prod = $_[0] where queuename_prod = $_[0]");
  12.  $sth->execute();
  13.  
  14.  my $sth = $dbh->prepare("UPDATE JMS_PROD SET rcvrs_prod = $_[3] where queuename_prod = $_[0]");
  15.  $sth->execute();
  16.  
  17.  my $sth = $dbh->prepare("UPDATE JMS_PROD SET number_of_msgs_prod = $_[4] where queuename_prod = $_[0]");
  18.  $sth->execute();
  19.  
  20.  my $sth = $dbh->prepare("UPDATE JMS_PROD SET queue_size_prod = $_[5] $_[6] where queuename_prod = $_[0]");
  21. $sth->execute();
  22.  
  23. my $sth = $dbh->prepare("UPDATE JMS_PROD SET updated_date = NOW() where queuename_prod = $_[0]");
  24. $sth->execute();
  25.  
  26. print "updated record $_[0] \n\n\n";
  27. #sleep 3;
  28.  
  29.  
Could somebody please help me thanks
Jul 2 '07 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
I got a perl script that i am reading from a txt file
I then parse the data which all works but when i run the update queries
I get an error you have an error in your sql synax

this is the code i am using

Expand|Select|Wrap|Line Numbers
  1.         foreach (@rows) {
  2.         @_ = split;
  3.  
  4.  
  5.  
  6.       # EXECUTE THE QUERY FUNCTION
  7. #$execute = $connect->query($myquery);
  8.  #$connect->disconnect  or warn $dbh->errstr;
  9.  
  10.  
  11.  my $sth = $dbh->prepare("UPDATE JMS_PROD SET queuename_prod = $_[0] where queuename_prod = $_[0]");
  12.  $sth->execute();
  13.  
  14.  my $sth = $dbh->prepare("UPDATE JMS_PROD SET rcvrs_prod = $_[3] where queuename_prod = $_[0]");
  15.  $sth->execute();
  16.  
  17.  my $sth = $dbh->prepare("UPDATE JMS_PROD SET number_of_msgs_prod = $_[4] where queuename_prod = $_[0]");
  18.  $sth->execute();
  19.  
  20.  my $sth = $dbh->prepare("UPDATE JMS_PROD SET queue_size_prod = $_[5] $_[6] where queuename_prod = $_[0]");
  21. $sth->execute();
  22.  
  23. my $sth = $dbh->prepare("UPDATE JMS_PROD SET updated_date = NOW() where queuename_prod = $_[0]");
  24. $sth->execute();
  25.  
  26. print "updated record $_[0] \n\n\n";
  27. #sleep 3;
  28.  
  29.  
Could somebody please help me thanks
Does your engine indicate the line where the error was found? Indicate that if it does.
Jul 3 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.