Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I executed the following code.
use strict; use warnings; use DBI; my $DSN = 'dbi:Pg:dbname=manojkumar'; my $username = 'manojkumar'; my $password = 'manojkumar'; my $TABLE_NAME = "fork_log"; my $DBH = DBI->connect($DSN,$username,$password); if(fork()==0) { my $result = "insert into $TABLE_NAME(method) values('Child Su +ccess');"; if($DBH->do("$result")) { my $result = "insert into query_log(message) values('Q +uery success in fork child.');"; } else { my $result = "insert into query_log(message) values('Q +uery failed in fork child.');"; } exit; } wait(); my $result = "insert into $TABLE_NAME(method) values('Parent Success') +;"; my $STH = $DBH->do("$result");

In the above code, child process inserting values into the fork_log table and it is working fine. But in the parent the query is not executing and printing the following error.

DBD::Pg::db do failed: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

Why it is printing the above error and how can I solve this?


In reply to Execute query in fork by manoj_speed

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-18 03:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found