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

From: Robin Iddon <robin(at)edesix(dot)com>
To:
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Problem with /usr/local/pgsql/bin/psql
Date: 2006-04-24 09:20:24
Message-ID: 444C9858.4050701@edesix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)prabha(at)wipro(dot)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
>
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message JSP 2006-04-24 12:31:40 Re: Problem with /usr/local/pgsql/bin/psql
Previous Message Gourish Singbal 2006-04-24 05:51:16 Autovacuuming