From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | David Fetter <david(at)fetter(dot)org> |
Cc: | Bruce Momjian <bruce(at)momjian(dot)us>, Ashish Karalkar <ashish(dot)karalkar(at)info-spectrum(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: user input during runtime |
Date: | 2007-02-17 17:48:39 |
Message-ID: | 45D73FF7.7060908@hagander.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
David Fetter wrote:
> On Fri, Feb 16, 2007 at 08:23:48PM -0500, Bruce Momjian wrote:
>> Ashish Karalkar wrote:
>>> Hello All,
>>> I want to prompt user to input some value and do some action on that value in runtime of a sql script.
>>> Is there any psql command to do this ??
>>> I can use \echo do display massage
>>> but to take input what is the command?
>>> Thanks in advance
>> You can do:
>>
>> \echo -n 'Enter value: '
>> \set x `read && echo $REPLY`
>
> Neat trick! Is there one that works on all our supported platforms?
> I'm guessing Win32 will just get confused about backticks.
Win32 will deal with the backticks Ok, but not the read && echo part.
You can set it to the output of a variable, for example
\set x `echo foo`
but I haven't been able to trick it into actually reading something. One
would think something like:
\set x `set /p Z= && echo %Z%`
would work, but it doesn't. One reason for this is that %Z% is actually
resolved at parsing time. it's a pain in CMD language, but that's how it
works. :-(
//Magnus
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-02-17 18:06:12 | Re: How do I use returning in a view? |
Previous Message | David Fetter | 2007-02-17 17:30:59 | Re: user input during runtime |