From: Robin Iddon <robin@edesix.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Problem with /usr/local/pgsql/bin/psql
Date: Mon, 24 Apr 2006 10:20:24 +0100
Message-ID: <444C9858.4050701@edesix.com> (raw)
In-Reply-To: <D9F5C94B9B5B84458C5D2E9CE8FD26FD037F80AF@swagath.wipro.com>
References: <D9F5C94B9B5B84458C5D2E9CE8FD26FD037F80AF@swagath.wipro.com>
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
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: robin@edesix.com
Subject: Re: Problem with /usr/local/pgsql/bin/psql
In-Reply-To: <444C9858.4050701@edesix.com>
References: <D9F5C94B9B5B84458C5D2E9CE8FD26FD037F80AF@swagath.wipro.com> <444C9858.4050701@edesix.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox