am trying to run the below query and facing some error.
Using putty so added escape character('\') before '$'.
db2 "SELECT XMLQUERY (
'for \$d in \$doc/Client/fax
passing CONTACTINFO as "doc")
ERROR: SQL16005N An XQuery expression references an element name, attribute name,
type name, function name, namespace prefix, or variable name "doc" that is not
defined within the static context. Error QName=err:XPST0008. SQLSTATE=10506
your help will be highly apreciable.
This topic has been locked.
2 replies Latest Post - 2011-12-23T04:52:55Z by SystemAdmin
Pinned topic XMLQUERY help
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2011-12-23T04:52:55Z at 2011-12-23T04:52:55Z by SystemAdmin
MatthiasNicola 120000E28R303 PostsACCEPTED ANSWER
Re: XMLQUERY help2011-12-21T11:31:10Z in response to SystemAdminYou can avoid a lot of problems if you don't try to run such queries with the db2 command at the operating system prompt. The escaping of $-signs, the use of quotes, etc. can all interfere when the OS is parsing the input string.
Here are two alternatives that usually work better:
Enter the DB2 command line processor with this command: db2 -t
Then you get the db2 prompt that looks like this:
There you can enter you queries without having to escape anything, and that avoids a lot of problems. The -t option means that each query needs to be terminated with the semicolon character.
Type your query into a text file and save it, e.g. as myquery.sql. Then run the query with the following command:
db2 -tvf myquery.sql
Hope this helps.