VSQL command to return only the output

Moderator: NorbertKrupa

Post Reply
arun2986
Newbie
Newbie
Posts: 5
Joined: Fri Jul 27, 2012 5:31 pm

VSQL command to return only the output

Post by arun2986 » Fri Jul 27, 2012 5:38 pm

Hi All,
I have a requirement where i need to connect vertica from Perl and store the result in a variable.
For eg.
$var=vsql -c "select count(*) from tableA";

Whenever i try to fetch the value , i get the whole result as

count
-------
7
(1 row)

This whole result is stored in the variable. Iam expecting the value 7 alone to be stored in the variable. Is there an inbuilt functionality which can do it , similar to db2 -x "select count(*) from tableA" ?

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

Re: VSQL command to return only the output

Post by JimKnicely » Fri Jul 27, 2012 6:08 pm

Hi arun2986 ,

Welcome to the forums!

Please check out the post:

viewtopic.php?f=18&t=236

This should work for you:

Code: Select all

$var=vsql -At -c "select count(*) from tableA";
Jim Knicely

Image

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

arun2986
Newbie
Newbie
Posts: 5
Joined: Fri Jul 27, 2012 5:31 pm

Re: VSQL command to return only the output

Post by arun2986 » Fri Jul 27, 2012 8:23 pm

Thanks a lot Jim. That helps.

Post Reply

Return to “Vertica SQL”