Page 1 of 1

Error with Variable Substitution

Posted: Mon May 05, 2014 12:43 pm
by fsalvelt
Hi,

Can someone see what i am doing wrong in the following:

Code: Select all

[dbadmin@vertica-db0]$ vsql -v test=dual -c "select * from :test"
ERROR 4856:  Syntax error at or near ":" at character 15
LINE 1: select * from :test
                      ^
I am trying to do a simple variable substitution on the command line.

Re: Error with Variable Substitution

Posted: Mon May 05, 2014 7:43 pm
by Julie
Hi,

It seems like your "select" statement being passed into vsql via the -c option is unaware of the variable. This works:

Code: Select all

[dbadmin@flygirl ~]$ vsql -v test=dual
Welcome to vsql, the Vertica Analytic Database interactive terminal.

Type:  \h or \? for help with vsql commands
       \g or terminate with semicolon to execute query
       \q to quit

dbadmin=> select * from :test;
 dummy
-------
 X
(1 row)

Re: Error with Variable Substitution

Posted: Tue May 06, 2014 7:30 pm
by JimKnicely
According to the docs with regard to the -c option, "The command must be either a command string that can be completely parsed by the server (it contains no vsql specific features), or a single meta-command."

You can try this:

Code: Select all

$  echo "\\set test dual\\\\select * from :test" | /opt/vertica/bin/vsql
 dummy 
-------
 X
(1 row)