psql with option -c fails..

Started by akp geekover 14 years ago4 messagesgeneral
Jump to latest
#1akp geek
akpgeek@gmail.com

Hi all -

I am trying to run the psql command the following way and
it's failing . Can you please help?

psql -d mydb -c 'update tb_user set accountstatus='A'
where userid=123'

*ERROR: column "a" does not exist*
*LINE 1: ...date tb_user accountstatus=A*
*
*

Thanks for the help

Regards

#2Lonni J Friedman
netllama@gmail.com
In reply to: akp geek (#1)
Re: psql with option -c fails..

You can't enclose the query in single quotes and then also use single
quotes inside the query. Either escape the quotes inside the query,
or enclose the query in double quotes.

On Wed, Sep 21, 2011 at 7:54 AM, akp geek <akpgeek@gmail.com> wrote:

Hi all -
               I am trying to run the psql command the following way and
it's failing . Can you please help?
                psql  -d mydb  -c 'update tb_user set accountstatus='A'
where userid=123'
ERROR:  column "a" does not exist
LINE 1: ...date tb_user accountstatus=A

Thanks for the help
Regards

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
L. Friedman                                    netllama@gmail.com
LlamaLand                       https://netllama.linux-sxs.org

#3patrick keshishian
pkeshish@gmail.com
In reply to: akp geek (#1)
Re: psql with option -c fails..

On Wed, Sep 21, 2011 at 7:54 AM, akp geek <akpgeek@gmail.com> wrote:

Hi all -
               I am trying to run the psql command the following way and
it's failing . Can you please help?
                psql  -d mydb  -c 'update tb_user set accountstatus='A'
where userid=123'
ERROR:  column "a" does not exist
LINE 1: ...date tb_user accountstatus=A

Try:

psql -d mydb -c "update tb_user set accountstatus='A' where userid=123"

You need to double quotes since you are using single quotes in your SQL string.

--patrick

#4akp geek
akpgeek@gmail.com
In reply to: patrick keshishian (#3)
Re: psql with option -c fails..

Thanks a lot .. Got it

On Wed, Sep 21, 2011 at 11:01 AM, patrick keshishian <pkeshish@gmail.com>wrote:

Show quoted text

On Wed, Sep 21, 2011 at 7:54 AM, akp geek <akpgeek@gmail.com> wrote:

Hi all -
I am trying to run the psql command the following way and
it's failing . Can you please help?
psql -d mydb -c 'update tb_user set accountstatus='A'
where userid=123'
ERROR: column "a" does not exist
LINE 1: ...date tb_user accountstatus=A

Try:

psql -d mydb -c "update tb_user set accountstatus='A' where userid=123"

You need to double quotes since you are using single quotes in your SQL
string.

--patrick