I am using a c program to insert the contents of mail messages into
postgresql. First, I copy the message from stdin into a char pointer which
I malloc at every line, then I use the following code to insert into a
table:

char query[1024];
PGresult *res;
...
sprint(query, "insert into mail_msg values ('%s'), message);
res = PQexec(conn, query);
...

There is obviously more than one problem here, the most important being
I'm inserting a message of undetermined length into a char array of 1024
bytes. Second, I'm not parsing the message for apostrophes or other
characters which would mess-up my query.

I'd appreciate if someone could suggest a solution to either problem, or
point me towards sample source code I could learn from. Please do not
suggest using Perl, I enjoy c even though I am still not very proficient
at it and this is a good opportunity to practice.

Thanks again,
Marc


Sat, 22 Jan 2000 13:17:26 +0000 (GMT)
Marc Tardif <admin@wtbwts.com>
pglib and long queries