pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Exception handling in Foreign table 2+ messages / 2 participants [nested] [flat]
* Exception handling in Foreign table @ 2016-07-06 07:39 Gaurav Tomar <gauravtomar14@gmail.com> 0 siblings, 1 reply; 2+ messages in thread From: Gaurav Tomar @ 2016-07-06 07:39 UTC (permalink / raw) To: pgsql-sql HI, I have created foreign table to read the data from the CSV file which is | separated. while reading the data from foreign table if there is any error in any row of the file the data is not getting loaded. I want to avoid that by skiping that row and continue with the next row. How can i achieve this. The table structure is as follows: CREATE FOREIGN TABLE location_ext ( id VARCHAR(80), name VARCHAR(200), description VARCHAR(400) ) SERVER file_server OPTIONS ( filename '/home/ubuntu/location.txt', FORMAT 'csv', delimiter '|', header 'true' ); and sample data is id|name|description 1|South Wing, second floor|Second floor of the Old South Wing, formerly in use by Psychiatry 2|South Wing Neuro OR 1 Old South Wing, Neuro Radiology Operation Room 1 on second floor 3|Patient's Home|Patient's Home if there is an error in 2 row than while reading the data it should skip it and load the 1 and 3 row. I also want to capture the error row (2 row) as an exception. Regards, Gaurav ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Exception handling in Foreign table @ 2016-07-06 17:35 Adrian Klaver <adrian.klaver@aklaver.com> parent: Gaurav Tomar <gauravtomar14@gmail.com> 0 siblings, 0 replies; 2+ messages in thread From: Adrian Klaver @ 2016-07-06 17:35 UTC (permalink / raw) To: Gaurav Tomar <gauravtomar14@gmail.com>; pgsql-sql On 07/06/2016 12:39 AM, Gaurav Tomar wrote: > HI, > > I have created foreign table to read the data from the CSV file which is > | separated. > while reading the data from foreign table if there is any error in any > row of the file the data is not getting loaded. I want to avoid that by > skiping that row and continue with the next row. > How can i achieve this. > > The table structure is as follows: > > CREATE FOREIGN TABLE location_ext > ( > id VARCHAR(80), > name VARCHAR(200), > description VARCHAR(400) > ) SERVER file_server > OPTIONS ( filename '/home/ubuntu/location.txt', FORMAT 'csv', delimiter > '|', header 'true' ); > > and sample data is > > id|name|description > 1|South Wing, second floor|Second floor of the Old South Wing, formerly > in use by Psychiatry > 2|South Wing Neuro OR 1 Old South Wing, Neuro Radiology Operation Room 1 > on second floor > 3|Patient's Home|Patient's Home > > if there is an error in 2 row than while reading the data it should skip > it and load the 1 and 3 row. > I also want to capture the error row (2 row) as an exception. I don't think that is possible. Just like COPY it is all or nothing. > > Regards, > > Gaurav > -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2016-07-06 17:35 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2016-07-06 07:39 Exception handling in Foreign table Gaurav Tomar <gauravtomar14@gmail.com> 2016-07-06 17:35 ` Adrian Klaver <adrian.klaver@aklaver.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox