Is there any ways to pass an array as parameter in libpq?

Поиск
Список
Период
Сортировка
От ChenXun
Тема Is there any ways to pass an array as parameter in libpq?
Дата
Msg-id COL110-W156A65650A94CA1246FA24E2B90@phx.gbl
обсуждение исходный текст
Ответы Re: Is there any ways to pass an array as parameter in libpq?  (Craig Ringer <craig@postnewspapers.com.au>)
Re: Is there any ways to pass an array as parameter in libpq?  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
.hmmessage P {margin:0px;padding:0px;} body.hmmessage {font-size:10pt;font-family:Verdana;} 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




Messenger保护盾2.0,更安全可靠的Messenger聊天! 现在就下载!

В списке pgsql-general по дате отправления:

Предыдущее
От: Dave Page
Дата:
Сообщение: [ANNOUNCE] PGDay.EU 2009 - registration deadline extended
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: Why does pg_dump set default_with_oids to true?