Re: [GENERAL] user input during runtime
Bruce Momjian wrote: > Magnus Hagander wrote: >> 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. :-( > > CMD "language"? LOL > We have our own language? ;) Joshua D. Drake -- === The PostgreSQL Company: Command Prompt, Inc. === Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 Providing the most comprehensive PostgreSQL solutions since 1997 http://www.commandprompt.com/ Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate PostgreSQL Replication: http://www.commandprompt.com/products/ ---(end of broadcast)--- TIP 6: explain analyze is your friend
Re: [GENERAL] user input during runtime
Magnus Hagander wrote: > 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. :-( CMD "language"? LOL -- Bruce Momjian <[EMAIL PROTECTED]> http://momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. + ---(end of broadcast)--- TIP 6: explain analyze is your friend
Re: [GENERAL] user input during runtime
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 ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq
Re: [GENERAL] user input during runtime
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. > in psql. I think we will have \prompt in 8.3. Well, I guess it's not all that crucial with \prompt coming out. :) Cheers, D -- David Fetter <[EMAIL PROTECTED]> http://fetter.org/ phone: +1 415 235 3778AIM: dfetter666 Skype: davidfetter Remember to vote! ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
Re: [GENERAL] user input during runtime
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` in psql. I think we will have \prompt in 8.3. -- Bruce Momjian <[EMAIL PROTECTED]> http://momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. + ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
[GENERAL] user input during runtime
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 With Regards Ashish Karalkar