Hi guys,
i'm having trouble passing a pl/sql varchar2 variable to an XMLQuery.
This is the relevant part of my code:
DECLARE
lo_result XMLTYPE; --contains the XML which is being parsed below
lo_return XMLTYPE; -- for the XML result returned by XMLQuery
lo_start VARCHAR2 (100) DEFAULT 'Toronto'; -- a PL/SQL varchar2 variable
lo_end VARCHAR2 (100) DEFAULT 'Ottawa'; -- a PL/SQL varchar2 variable
BEGIN
SELECT XMLQUERY (
'for $i in //leg[start_address[text()[contains(.,$lo_start)]] and end_address[text()[contains(.,$lo_end)]]]/distance/value/text() return ($i)'
PASSING lo_result, lo_start AS "lo_start", lo_end AS "lo_end"
RETURNING CONTENT)
INTO lo_return
FROM DUAL;
END;
The XPath expression is correct but it doesn't seem to accept my variables since lo_return is empty.
I think the variables should be of type Xmltype but the compiler won't let me convert them because they do not contain any XML tags .
Hope anyone can help.
Thanks,
Martina