Ennio-Sr <nasr.laili@tin.it> writes:
> I've been unsuccessfully trying something like this simple one:
> \! echo "insert key: ";read key; export $key;
> SELECT autore, titolo, editore FROM bibl WHERE autore like '%[$key]%'
Perhaps you want something like
regression=# \echo prompt
prompt
regression=# \set foo `read val; echo "'$val'"`
qwerty
regression=# select :foo;
?column?
----------
qwerty
(1 row)
although on the whole I think you'd be better off turning this around:
write it as a shell script and invoke psql for individual steps,
rather than the other way round. It's hard to envision a script that
needs user interaction and won't shortly thereafter need control
structures etc.
regards, tom lane