Postgres - how to skip "sequence" columns

Postgres - how to skip "sequence" columns

am 12.04.2010 16:58:10 von php-db

Is it possible to skip column(s) in the target table when using
pg_copy_from? When I tried to bulk insert some data from a csv
file by way of pg_copy_from I received the error "Warning:
pg_copy_from() [function.pg-copy-from]: Copy command failed:
ERROR: permission denied for relation xyz", pretty much as I
expected since things look like:

CREATE SEQUENCE xyz;
CREATE TABLE some_table (
id int NOT NULL PRIMARY KEY DEFAULT nextval('xyz')
....
(i.e. the first column is automatically populated by the db itself).

The csv file contains only data for the second and subsequent
columns, so anyway needs to "hop right" one column.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Postgres - how to skip "sequence" columns

am 13.04.2010 00:48:34 von dmagick

Gary . wrote:
> Is it possible to skip column(s) in the target table when using
> pg_copy_from? When I tried to bulk insert some data from a csv
> file by way of pg_copy_from I received the error "Warning:
> pg_copy_from() [function.pg-copy-from]: Copy command failed:
> ERROR: permission denied for relation xyz", pretty much as I
> expected since things look like:
>
> CREATE SEQUENCE xyz;
> CREATE TABLE some_table (
> id int NOT NULL PRIMARY KEY DEFAULT nextval('xyz')
> ...
> (i.e. the first column is automatically populated by the db itself).

It seems not from looking at the php manual.

You could use http://www.php.net/manual/en/function.pg-put-line.php instead.

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Postgres - how to skip "sequence" columns

am 13.04.2010 08:48:09 von php-db

On 4/13/10, Chris wrote:
> Gary . wrote:
>> Is it possible to skip column(s) in the target table when using
>> pg_copy_from?
....
> It seems not from looking at the php manual.
>
> You could use http://www.php.net/manual/en/function.pg-put-line.php instead.

Yeah. I was hoping to use pg_copy_from to avoid looping over the array
in php, but I can do that. Thanks.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php