0

There is probably a very simple solution to this, but I've tried every variation I could think of and still not able get rid of the error:

I'm running this via a shell script:

su - myid -c 'db2 -v "EXPORT TO '/tmp/file.out' OF DEL MODIFIED BY COLDEL| select A, B, C FROM mytable where C = '' and ( F = 1 or F = 2 or F = 3 or F = 4 ) "'

And this is the error I am getting:

SQL0104N  An unexpected token "=   and ( status" was found following "mytable
where C".  Expected tokens may include:  "<space>".  SQLSTATE=42601

Any help would be greatly appreciated

0

2 Answers 2

1

You could use an ANSI-quoted string if you are using bash:

su - myid -c $'db2 -v "EXPORT TO \'/tmp/file.out\'...'

in which you can quote a single quote using \'. In POSIX shells, you'll have to use double-quotes, and quote the embedded double-quotes:

su - myid -c "db2 -v \"EXPORT TO '/tmp/file.out' ..."
Sign up to request clarification or add additional context in comments.

Comments

0

I figured it out. Here's my updated query:

su - myid -c 'db2 -v "EXPORT TO '/tmp/file.out' OF DEL MODIFIED BY COLDEL| select A, B, C FROM mytable where C = '\'''\''  and ( F = 1 or F = 2 or F = 3 or F = 4 ) "'

I had to replace the single '' with '\'''\'' <---those are all single quotes

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.