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 1pG1K7-0001rX-7j for pgsql-general@arkaria.postgresql.org; Thu, 12 Jan 2023 17:25:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pG1K6-0005Es-3x for pgsql-general@arkaria.postgresql.org; Thu, 12 Jan 2023 17:25:06 +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 1pG1K5-0005Eg-NO for pgsql-general@lists.postgresql.org; Thu, 12 Jan 2023 17:25:05 +0000 Received: from mail-yb1-xb2b.google.com ([2607:f8b0:4864:20::b2b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pG1K3-0006cH-ML for pgsql-general@lists.postgresql.org; Thu, 12 Jan 2023 17:25:05 +0000 Received: by mail-yb1-xb2b.google.com with SMTP id p188so19523727yba.5 for ; Thu, 12 Jan 2023 09:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:subject:from:content-language:to :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=CtL5a434lPw3ZI2VPp+ZgdGZEER/i9i98IE1f3pv4hA=; b=qNjHs7Hzv0ehKAATZdr4FomiWz7lS22yTCUzFkstTgjmHA+ElxTklDKOkCMGgU0emz IkpAAQzN4H+y5csdXQfOy69k7sGGxpiaLQNmkGzWc4QSU9i8JbekgrL0tejn37Or7ZTl ecQjewy0RL9PQR4x58xZRZgtww+xZztQlqwfgL5A6EtvpuxOhMA+y1Sopb6ijaKS32E6 z20g+H7EOQyUTiQBUFE3MhoGh//EXjUAcJrSlKz8vq5QqAf7dbzUIMUoEAEvfzWknTnL hSoBvDZ4OSzewFIqWkLkaav+SFCSGxSp7cCNHFL9wf4UtFAewWWQcBDbYG+l6wOVfcQ2 l7PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:content-language:to :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=CtL5a434lPw3ZI2VPp+ZgdGZEER/i9i98IE1f3pv4hA=; b=1Gn0VCfgVBtu42ScmvbI6M0B6XL2OC4rY2fEhRA8EZK1RJzID9GJlm0XAOrGNEJPZ8 khh/QmWdpoK/phbZzxKw6S4Oim/z1S3yX/MnuoUGE466cAoWJ93p4tFsFnhmftXcMxzA AoF76tXEaRhC0sOTTy35AiPDWSzNiy7TaicW0S9O8UOkLlLw3ZIX6HTdtdH6rE0p1JLN +MniBXuh5yMLZE2JmKuEnV0dBsO3ff5v8jkEKmUAs5oX9ZAIPMvcJvlcw73Oga06WZ8f y4tGa+GzB+RpZbQZsNMVT8bN79dEAXXD8d5E5xcWVtiOpkN9m19VCXE/bFWixmMSUujM lWlA== X-Gm-Message-State: AFqh2kqctP5BdrWQv3ol25L84ZWYy8+j5cqAMwD98XiO1H496ieCusXu +P1INMHngy7SY4nOjawIJcpko7cANzggrw== X-Google-Smtp-Source: AMrXdXs3n8lYN/G2WbbRe3dbXA/BJDNYG1rCkckxf0VFHKD5G0p6JGZv8E0iz3qutS/SlP6FLL9T+w== X-Received: by 2002:a25:4015:0:b0:7c9:fd95:421b with SMTP id n21-20020a254015000000b007c9fd95421bmr1762983yba.60.1673544301557; Thu, 12 Jan 2023 09:25:01 -0800 (PST) Received: from [192.168.1.66] (108-250-206-84.lightspeed.nworla.sbcglobal.net. [108.250.206.84]) by smtp.googlemail.com with ESMTPSA id x4-20020a05620a258400b006fca1691425sm11192904qko.63.2023.01.12.09.25.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Jan 2023 09:25:01 -0800 (PST) Message-ID: <00a37956-d2b1-3749-9747-66d0d562ac90@gmail.com> Date: Thu, 12 Jan 2023 11:25:00 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 To: "pgsql-general@lists.postgresql.org" Content-Language: en-US From: Ron Subject: gexec from command prompt? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 Thus, I added an extra back $ psql sides -atXc "select format('SELECT ''%s'', MIN(part_date) FROM %s;', table_name, table_name) from dba.table_structure order by table_name limit 5\\gexec" select format('SELECT ''%s'', MIN(part_date) FROM %s;', table_name, table_name) from dba.table_structure order by table_name limit 5\gexec ERROR:  syntax error at or near "\" LINE 1: ...) from dba.table_structure order by table_name limit 5\gexec Removing "\\exec" from the statement, and appending -c "\\gexec" to the psql command technically worked, but did not run the commands. -- Born in Arizona, moved to Babylonia.