Re: prepare(SELECT ... FROM TABLE) error

2010-02-13 Thread Dr.Ruud
Jay Savage wrote: Dr.Ruud: Because $@ is a global, it is best practice to act on the return value of eval itself: [snip] $@ is also *guaranteed*--in the words of perlfunc--to be set correctly. I believe that historically this may not have been the case: $@ may have only been set on failure

Re: prepare(SELECT ... FROM TABLE) error

2010-02-10 Thread Jeff Peng
On Thu, Feb 11, 2010 at 2:03 AM, Jay Savage wrote: > > $@ is also *guaranteed*--in the words of perlfunc--to be set > correctly. I believe that historically this may not have been the > case: $@ may have only been set on failure and not flushed on success, > but in recent Perls it should be reliab

Re: prepare(SELECT ... FROM TABLE) error

2010-02-10 Thread Jay Savage
On Tue, Feb 9, 2010 at 8:05 PM, Dr.Ruud wrote: > Jay Savage wrote: > [snip] > Because $@ is a global, it is best practice to act on > the return value of eval itself: [snip] $@ is also *guaranteed*--in the words of perlfunc--to be set correctly. I believe that historically this may not have be

Re: prepare(SELECT ... FROM TABLE) error

2010-02-10 Thread Dr.Ruud
Jay Savage wrote: Wrap the call in an eval block. Then check $@ to see if there was a fatal error, which you can ignore if you want to or do something along the lines of: eval { my $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable"); }; if ($@) { print "Table $tabl

Re: prepare(SELECT ... FROM TABLE) error

2010-02-09 Thread Jay Savage
On Wed, Feb 3, 2010 at 9:22 PM, Tony Esposito wrote: > This question has never been answered.  To out it another way, given the code > ... > >  foreach my $mytable (@mytables) { >  my $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable"); >  # report error but move on to next table > } > > how do

Re: prepare(SELECT ... FROM TABLE) error

2010-02-05 Thread Dr.Ruud
Tony Esposito wrote: This question has never been answered. To out it another way, given the code ... foreach my $mytable (@mytables) { my $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable"); # report error but move on to next table } how do I ignore the situation/error that DBI thro

Re: prepare(SELECT ... FROM TABLE) error

2010-02-03 Thread Tony Esposito
$mytable does not exist and just move on to the next table? --- On Mon, 1/2/10, Tony Esposito wrote: From: Tony Esposito Subject: Re: prepare(SELECT ... FROM TABLE) error To: "Beginners Perl" , "7" <7stud.7s...@gmail.com> Date: Monday, 1 February, 2010, 17:02 Als

Re: prepare(SELECT ... FROM TABLE) error

2010-02-02 Thread 7
On Mon, Feb 1, 2010 at 1:40 PM, Tony Esposito wrote: > Is this the idea? I do not ever want to catch the error from the prepare > statement itsel > I thought you said the program fails if you don't catch the error? If so, and you want your program to continue executing, then you have to catch

Re: prepare(SELECT ... FROM TABLE) error

2010-02-01 Thread Tony Esposito
Also, if prepare fails, I want to continue processing -- hence the need to capture the error in my code and not have DBI::DBD throw and exception then stop all processing ... --- On Mon, 1/2/10, Tony Esposito wrote: From: Tony Esposito Subject: Re: prepare(SELECT ... FROM TABLE) error To

Re: prepare(SELECT ... FROM TABLE) error

2010-02-01 Thread Tony Esposito
t;SELECT COUNT(*) FROM mytable");    }; if ($dbh->err) {   print "Table $table -- DOES NOT EXIST\n"; } $retCode = $sth->execute();   --- On Mon, 1/2/10, 7 <7stud.7s...@gmail.com> wrote: From: 7 <7stud.7s...@gmail.com> Subject: Re: prepare(SELECT ... FROM TABLE) er

Re: prepare(SELECT ... FROM TABLE) error

2010-02-01 Thread 7
On Mon, Feb 1, 2010 at 12:11 PM, Tony Esposito wrote: > when the table does not exist the prepare fails. How do ignore the error > thrown by the prepare() and catch it later in the program? > > > my $dbh = DBI->connect("dbi:ODBC:mysql" > ,$login >

prepare(SELECT ... FROM TABLE) error

2010-02-01 Thread Tony Esposito
when the table does not exist the prepare fails.  How do ignore the error thrown by the prepare() and catch it later in the program?     my $dbh = DBI->connect("dbi:ODBC:mysql"   ,$login ,$passwd ,{ RaiseError => 0 }