No result set produces file with size zero (prefer no file)

Moderator: NorbertKrupa

Post Reply
debfawn
Beginner
Beginner
Posts: 47
Joined: Tue Jan 29, 2013 2:30 pm

No result set produces file with size zero (prefer no file)

Post by debfawn » Tue Dec 17, 2013 2:20 pm

Good morning!

From the vsql command line, I am running a query which does not produce a result set. The -o option creates a file having a size of zero.

Example:

Code: Select all

[dbadmin@vertica-1]$ vsql -Atc "select * from dual where 1 = 2" -o /home/dbadmin/test.txt
[dbadmin@vertica-1]$ ls -lrt /home/dbadmin/test.txt
-rw-r--r--. 1 dbadmin verticadba 0 Dec 17 08:13 /home/dbadmin/test.txt
I would prefer Vertica NOT to create the file at all if the query has no result set.

Is that possible?

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

Re: No result set produces file with size zero (prefer no fi

Post by JimKnicely » Thu Dec 19, 2013 7:44 pm

Hi,

Maybe you can tag on a find and delete onto your command line?

Example:

Code: Select all

[dbadmin@v1 ~]$ vsql -Atc "select * from dual where 1 = 2" -o /home/dbadmin/test.txt; find /home/dbadmin/test.txt -size 0 -delete
[dbadmin@v1 ~]$ ls -lrt /home/dbadmin/test.txt
ls: cannot access /home/dbadmin/test.txt: No such file or directory
Jim Knicely

Image

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

debfawn
Beginner
Beginner
Posts: 47
Joined: Tue Jan 29, 2013 2:30 pm

Re: No result set produces file with size zero (prefer no fi

Post by debfawn » Fri Dec 20, 2013 4:21 pm

Thanks! I can add the delete command to my scripts. Good idea 8-)

Post Reply

Return to “vSQL”