Greetings !.

I have some problem with executing a SQL  update statement while updating
multiple records at a time.

I have tried different ways but it is udating one a single (first) record.
The same sql statement works perfectly when run directly on the MY SQL
prompt.

The code i have used are

1.
@del_list = split(",", $in{del_industry});
foreach $id (@del_list) {
     $id= "(industry_id='$id')";
}
$where = join(" or ", @del_list);
$sql ="update industry_list set deleted='y' where ($where)";
$dbh = DBI->connect($site{dsn});
&displayError("Unable to delete the option.<br> $sql")
unless($dbh->do($sql));

# The contents of $sql are "update industry_list set deleted='y' where
((industry_id='001') or (industry_id='002') or (industry_id='003') or
(industry_id='004') or (industry_id='005'))"


2.
$dbh = DBI->connect($site{dsn});
$sql .="update industry_list set deleted='y' where industry_id = ?";
my $sth = $dbh->prepare($sql);
@del_list = split(",", $in{del_industry});
foreach $del_id (@del_list){
    $content .= "<br>trying to deleted $del_id";
    $sth->execute($del_id);
}




----- Original Message -----
From: "Wagner-David" <[EMAIL PROTECTED]>
To: "Perl Beginners" <[EMAIL PROTECTED]>
Sent: Friday, July 06, 2001 10:21 AM
Subject: RE: -d & other file tests


> You are passing the source diretory and file, yet when doing the
> test you are only doing the source file and not combining the directory
and
> file. Without seeing what you are passing, this would be my first guess. I
> say this becuase you always pring the two together when you print.
>
> Wags ;)
>
> -----Original Message-----
> From: Adam Theo [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 05, 2001 17:59
> To: Perl Beginners
> Subject: -d & other file tests
>
>
>
> Hello, Adam Theo here;
>
> i was wondering if there is something i must declare to use file tests
> such as -d and -e? i have code which i am working on, and i need to
> check to see if a file is a directory. if it is, i run a subroutine.
>
> i recall having used file tests before, and successfully. i don't recall
> having to declare anything special to use them, such as 'use File::Test'
> or something like that. i just used it in the code, like any other core
> perl function/operator.
>
> here is the bit of code relevant to the file tests. through 'print' and
> data::dumper, i have isolated the root of my problem. it is that the
> file tests are not being done. the perl interpreter doesn't seem to know
> to check if the file is a directory, and just skips over it, going on to
> the final 'else' loop, even though it knows of the file, and can do
> other stuff with it, just not file tests.
>
> sub check_source {
>      my($source_dir, $source_file) = @_;
>      print("Checking $source_dir/$source_file.\n");
>      if ($source_file =~ /^\./) {
>        print("Can't open file '$source_dir/$source_file':
>          System file.\n");
>      }
>      elsif (-d $source_file) {
>        print("$source_dir/$source_file is a directory.\n");
>        $source_dir = "$source_dir/$source_file";
>        &get_sources($source_dir);
>      }
>      elsif ($source_file =~ /(\.xml)$/) {
>        print("$source_dir/$source_file is a source file.\n");
>        &parse_source($source_dir, $source_file);
>      }
>      else {
>        print("No match!\n");
>      }
> }
>
> thanks in advance!
> --
>    /\   Theoretic Solutions (www.Theoretic.com):
>   //\\    'Activism, Software, and Internet Services'
> //--\\ Personal Homepage (www.Theoretic.com/adamtheo/):
>    ][     'Personal history, analysis, and favorites'
>    ][   Birthright Online (www.Birthright.net):
>           'Keeping the best role-playing game alive'
> Email & Jabber:                   Other:
> -Professional: [EMAIL PROTECTED]  -AIM: AdamTheo2000
> -General: [EMAIL PROTECTED]   -ICQ: 3617307
> -Personal: [EMAIL PROTECTED]      -Phone: (850)8936047
>

Reply via email to