Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Passing PL/SQL varchar2 variable to XML Query

Martina1018Apr 23 2013 — edited Apr 23 2013
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2013
Added on Apr 23 2013
5 comments
11,586 views