From: | ChenXun <p(dot)smasher(at)hotmail(dot)com> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Is there any ways to pass an array as parameter in libpq? |
Date: | 2009-10-27 00:07:17 |
Message-ID: | COL110-W156A65650A94CA1246FA24E2B90@phx.gbl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
I'm starting to learn programming with libpq.
In the main loop of my code, I will receive some data in the format of an array of a struct. The data will be inserted to the database, in different lines.
I also need to update the last record in the table before the insertion. So I plan to write a pl/pgsql function (procedure) to perform the whole updating and inserting.
But I don't know how to pass the array to the procedure through libpq. It seems the only way is to using libpq to do updating and inserting separately. Like this
for(;;) {
/* receive data */
/* libpq updating */
PQexec(...);
PQprepare(...);
for (i=0; i<n; i++) {
/* libpq inserting */
PQexecPrepared()...
}
}
The PQprepare function has to be called in each loop.So my question is that whether there is a method to pass the array as parameter to libpq?
Best regards,
Xun
_________________________________________________________________
MSN十周年庆典,查看MSN注册时间,赢取神秘大奖
http://10.msn.com.cn
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2009-10-27 01:10:03 | Re: drop view and recreate - for sync |
Previous Message | John R Pierce | 2009-10-26 23:17:53 | Re: Implementing Frontend/Backend Protocol TCP/IP |