Libpq coding assistance
I am in need of some assistance in coding a c module using libpq on a
windows platform. Specifically, I need some help with providing the
input buffer for lo_write. The code sample provided in the
documentation contains this snippet:
------------
lobj_fd = lo_open(conn, lobjId, INV_WRITE);
while ((nbytes = read(fd, buffer,BUFSIZE)) > 0)
{
tmp = lo_write(conn, lobj_fd, buffer, nbytes);
if (tmp < nbytes)
fprintf(stderr, "error while reading large object\n");
}
(void) CloseHandle(fd);
(void) lo_close(conn, lobj_fd);
------------
I need to change the read() statement to use ReadFile, thus:
------------
lobj_fd = lo_open(conn, lobjId, INV_WRITE);
while (ReadFile(fd, buffer, BUFSIZE, &nbytes, NULL)!=EOF )
{
tmp = lo_write(conn, lobj_fd, buffer, nbytes);
if (tmp < nbytes)
fprintf(stderr, "error while reading large object\n");
}
(void) lo_close(conn, lobj_fd);
(void) CloseHandle(fd);
--------------
This, of course, doesn't work. The program is reported as no longer responding.
An infinite loop I suspect. If anyone is doing this or knows how to code it,
I would be grateful.
--
---------------------------------------------------------------------
Scott Holmes http://pages.sbcglobal.net/scottholmes
scottholmes@sbcglobal.net
Independent Programmer/Analyst Passport 4GL
PHP HTML Composer PostgreSQL Informix 4GL, SQL
---------------------------------------------------------------------
There are more things in heaven and earth, Horatio,
than are dreamt of in your philosophy
---------------------------------------------------------------------
Scott Holmes <scottholmes@sbcglobal.net> writes:
------------
lobj_fd = lo_open(conn, lobjId, INV_WRITE);
while ((nbytes = read(fd, buffer,BUFSIZE)) > 0)
{
}
------------
I need to change the read() statement to use ReadFile, thus:
------------
lobj_fd = lo_open(conn, lobjId, INV_WRITE);while (ReadFile(fd, buffer, BUFSIZE, &nbytes, NULL)!=EOF )
{
}
--------------This, of course, doesn't work. The program is reported as no longer
responding. An infinite loop I suspect. If anyone is doing this or
knows how to code it, I would be grateful.
Sounds like ReadFile (a Windows call?) isn't behaving the way you
think it does. Write some test code and play around with it until you
understand how it works.
-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863
Import Notes
Reply to msg id not found: ScottHolmes'smessageofSun04Nov2001115533-0800
Hi,
Is there an internal timestamp on a table when it was created?
I want to the program to perform an auto daily backup on certain tables. If
I can check time stamp on the table as when it was created, so I can set the
program to do just one backup a day.
Thanks
-Jeff
Hi,
I'm getting parser error at or near AS
when try to copy a table using CREATE TABLE AS
Here what I have in the sql statement
CREATE TABLE employee_backup (id text UNIQUE, lastname text, firstname text,
phone text) AS SELECT * FROM employee
Can some body tell me what is wrong with the sql statement?
Thank you