Re: misc psql questions
От | Peter Eisentraut |
---|---|
Тема | Re: misc psql questions |
Дата | |
Msg-id | Pine.LNX.4.30.0102151928270.1211-100000@peter.localdomain обсуждение исходный текст |
Ответ на | misc psql questions (James Thompson <jamest@math.ksu.edu>) |
Список | pgsql-general |
James Thompson writes: > About a lifetime ago I used to do quite a bit of work w/ Oracle. > > It's command line sql tool had some pretty nice features that I haven't > been able to find in psql. I was wondering if any of the following > existed.... > > I think the first was called break on which altered in output from > something like > > name date qty > ------------------------- > Fred 01-JAN-2000 10 > Fred 10-JAN-2000 13 > Fred 01-JUL-2000 1 > Fred 01-DEC-2000 100 > Bob 01-JAN-2000 5 > Bob 10-MAY-2000 10 > > to > > name date qty > ------------------------- > Fred 01-JAN-2000 10 > 10-JAN-2000 13 > 01-JUL-2000 1 > 01-DEC-2000 100 > Bob 01-JAN-2000 5 > 10-MAY-2000 10 > > it also allowed for things like compute sum which would activate on breaks > but I don't recall how they worked. This seems to be a thing for a report generator. Try pgaccess. > The other thing I'd love to be able to do is get user input while running > a sql file. I don't recall how this worked exactly but the script would > either accept variables calling the script or prompt for them. > > So if I had a sql script in a file named contact_report. And I did > > prod=> \i contact_report 01-JAN-2000 31-DEC-2001 > > then it would load the script and replace IIRC &1 and &2 with the > respective dates listed on command line. You can use \set to set variables. > It also had an ACCEPT command that would cause it to prompt for input from > user and assign to a varable name. Try \echo -n 'Prompt: ' \set varname `read input; echo $input` -- Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/
В списке pgsql-general по дате отправления: