Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKqjm-0005Cu-0s for pgsql-sql@arkaria.postgresql.org; Wed, 06 Jul 2016 17:35:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bKqjl-0003y0-Ke for pgsql-sql@arkaria.postgresql.org; Wed, 06 Jul 2016 17:35:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bKqjl-0003xu-0G for pgsql-sql@postgresql.org; Wed, 06 Jul 2016 17:35:49 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bKqji-0001wx-1s for pgsql-sql@postgresql.org; Wed, 06 Jul 2016 17:35:48 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 143E42010F; Wed, 6 Jul 2016 13:35:44 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Wed, 06 Jul 2016 13:35:44 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=/GPvlWoNnGHncYM+lkQwRIhBmdw=; b=kyT9sa rNX2t7AaZ3ca2imiJQqCAbDKCo22W0czAeXpM8dpzdXuOlPnWSpM2p6d24TNV2B2 sF0eiWYM3oGxM2nYxTgiO3rs6Po6QwPCm48wWZoWmMtSsSzjS2SCb8VoqCWq7u+E T3VpbKMLv16mmW677B5x09zhmzczwxpPg6Y2M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=/GPvlWoNnGHncYM +lkQwRIhBmdw=; b=dUJ9LLdrN0HOs4DaxT9j5/EUkjaZ+V5ZLggw7yU6IWqGzGa aRyUE5XZmfezffaiwSWmJkOyyNGxf/WF2YEj9SbsZEzhtrZRtO1GXfbkutMZd2HR RX+NnpjMB7X82OBHPHUFc/NvuSKRgF1/OCxukknNSyLK6sE3WZ18Bb9umyso= X-Sasl-enc: WnHKSxVyRvJkBbxORvc0h4v4arhIBHO/FXXHquaz8iB6 1467826543 Received: from [192.168.1.2] (174-24-160-10.tukw.qwest.net [174.24.160.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 8BA2CCCDB2; Wed, 6 Jul 2016 13:35:43 -0400 (EDT) Subject: Re: Exception handling in Foreign table To: Gaurav Tomar , pgsql-sql@postgresql.org References: From: Adrian Klaver Message-ID: <4c9e73a2-ab89-1d9b-5d51-bddbce04b9d3@aklaver.com> Date: Wed, 6 Jul 2016 10:35:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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