Re: insert more than one rows

From: "Garcia, Joshua" <Joshua(dot)Garcia(at)xerox(dot)com>
To: "Andrej Ricnik-Bay" <andrej(dot)groups(at)gmail(dot)com>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: insert more than one rows
Date: 2006-06-30 15:17:06
Message-ID: E00A3B716AD4C84FB97E42367015E8A00BFF10@usa5911mf01.na.xerox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

-----Original Message-----
From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org] On Behalf Of Andrej
Ricnik-Bay
Sent: Wednesday, June 28, 2006 1:34 AM
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: [NOVICE] insert more than one rows

On 6/28/06, roy simkes <roysimkes(at)hotmail(dot)com> wrote:
> Can I use the COPY command without pointing a file? Or can I point a
string
> variable to use it as source while the delimeter is something else
than the
> tab character (the | character perhaps). Or can I point a string array
> simply? (When i say point i mean to use it as datasource. Sorry for my
bad
> english)

Another alternative to the suggestion in the link Andreas provided
might be to use the COPY FROM STDIN method;
If you have your query-results in an array of strings, separator a
pipe-symbol, for example, something like the following snippet might
work for you:

PQexec(conn, "CREATE TABLE foo (a int4, b char(16), d double
precision)");
PQexec(conn, "COPY foo FROM STDIN DELIMITER AS '|'");
foreach ($my_results as &$value) {
PQputline(conn, $value);
}
PQputline(conn,"\\.\n");
PQendcopy(conn);

Cheers,
Andrej

--
Please don't top post, and don't use HTML e-Mail :} Make your quotes
concise.

http://www.american.edu/econ/notes/htmlmail.htm

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

-----Original Message-----

Is there a way to do that without using deprecated libpq copy functions?

Thanks,
Josh

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Murray Warren 2006-06-30 19:14:18 JDBC getConnection with Tomcat
Previous Message Christopher Browne 2006-06-30 03:26:39 Re: postgres in realtime mode