Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYvPo-0003wv-39 for pgsql-general@arkaria.postgresql.org; Mon, 17 Dec 2018 16:06:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gYvOn-0008HW-0p for pgsql-general@arkaria.postgresql.org; Mon, 17 Dec 2018 16:05:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYuOW-0000bY-5i for pgsql-general@lists.postgresql.org; Mon, 17 Dec 2018 15:01:20 +0000 Received: from resqmta-ch2-07v.sys.comcast.net ([2001:558:fe21:29:69:252:207:39]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYuOT-0007Yz-E0 for pgsql-general@lists.postgresql.org; Mon, 17 Dec 2018 15:01:18 +0000 Received: from resomta-ch2-11v.sys.comcast.net ([69.252.207.107]) by resqmta-ch2-07v.sys.comcast.net with ESMTP id YsdLgfqyZS6EHYuONgZMKw; Mon, 17 Dec 2018 15:01:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20161114; t=1545058871; bh=7/hnXzNbt24cB7nL5kkE2jH4PBkGty/a7gCLn/k0m6U=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: MIME-Version:Content-Type; b=TixQyfUrnVgRR/DbmXdjORV7AZKGJLiuhHMd5tAhx7BazMvBKivJ5FvEuhVKDrbu8 qnKBFd/I+Chdjm4JMD8b0p+y9e/QhazcbuPQbzbre29wD3OAQU/3BLIexSgXXRkq7H Bs76vBf1RIuGakgueZYfhEa/zst2JjPoIYZOWNi3rbWl+WIzDd+x0PD70JttzQ4uhW PJqT17O2c72nlJS8maQEE6uOMSc43KgFWuysvVTrd/dq6mqfquCPxP9aN7OVvqt6yo SgWn3Og8HbVHAKpIPSo/ywpB70EUrgyiG9PhhUlKpj2S+y5z20G1o7RqrpF185/6o+ Jk0S5lS2AyqBQ== Received: from jsievers.comcast.net ([71.57.79.23]) by resomta-ch2-11v.sys.comcast.net with ESMTPA id YuOMg10q6V20XYuONgHl58; Mon, 17 Dec 2018 15:01:11 +0000 Received: from jsievers.enova.com (localhost [127.0.0.1]) by jsievers.comcast.net (Postfix) with ESMTP id 41642260056; Mon, 17 Dec 2018 09:01:10 -0600 (CST) From: Jerry Sievers To: hamann.w@t-online.de Cc: pgsql-general@lists.postgresql.org Subject: Re: conditionally terminate psql script References: Date: Mon, 17 Dec 2018 09:01:10 -0600 In-Reply-To: (hamann w.'s message of "17 Dec 2018 13:07:22 -0000") Message-ID: <87efag2o5l.fsf@jsievers.enova.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-CMAE-Envelope: MS4wfDqW21/r4rWx0HCswgNusdShAzpzeCM+ncQ8MlLEQfrd5uI1vlRL+nlIz6YI1Zt/qnQ9plDej05BQ2J0v/NJalkMw2t4kSxiJI3yU6gC6zNMSFsu1x2L OCqg5tuiz0c9U/PhX3GF+4poxe+t2XsjlPCb6XlOeLo1YhjW8q04NnaQWh4DJg61Q4pJDlNqcJtSvHDjyHRXLTY1edOP8I59eU6/NGedTRmrCPm9AtXcuJs1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk hamann.w@t-online.de writes: > Hi, > > many thanks -- too bad I am still using 9.3 Just because your server backend is 9.3 does not rule out using much newer clients, such as psql. HTH > > Best regards > Wolfgang > >>> Hi >>> >> po 17. 12. 2018 v 13:14 odes=C3=ADlatel napsa= l: >>> >> > >>> > >>> > Hi, >>> > >>> > is there a way to stop execution of a psql script if a select returns= some >>> > rows (or no rows) >>> > The idea is to add a safety check on data, specifically to select all= new >>> > rows that would conflict >>> > on a bulk insert, show them and stop >>> > >>> >> you need psql from PostgreSQL 10 and higher >>> >> there is a \if statement >>> >> Regards >>> >> Pavel >>> >> > >>> > Best regards >>> > Wolfgang >>> > >>> > >>> > >>>=20 > > > > > > --=20 Jerry Sievers e: jerry.sievers@comcast.net p: 312.241.7800