Re: REPEATED INSERT INTO ... 2nd thread

From: Neil Conway <neilc(at)samurai(dot)com>
To: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: REPEATED INSERT INTO ... 2nd thread
Date: 2003-02-25 16:59:59
Message-ID: 1046192387.427.13.camel@tokyo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2003-02-25 at 03:59, Christoph Haller wrote:
> for (CmdIndex = start_index; CmdIndex < nRows; CmdIndex++)
> {
> sprintf(CmdLine,
> "INSERT INTO AArray_Values ( Primary_Key, List_Pointer,\
> Parameter_Name, Parameter_Code,\
> Dim_Pointer, File_Pointer, Source_Type )\
> VALUES ( %d,%d,'%s',%d,%d,%d,'%s' );",
> AArray_Values[CmdIndex].primary_key,
> AArray_Values[CmdIndex].value_list_ptr,
> AArray_Values[CmdIndex].parameter_name,
> AArray_Values[CmdIndex].parameter_code,
> AArray_Values[CmdIndex].dim_pointer,
> AArray_Values[CmdIndex].file_pointer,
> AArray_Values[CmdIndex].source_type);
> /*
> call PQexec() to process
> */
> }
> How would you replace this by COPY?

something like ...

PQexec("COPY xxx FROM stdin");
for (...)
{
sprintf(buf, "%d\t%d\t...\n",
values[0], values[1], ... values[n]);
PQputline(conn, buf);
}
PQputline(conn, "\\.\n");
PQendcopy(conn);

Cheers,

Neil
--
Neil Conway <neilc(at)samurai(dot)com> || PGP Key ID: DB3C29FC

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeroen T. Vermeulen 2003-02-25 17:14:42 Re: I cant find it or I'm just lazy ?
Previous Message Lee Kindness 2003-02-25 15:58:51 Re: Thread safe ecpg