Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vBJKu-00EuoY-PL for pgsql-admin@arkaria.postgresql.org; Tue, 21 Oct 2025 20:52:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vBJKt-00BxU7-PF for pgsql-admin@arkaria.postgresql.org; Tue, 21 Oct 2025 20:52:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vBJKt-00BxTq-Dq for pgsql-admin@lists.postgresql.org; Tue, 21 Oct 2025 20:52:02 +0000 Received: from mail-vs1-xe35.google.com ([2607:f8b0:4864:20::e35]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vBJKq-003Uap-0l for pgsql-admin@lists.postgresql.org; Tue, 21 Oct 2025 20:52:02 +0000 Received: by mail-vs1-xe35.google.com with SMTP id ada2fe7eead31-59dff155dc6so3059783137.3 for ; Tue, 21 Oct 2025 13:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761079918; x=1761684718; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=w9sHYbFX6PGZ4+tJs6MYYpziBJrLJfUtx4twq7oO/wA=; b=ld0GrgylsWQ3NhM8bUIOlKuZhbqVl4y0ElodUocp5FPJlTA3g2MfTNsE4LENZKtt72 2E8ZWwM3TQCWSJRjHHQsv6J4uSjGHmmCbbKu0kiX47Y4WhpZg6bx9EHagocNqMAn/Fr4 fQ8O8y5pwnC8vmZIMo43PcC8DfKiFRmx/bp96ydse0YEt8y+oiQavKWg2Yjw3PBxm4dm lNUpmFHpHBO4F/mmDHoY4q1EyUKuL/45yODVs5t6jTx62V/2Hq0ZgF3VwZPeYhOey42a 6wa6UYtgVNAkot4HrfH+55AZ+yzm4btbBcerSeXv74lQO5yGMfB4qylvjwCAVxm9Rn32 fXTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761079918; x=1761684718; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=w9sHYbFX6PGZ4+tJs6MYYpziBJrLJfUtx4twq7oO/wA=; b=TBzCiWHT98w1Vky+9ErG9tYR1EZ3x/AC7rohiJmNSs61CEdUO7j+MHCZNdoyeVT2Ky Q1NC7LkfWzFkmlPGqSLSWLyzNOqPJ1WXak4CLQvifF7o4/dg3S4SsawxVefTEayGIyE1 r0vnZkd2Nedu63w48QkccdgYA9JW0nX/lhyY4PbfaJ8ATkURWOTp//cIPXfT9gUtT2xM brVr+i6ZtnnHdZeBYnl7hAMw2za9t599AdGrUvSkdlY5Bukj5lrE2TCVyZHUkyRCsNvW E11Xz6GpgG5c7fbdhxUDUVvjZ6u5SvpPvrE+RSsccJb1J0t5Oe1gjgaliyowH7+4arIo mtww== X-Gm-Message-State: AOJu0Yw8y4+QG5Wbh0ctMODHlOow+txl/+xienuqFVvBTLhpFQcT/9vm 10qMuNoSwennQNGbiD3XftkB5IR8gQVVU7TN1MYCmwUjIsKZ1EOPqqgvrVfSJTBawYQP6InoWyE RgXMKEMBs2+WINJ1TUNsX2ZsRzppz40NujXbf X-Gm-Gg: ASbGncvtCsh6nsXYAM4hXOOLYsKBmfoPNKMDDbUyzmBNDM/uCb+bx/lESVVCfZrFerT TiQ39fB8cpwfVRjQx2dh2fkHDq2g0pnCzZgtlfxQY7TgKkWvAOsmApylgnX13Cz+Pin8AJdRtQs tXyNosWerEWrWy1w0iMaQLaZGrE6wVpdKEvWFCLErbw5+QHKAop1nuh+PooL8Zo1HJFB0OFLj5N +abX59JqgPuVJjcS80MqkNaUqM+1f0ELeh0jH9UArCmToOk6JXi0r/x57KUwHO15PDAl/3ko9oC 5jgrIw5hhe9KaWWWNWBKcXckA2lXGkXc2VkXQMI= X-Google-Smtp-Source: AGHT+IHsljmbtzgZzKCQY9SlCH6S4mnTsJzcdiK1Z71d7jp9aHTLqNTWKu3n3DyGueLQzhHpNwd5UwPTa9fzvP1c2xU= X-Received: by 2002:a05:6102:3f16:b0:57d:9305:63db with SMTP id ada2fe7eead31-5d7dd5956d2mr4828826137.15.1761079917578; Tue, 21 Oct 2025 13:51:57 -0700 (PDT) MIME-Version: 1.0 From: Mauricio Fernandez Date: Tue, 21 Oct 2025 17:51:46 -0300 X-Gm-Features: AS18NWBz_ujcOyLlkJ22U479nOnJMMUKyoTiofL8c4xNtSymAzNkI2aacWkA5Kk Message-ID: Subject: Script generation through psql To: Pgsql-admin Content-Type: multipart/alternative; boundary="000000000000e88f160641b15e7c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000e88f160641b15e7c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi community I'm trying to generate an script file as the output from psql script been called from linux bash, and I've two issues: The bash call is like: psql -U myusr-d mydb -f ./scr.sql > $UPD_FILE 2>&1 $ cat scr.sql \set vl_id 19 \set ECHO none \pset tuples_only on \pset pager off select script_drop from proceso_actualiza_fdw where id =3D :vl_id; select script_import from proceso_actualiza_fdw where id =3D :vl_id; \q 1.- The output file is like : *Pager usage is off.* -- *+* -- BORRADO DE TABLAS MODIFICADAS + How can I eliminate "*Pager usage is off." *and the *"+" *at the end of each row? 2. If in the psql script I want to pass variable values from an anonymous block to the rest of the script, how can I proceed?. For example DO $$ DECLARE vl_id integer; BEGIN -- vl_id is set inside the procedure call my_procedure(*vl_id*); END $$; select script_drop from proceso_actualiza_fdw where id =3D :*vl_id*; select script_import from proceso_actualiza_fdw where id =3D :*vl_id*; The script output file is the result set from the queries. I've tried with \set myvar but this doesn't works Thank you very much in advance kind regards Mauricio Fern=C3=A1ndez --000000000000e88f160641b15e7c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi community=C2=A0

I'm trying to ge= nerate an script file as the output from psql script been called from linux= bash, and I've two issues:

The bash call is like:

psql -U myusr-d mydb -f ./scr.sql > $UPD_FILE 2&= gt;&1

$ cat scr.sql
\set vl_id 1= 9
\set ECHO none
\pset tuples_only on
\pset pager off

selec= t script_drop from proceso_actualiza_fdw where id =3D :vl_id;

select= script_import from proceso_actualiza_fdw where id =3D :vl_id;

\q

1.- The output=C2=A0file is like :
Page= r usage is off.
=C2=A0-- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+
=C2=A0-- BORRADO DE TA= BLAS MODIFICADAS =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+

How can I eliminate "Pager usage is off."= and the "+"=C2=A0 at the end of each row?
<= br>
2. If in the psql script I want to pass variable values from = an anonymous block to the rest of the script,=C2=A0how can=C2=A0I proceed?.= For example

DO $$
DECLARE
=C2=A0 vl_id inte= ger;
BEGIN
=C2=A0-- vl_id is set inside the procedure
=C2=A0 call = my_procedure(vl_id);
END $$;

select scri= pt_drop from proceso_actualiza_fdw where id =3D :vl_id;

selec= t script_import from proceso_actualiza_fdw where id =3D :vl_id;

The script output file is the result set=C2=A0from the= queries.

I've tried=C2=A0with \set myvar but = this doesn't works

Thank you very much in adva= nce

kind regards

Mauricio= Fern=C3=A1ndez
--000000000000e88f160641b15e7c--