Page 1 of 1

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

Posted: Tue Dec 17, 2013 2:20 pm
by debfawn
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?

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

Posted: Thu Dec 19, 2013 7:44 pm
by JimKnicely
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

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

Posted: Fri Dec 20, 2013 4:21 pm
by debfawn
Thanks! I can add the delete command to my scripts. Good idea 8-)