Set variable to value containing a space

Moderator: NorbertKrupa

Post Reply
hopewell
Beginner
Beginner
Posts: 29
Joined: Wed Mar 27, 2013 10:39 pm

Set variable to value containing a space

Post by hopewell » Mon Feb 23, 2015 2:35 pm

Hi all,

How can I set a variable equal to a value that contains a space?

If I do it the following the strings data1 and data2 are concatenated:

Code: Select all

dbadmin=> \set myvar data1 data2
dbadmin=> \echo :myvar
data1data2
If I use quotes, I get the space, but I also get the quotes:

Code: Select all

dbadmin=> \set myvar "data1 data2"
dbadmin=> \echo :myvar
"data1 data2"
I don't want the quotes!

Thank you

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

Re: Set variable to value containing a space

Post by JimKnicely » Mon Feb 23, 2015 3:46 pm

Try single quotes:

Code: Select all

dbadmin=> \set myvar 'data1 data2'
dbadmin=> \echo :myvar
data1 data2
Jim Knicely

Image

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

hopewell
Beginner
Beginner
Posts: 29
Joined: Wed Mar 27, 2013 10:39 pm

Re: Set variable to value containing a space

Post by hopewell » Mon Mar 02, 2015 3:37 pm

Nice, thanks Jim!

Post Reply

Return to “vSQL”