Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pG1zm-00065m-Hx for pgsql-general@arkaria.postgresql.org; Thu, 12 Jan 2023 18:08:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pG1zl-0002JU-D2 for pgsql-general@arkaria.postgresql.org; Thu, 12 Jan 2023 18:08:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pG1zl-0002Ec-2K for pgsql-general@lists.postgresql.org; Thu, 12 Jan 2023 18:08:09 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pG1zi-00071I-Lu for pgsql-general@lists.postgresql.org; Thu, 12 Jan 2023 18:08:08 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 852795C0103; Thu, 12 Jan 2023 13:08:05 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 12 Jan 2023 13:08:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1673546885; x=1673633285; bh=f 8DVPU5/oXbKXOjo7jFw8m6mcG3nUUFOsux+3u5StPY=; b=mx9BBHu6By9VV9AaQ QMhAETfcoTNdy1Z8ECnemToYHOc6a8S/lPWNQrQjHcKOm+3V7e0nn0bTKnfyBa7s 3cx48vLMzauGaQmXi/JXXA233/KyhlaoVsJYIxqs7nytnbp+q3Dk45jQvezxL8au b//KQGtKzHo0JyaqrVzAYCh3F5gXMBrcIlmNT0wMz0zr4j3qBS/Ucv0nZovXfDdX UXZymHSZgbeUHstt+Vfjj+n3CL5fw5ArFLVHwVO1Oo3+YuOcALUehOzI1zFt3CmE RG5YHwD+GwE4vJJa66FsMGL/uPbsu/US1H/JhA8SM1yXZrRhgQX//3i39381ihW0 IULQQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleeigddutdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfggtggugfgjsehtke ertddttdejnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhr vgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpedvkedtffduff dtffffheffhfejjefhgfeiueeukeejkeffgfdufffhudffffeuveenucffohhmrghinhep vghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhr gh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Jan 2023 13:08:05 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 59F171D; Thu, 12 Jan 2023 19:04:08 +0100 (CET) Date: Thu, 12 Jan 2023 19:04:08 +0100 From: Alvaro Herrera To: Ron Cc: "pgsql-general@lists.postgresql.org" Subject: Re: gexec from command prompt? Message-ID: <20230112180408.b7hhh3ypdnthpa7i@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <00a37956-d2b1-3749-9747-66d0d562ac90@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Jan-12, Ron wrote: > Postgresql 12.11 > > This might be more of a bash question, or it might be a psql vs engine problem. > > I want to run this query using psql from a bash prompt: > select format('SELECT ''%s'', MIN(part_date) FROM %s;', table_name, table_name) > from dba.table_structure > order by table_name\gexec Yeah, what I use in these cases is something like echo "select format('SELECT ''%s'', MIN(part_date) FROM %s;', table_name, table_name) from dba.table_structure order by table_name \gexec" | psql -f- -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "El hombre nunca sabe de lo que es capaz hasta que lo intenta" (C. Dickens)