Error with Variable Substitution

Moderator: NorbertKrupa

Post Reply
User avatar
fsalvelt
Intermediate
Intermediate
Posts: 54
Joined: Sun Mar 18, 2012 1:34 am

Error with Variable Substitution

Post by fsalvelt » Mon May 05, 2014 12:43 pm

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.
Thank, Fred

User avatar
Julie
Master
Master
Posts: 221
Joined: Thu Apr 19, 2012 9:29 pm

Re: Error with Variable Substitution

Post by Julie » Mon May 05, 2014 7:43 pm

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)
Thanks,
Juliette

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1806
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Error with Variable Substitution

Post by JimKnicely » Tue May 06, 2014 7:30 pm

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)
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “vSQL”