From: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
---|---|
To: | Mauricio Ferrari <mautuc(at)yahoo(dot)com(dot)ar> |
Cc: | lista postgres <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: enviar sentencias a psql desde script |
Date: | 2004-12-20 23:39:11 |
Message-ID: | 20041220233911.GA3781@dcc.uchile.cl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
On Mon, Dec 20, 2004 at 08:17:25PM -0300, Mauricio Ferrari wrote:
Hola,
> read TABLA
>
> psql Base < DELETE FROM $TABLA
>
> echo LA TABLA $TABLA FUE VACIADA!.
>
> y el error que me da es que no existe el archivo, he
> probado tambien asignando la sentencia a una variable
> pero me dice redireccion ambigua.
Una redireccion < toma el nombre de un archivo. Si quieres pasarle un
string, necesitas un pipe:
echo "DELETE FROM $tabla" | psql Base
O mas facil aun, usa -c de psql:
psql Base -c "DELETE FROM $tabla"
--
Alvaro Herrera (<alvherre[(at)]dcc(dot)uchile(dot)cl>)
"Someone said that it is at least an order of magnitude more work to do
production software than a prototype. I think he is wrong by at least
an order of magnitude." (Brian Kernighan)
From | Date | Subject | |
---|---|---|---|
Next Message | Cachorios | 2004-12-21 10:34:29 | RE: Power Builder y Postgresql |
Previous Message | Mauricio Ferrari | 2004-12-20 23:17:25 | enviar sentencias a psql desde script |