Re: insert more than one rows - Mailing list pgsql-novice

From Andrej Ricnik-Bay
Subject Re: insert more than one rows
Date
Msg-id b35603930606280133q63dce707qb2358c34fde5465c@mail.gmail.com
Whole thread Raw
In response to insert more than one rows  ("roy simkes" <roysimkes@hotmail.com>)
Responses Re: insert more than one rows  ("Garcia, Joshua" <Joshua.Garcia@xerox.com>)
List pgsql-novice
On 6/28/06, roy simkes <roysimkes@hotmail.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

pgsql-novice by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: insert more than one rows
Next
From: "nitin quick"
Date:
Subject: postgres in realtime mode