Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL: ORA-19102: XQuery string literal expected (Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi)
PL/SQL: ORA-19102: XQuery string literal expected [message #463629] Fri, 02 July 2010 05:34 Go to next message
rahulvb
Messages: 924
Registered: October 2009
Location: Somewhere Near Equator.
Senior Member

CREATE TABLE xmlTable (Xml XMLType) 

declare 
  poXML CLOB;
BEGIN   
  -- Store the Purchase Order XML in the CLOB variable
  poXML := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
            <PurchaseOrder>
              <PONum>1001</PONum>
              <Company>Oracle Corp</Company>
            </PurchaseOrder>';
  -- Insert the Purchase Order XML into an XMLType column
  INSERT INTO xmlTable (xml) VALUES (XMLTYPE(poXML));

--Handle the exceptions
EXCEPTION
  WHEN OTHERS THEN 
    raise_application_error(-20101, 'Exception occurred :'||SQLERRM);
end ;



Error

  INSERT INTO xmlTable (Xml) VALUES (XMLTYPE(poXML));
                        *
ERROR at line 11:
ORA-06550: line 11, column 25:
PL/SQL: ORA-19102: XQuery string literal expected
ORA-06550: line 11, column 3:
PL/SQL: SQL Statement ignored


I am not sure why I am getting this error ...and i got this snippet from Oracle Site


its Solution may be very simple but some how I am not getting it Smile

so F1
Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463632 is a reply to message #463629] Fri, 02 July 2010 05:43 Go to previous messageGo to next message
Michel Cadot
Messages: 68761
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
1/ Remove thei stupid WHEN OTHERS clause
2/
SQL> CREATE TABLE xmlTable (Xml XMLType) ;

Table created.

SQL> declare 
  2    poXML CLOB;
  3  BEGIN   
  4    -- Store the Purchase Order XML in the CLOB variable
  5    poXML := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  6              <PurchaseOrder>
  7                <PONum>1001</PONum>
  8                <Company>Oracle Corp</Company>
  9              </PurchaseOrder>';
 10    -- Insert the Purchase Order XML into an XMLType column
 11    INSERT INTO xmlTable (xml) VALUES (XMLTYPE(poXML));
 12  
 13  --Handle the exceptions
 14  EXCEPTION
 15    WHEN OTHERS THEN 
 16      raise_application_error(-20101, 'Exception occurred :'||SQLERRM);
 17  end ;
 18  /
  INSERT INTO xmlTable (xml) VALUES (XMLTYPE(poXML));
                        *
ERROR at line 11:
ORA-06550: line 11, column 25:
PL/SQL: ORA-19102: XQuery string literal expected
ORA-06550: line 11, column 3:
PL/SQL: SQL Statement ignored

SQL> rename xmltable to x;

Table renamed.

SQL> declare 
  2    poXML CLOB;
  3  BEGIN   
  4    -- Store the Purchase Order XML in the CLOB variable
  5    poXML := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  6              <PurchaseOrder>
  7                <PONum>1001</PONum>
  8                <Company>Oracle Corp</Company>
  9              </PurchaseOrder>';
 10    -- Insert the Purchase Order XML into an XMLType column
 11    INSERT INTO x  (xml) VALUES (XMLTYPE(poXML));
 12  
 13  end;
 14  /

PL/SQL procedure successfully completed.


3/ Do not use reserved word as table name. Before creating anything, query v$reserved_words.

Regards
Michel
Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463633 is a reply to message #463629] Fri, 02 July 2010 05:49 Go to previous messageGo to next message
rahulvb
Messages: 924
Registered: October 2009
Location: Somewhere Near Equator.
Senior Member
Ah.. Embarassed My bad there.
Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463635 is a reply to message #463632] Fri, 02 July 2010 06:01 Go to previous messageGo to next message
ramoradba
Messages: 2457
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
Quote:
I am not sure why I am getting this error ...and i got this snippet from Oracle Site

Event its from Oracle Don`t copy and paste directly .Analyze it Wink
sriram Smile
Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463636 is a reply to message #463635] Fri, 02 July 2010 06:07 Go to previous messageGo to next message
rahulvb
Messages: 924
Registered: October 2009
Location: Somewhere Near Equator.
Senior Member
ramoradba wrote on Fri, 02 July 2010 06:01
Quote:
I am not sure why I am getting this error ...and i got this snippet from Oracle Site

Event its from Oracle Don`t copy and paste directly .Analyze it Wink
sriram Smile



Sirram,

Accidentally I have rename the table to keyword Smile and Never thought about it that that could be a keyword Very Happy

-Rahul
Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463637 is a reply to message #463636] Fri, 02 July 2010 06:13 Go to previous messageGo to next message
ramoradba
Messages: 2457
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
Quote:
Remove thei stupid WHEN OTHERS clause


@ Michel ,
If its really a stupid one ,why not Oracle drop the clause in current/upcoming releases...
Just asking... Wink

sriram
Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463638 is a reply to message #463637] Fri, 02 July 2010 06:16 Go to previous messageGo to next message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
ramoradba wrote on Fri, 02 July 2010 06:13
Quote:
Remove thei stupid WHEN OTHERS clause


@ Michel ,
If its really a stupid one ,why not Oracle drop the clause in current/upcoming releases...
Just asking... Wink

sriram


When WHEN OTHERS is not followed by RAISE its almost always a BUG.
At times, you can not cover all the exceptions in your exception handler and then you need to specify WHEN OTHERS as the last exception to handle if any exception occured.

Use of WHEN others without raise is like you hide the actual exception raised. It becomes difficult to debug if you use NULL just after WHEN OTHERS, so remove it to find out the actuall error.Well, I found some strange behaviour when WHEN OTHERS exception is not followed by RAISE. I did remove all the WHEN OTHERS exceptions from the procedure and then found that the actual error was something else. Thanks to Tom Kyte for his article on this topic for which I could solve the problem in a short span of time.


Michel would give a proper reply to your question I believe.





Regards
Ved

[Updated on: Fri, 02 July 2010 06:30]

Report message to a moderator

Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463640 is a reply to message #463638] Fri, 02 July 2010 06:25 Go to previous messageGo to next message
ramoradba
Messages: 2457
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
I know that Ved..Thats Even I suggested that so many times in my replies..
I am just asking why not Oracle thinking /planning in that way of coding.thats why I put that wink over there in my previous reply.
Seems It will be long discussion from others so I quit from this.(I know the person from which I can get a next message)

sriram
Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463643 is a reply to message #463640] Fri, 02 July 2010 06:32 Go to previous messageGo to next message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
Quote:

In Oracle Database 11g, I can easily find the offending bits of code..


Have a look at this link by Tom Kyte

Read the topic WHEN OTHERS Then Null Redux

Regards
Ved

[Updated on: Fri, 02 July 2010 06:46]

Report message to a moderator

Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463646 is a reply to message #463643] Fri, 02 July 2010 06:44 Go to previous messageGo to next message
ramoradba
Messages: 2457
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
Thanks for the link...
sriram
Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463657 is a reply to message #463637] Fri, 02 July 2010 07:52 Go to previous messageGo to next message
Michel Cadot
Messages: 68761
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
ramoradba wrote on Fri, 02 July 2010 13:13
@ Michel ,
If its really a stupid one ,why not Oracle drop the clause in current/upcoming releases...
Just asking... Wink

sriram

SQL> alter session set PLSQL_Warnings = 'enable:all';

Session altered.

SQL> create or replace procedure p
  2  is
  3  begin
  4    raise_application_error(-20000,'Error');
  5  exception when others then null;
  6  end;
  7  /

SP2-0804: Procedure created with compilation warnings

SQL> sho err
Errors for PROCEDURE P:
LINE/COL
---------------------------------------------------------------------------------
ERROR
-----------------------------------------------------------------------------------------

5/16
PLW-06009: procedure "P" OTHERS handler does not end in RAISE or RAISE_APPLICATION_ERROR

SQL> @v

Version Oracle : 11.1.0.6.0

Oracle did it but only if you want. I think every developer should set this parameter when writing application code.

Regards
Michel

Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463660 is a reply to message #463657] Fri, 02 July 2010 08:05 Go to previous messageGo to next message
ramoradba
Messages: 2457
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
Thanks Michel for the Example.
Yes ,I missed the point.Need to re-read again.
Once again Thank you.

sriram Smile
Re: PL/SQL: ORA-19102: XQuery string literal expected [message #463662 is a reply to message #463660] Fri, 02 July 2010 08:28 Go to previous message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
Its there in the link..
Quote:

Quote:

In Oracle Database 11g, I can easily find the offending bits of code..



Regards
Ved
Previous Topic: insert query problem
Next Topic: ORA-02019: connection description for remote database not found
Goto Forum:
  


Current Time: Mon Jul 21 04:44:07 CDT 2025