As a bloody newbie when it comes to complex sql commands, I want to execute two XPath database queries where the second command uses the result of the first one:
declare
version VARCHAR2(256);
document VARCHAR2(256);
begin
select ID_VERSION into version from VERSIONTABLE where extract(VERSION_XML, '//p:contract[@id="contract-001"]', 'xmlns:p="http://www.foo.com/v1"').getClobVal() IS NOT NULL;
select ID_DOCUMENT into document from DOCUMENTTABLE where extract(DOCUMENT_XML, '//p:content[@ref='$version']', 'xmlns:p="http://www.foo.com/v1"').getClobVal() IS NOT NULL;
end;
/
The first command will always return exactly one ID_VERSION. As a result, I want to print document.
The question: how do I properly include version in the second command? Executing above commands, it outputs following error at the code position of '$version':
PLS-00181: unsupported preprocessor directive '$VERSION' [SQL State=65000, DB Errorcode=6550]
Thank you!