Re: Doing a \set through perl DBI ?

From: David Gauthier <davegauthierpg(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Doing a \set through perl DBI ?
Date: 2018-06-06 20:53:14
Message-ID: CAMBRECA_KefdGs8_dCgxY06o=-Jv=XxkmWoP1VBWXr=eUECLyQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I think I found my own answer. I wanted to use the current linux user's
uid as part of a query (again, this is a perl/DBI script). I was thinking
I might be able to set a variable into the DB session somehow using \set
through DBI to accomplish this. The solution that finally occurred to me
was to create a temporary table and have the perl script shove the uid into
a column in that table, then query against that. Sort of like using a temp
table to store variables set from outside.

On Wed, Jun 6, 2018 at 11:46 AM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Wednesday, June 6, 2018, David Gauthier <davegauthierpg(at)gmail(dot)com>
> wrote:
>
>> Hi:
>>
>> Is there a way to do the equivalent of a "\set foo 1" through perl dbi ?
>> I tried...
>> $dbh->do("\\set foo 1");
>> and got a syntax error
>>
>> Of course, I'd also have to be able to access the value of foo once its
>> set. I'm guessing the usual way ??? (select :foo)
>>
>>
> No. Meta commands are psql client program only. You'd need to explain
> why you want this to get reasonable server-side suggestions.
>
> David J.
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jerry Sievers 2018-06-06 21:00:28 Re: Which backend using which pg_temp_N schema?
Previous Message Adrian Klaver 2018-06-06 20:45:48 Re: Which backend using which pg_temp_N schema?