I'm converting a script from Teradata to Netezza, and I'm stuck at the portion where BTEQ uses the functionality of the OS to check if a file contains any data. If it does, it is deleted. I want to perform the same function in nzsql.

Can anyone please help?


The documentation for nzsql states that to shell-out you just have to use blackslash pling, followed by the command:

\! command

If you need to know how to test for file size in a shell script, you can use something similar to:

if [[ -f $file ]] && [[ -s $file ]]; then 
  echo "File exists and is greater than 0 bytes" ; 
  rm -f $file

-f checks that it exists, -s checks if it's greater than 0 bytes.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.