Issue with psqlrc with command line. - Mailing list pgsql-general

From saurabh shelar
Subject Issue with psqlrc with command line.
Date
Msg-id CALBKi8a0XqdUjAc3nqgoukvG=P=d91zRuozx=Jwg93Ke+Hes-A@mail.gmail.com
Whole thread Raw
Responses Re: Issue with psqlrc with command line.
List pgsql-general
Hi All,

I am facing issue while executing psqlrc alias commands via. "psql -c" option.

Please find below details:

-bash-4.2$ cat .psqlrc 
\set testing 'select * from test;'

postgres=# select version();
                                                 version                                                  
----------------------------------------------------------------------------------------------------------
 PostgreSQL 9.6.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16), 64-bit
(1 row)

postgres=# :testing
 id 
----
  1

However, it is not working with the command line.

-bash-4.2$ /opt/PostgreSQL/9.6/bin/psql -c ":testing"
ERROR:  syntax error at or near ":" at character 1
STATEMENT:  :testing
ERROR:  syntax error at or near ":"
LINE 1: :testing

As per the document from PG-9.6 it is possible. 

Apologies, If I am getting wrong. 

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: using a plpgsql function argument as a table column.
Next
From: "David G. Johnston"
Date:
Subject: Re: Issue with psqlrc with command line.