The application dies when insertion fails.

Поиск
Список
Период
Сортировка
От Antai Ning
Тема The application dies when insertion fails.
Дата
Msg-id F72CDFC92CAA204A9BE73476EED3821D015E5F@JETMAIL
обсуждение исходный текст
Список pgsql-general
<p><font size="2">Hi Gurus,</font><p><font size="2">This has been bothered me for a couple of days. I wrote a postgres
dbapplication in perl which parses a syslog file and inserts some data into a table. I put the actual insertion in a
evalblock, so the application won't die when insertion fails. But it doesn't work as I expected. When it encounter a
"DBD::Pg::stexecute failed: ERROR:  Bad timestamp external representation 'Jan 11 18:05:50   at (eval 9) line 426,
<MSGS>line 1." error, the whole program die.</font><p><font size="2">I'm using DBD::Pg intereface, postgres
7.1.3.Here is the codes:</font><p><font
size="2">-----------------------------------------------------------------------</font><br/><font size="2">my $dbh =
DBI->connect("dbi:Pg:dbname=$dbname",$dbuser,$dbpass,{AutoCommit=> 0,RaiseError => 1,PrintError => 0}) ||
die"Unable to connect to $dbname on $dbhost [$DBI::errstr]\n";</font><p><font size="2">while(1)</font><br /><font
size="2">{</font><br/>        <font size="2"># reading from MSGS and parsing here</font><p>        <font size="2">$sth
=$dbh->prepare("insert into http_request</font><br />                                <font
size="2">(INTERFACE_ID,INTERFACE_DIR,REQUEST_TIME,SRC,URL,result_id)</font><br/><font size="2">                       
values(?,?, ?, ?, ?, ?)");</font><p>        <font size="2">eval {</font><br /><font size="2">         
$sth->execute($ifid,$idir,$timestamp,$userip,$destip,$rid);</font><br/><font size="2">         
$sth->finish;</font><br/><font size="2">          $dbh->commit;</font><br />        <font
size="2">};</font><p>       <font size="2">if($@)</font><br />        <font size="2">{</font><br /><font
size="2">               print "Insert failed\n";</font><br /><font size="2">                print "$@";</font><br
/>       <font size="2">}</font><br /><font size="2">}</font><p><font
size="2">---------------------------------------------------------------------------</font><p><fontsize="2">I noticed
thatthe timestamp is not valid, but the excution should continue. Strange thing is that it didn't die right away. After
print"$@"prints out the error "DBD::Pg::st execute failed: ERROR:  Bad timestamp external representation 'Jan 11
18:05:50  at (eval 9) line 426, <MSGS> line 1." it dies.</font><p><font size="2">So what do I miss
here?</font><p><fontsize="2">Thanks in advance!</font><br /><p><font size="2">Andy</font> 

В списке pgsql-general по дате отправления:

Предыдущее
От: Darren Ferguson
Дата:
Сообщение: Re: connection refused problem
Следующее
От: Tom Lane
Дата:
Сообщение: Re: horrendous query challenge :-)