Re: Problem with /usr/local/pgsql/bin/psql

Поиск
Список
Период
Сортировка
От Robin Iddon
Тема Re: Problem with /usr/local/pgsql/bin/psql
Дата
Msg-id 444C9858.4050701@edesix.com
обсуждение исходный текст
Ответ на Problem with /usr/local/pgsql/bin/psql  (<dhanesh.prabha@wipro.com>)
Список pgsql-admin
Your problem here is quoting.  You need to escape the quotes around the
SQL strings so that the shell (I assume you're using Unix of some
flavour) doesn't interpret them:

        /usr/local/pgsql/bin/psql -d temp -c 'insert into
temp.ip_mapping_tb(ip,location)  values(\'192.100.9.51\',\'FirstFloor\')'


However, if I were you I would consider running via a file anyway - if
you save your query into a file then you can use

psql -d temp -f foo.sql

instead.  Within the file you can type your query exactly like it should
be with no special escaping required.

Hope this helps,

Robin

dhanesh.prabha@wipro.com wrote:
> Hi ,
>
>
>     I am trying to insert data into the table via shell script using
> psql command.
>     But it giving syntax error. the same query is finely working pgAdmin
> III client.
>     The query and error given below.
>
>
>     Eg:
>
>
>         ERROR:  syntax error at or near ".9" at character 85
>         LINE 1: ...pping_tb(ip,location)  values(192.100.9.51,Firs...
>
>
>         Also when i am givinf Firstfloor as First Floor it was giving
> error
>
>
>         /usr/local/pgsql/bin/psql -d temp -c 'insert into
> temp.ip_mapping_tb(ip,location)  values('192.100.9.51','First Floor')'
>
>
>         psql: FATAL:  role "Floor)" does not exist
>
>


В списке pgsql-admin по дате отправления:

Предыдущее
От: Bruno Cortes
Дата:
Сообщение: FATAL: catalog is missing attributes
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Autovacuuming