Re: Retrieve filename within a script

From: Vincent Veyron <vv(dot)lists(at)wanadoo(dot)fr>
To: Patrick FICHE <Patrick(dot)Fiche(at)aqsacom(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Retrieve filename within a script
Date: 2024-11-15 16:29:30
Message-ID: 20241115172930.c11b7546b49af380f2d8840f@wanadoo.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 14 Nov 2024 08:42:36 +0000
Patrick FICHE <Patrick(dot)Fiche(at)aqsacom(dot)com> wrote:

> I was wondering if it was possible to get the filename provided as an argument to psql.
> psql -f /tmp/test.sql
>

Since you know it already, you could pass it as a variable :

psql -f /tmp/test.sql -v my_path='/tmp/test.sql'

and retrieve it with SELECT :'my_path';

--
Bien à vous, Vincent Veyron

https://marica.fr
Logiciel de gestion des contentieux juridiques, des contrats et des sinistres d'assurance

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bharani SV-forum 2024-11-15 19:46:18 Need exact SQL query to find List of Detach Partitioned Tables (Yet to be Dropped)
Previous Message Andy Hartman 2024-11-15 15:49:57 Re: DB Files