Hello,
We are using PQputline function for copying data to database
Postgres version 7.2.4
Following is the code snapshot:
We are taking data from one database, 100 records at time and storing that records in string array "strArr"
After filling "strArr", we are passing this string array to PQputline as follows:
res = PQexec(conn, "COPY <tablename> from STDIN");
PQclear(res);
i = 0;
while(true) {
status = PQputline(conn,strArr[i]); //contains one row of data
if(status != 0) {
cout<<endl<<"Unable to send string: "<< strArr[i] <<endl;
if (status == EOF) {
cout<<endl<<"status is EOF"<<endl;
}
}
i++;
if(i > 100) {
break;
}
}
status = PQputline(conn, "\\.\n"); // terminator line
status = PQendcopy(conn);
Sometime above code works fine but at sometime PQputline returns EOF and code goes in hang state for PQendcopy function.
How to recognize, why PQputline sends EOF?
Please provide me some help regarding what action must be taken when PQputline returns EOF or PQputline unable to send the line to server.
Also how to avoid the hang state of postgres server in PQendcopy function
Thanks,Soni