Skip to Main Content
  • Questions
  • XMLQuery ORA-19114: XPST0003 - error during parsing the XQuery expression:

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Pawel.

Asked: September 19, 2017 - 11:59 am UTC

Last updated: June 04, 2018 - 4:19 pm UTC

Version: 11g

Viewed 10K+ times! This question is

You Asked

I'm doing examples from workbook. I created table and insert couple of records. Below is my code:

Create table:

CREATE TABLE test_Pracownicy
(IDPracownika NUMBER(3),
Dane XMLTYPE);
Insert record to the table:

INSERT INTO test_Pracownicy (IDPracownika, Dane)
VALUES (1,
  XMLTYPE('
    <PRecord>
      <Nazwisko>Kowalski</Nazwisko>
      <Imie>Jan</Imie>
      <RokUrodz>1980</RokUrodz>
      <Wzrost>1.77</Wzrost>
      <DataZatr>2001/02/10</DataZatr>
    </PRecord>')
);

Now I want to run XMLQuery:

SELECT IDPracownika,
  XMLQuery(
    'FOR $i IN /PRecord
      WHERE $i /Nazwisko = "Kowalski"
      ORDER BY $i/Imie
      RETURN $i'
    PASSING by VALUE Dane
    RETURNING CONTENT) NazwiskoXML
FROM test_Pracownicy;

and I'm getting error:

ORA-19114: XPST0003 - error during parsing the XQuery expression:
LPX-00801: XQuery syntax error at 'i'
1 FOR $i IN /PRecord
- ^
19114. 00000 - "error during parsing the XQuery expression: %s"
*Cause: An error occurred during the parsing of the XQuery expression.
*Action: Check the detailed error message for the possible causes.

and Chris said...

XQuery expressions are case sensitive and use lowercase keywords:

CREATE TABLE test_Pracownicy
(IDPracownika NUMBER(3),
Dane XMLTYPE);

INSERT INTO test_Pracownicy (IDPracownika, Dane)
VALUES (1,
  XMLTYPE('<PRecord>
      <Nazwisko>Kowalski</Nazwisko>
      <Imie>Jan</Imie>
      <RokUrodz>1980</RokUrodz>
      <Wzrost>1.77</Wzrost>
      <DataZatr>2001/02/10</DataZatr>
    </PRecord>')
);

set long 10000

SELECT IDPracownika,
  XMLQuery(
    'FOR $i IN /PRecord
      WHERE $i /Nazwisko = "Kowalski"
      ORDER BY $i/Imie
      RETURN $i'
    PASSING by VALUE Dane
    RETURNING CONTENT) NazwiskoXML
FROM test_Pracownicy;

SQL Error: ORA-19114: XPST0003 - error during parsing the XQuery expression: 
LPX-00801: XQuery syntax error at 'i'
1   FOR $i IN /PRecord

SELECT IDPracownika,
  XMLQuery(
    'for $i in /PRecord
      where $i /Nazwisko = "Kowalski"
      order by $i/Imie
      return $i'
    PASSING by VALUE Dane
    RETURNING CONTENT) NazwiskoXML
FROM test_Pracownicy;

IDPRACOWNIKA NAZWISKOXML                                                                     
------------ --------------------------------------------------------------------------------
           1 <PRecord>                                                                       
               <Nazwisko>Kowalski</Nazwisko>                                                 
               <Imie>Jan</Imie>                                                              
               <RokUrodz>1980</RokUrodz>                                                     
               <Wzrost>1.77</Wzrost>                                                         
               <DataZatr>2001/02/10</DataZatr>                                               
             </PRecord> 

Rating

  (4 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, September 20, 2017 - 11:51 am UTC

thanks a lot !

4est, September 20, 2017 - 11:53 am UTC

thank you!

Clarification

Deepak, May 28, 2018 - 1:42 pm UTC

Am getting this Error: ORA-19114: XPST0003 - error during parsing the XQuery expression:

Sample SQL:
SELECT (column_value).getstringval() FROM xmltable('"SLGS "&*" SLGS"');
Chris Saxon
June 04, 2018 - 4:19 pm UTC

"SLGS "&*" SLGS" is invalid XML!

What exactly are you trying to do?

A reader, June 04, 2018 - 5:02 pm UTC

You can delete post

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library