Solved

Oracle xpath

Posted on 2011-03-02
15
841 Views
Last Modified: 2012-05-11
Experts...

I created a function where in I pass the xml and am trying to update it within the function. It compiled fine but when I try to run it in an anonymous block I get this error
ORA-30625: method dispatch on NULL SELF argument is disallowed

here is my code

I have this xml in a variable v_xml

I pass it to a function

get_dtls_fn(i_xml xmltype)
return xmltype
IS
v_xml2 xmltype;
begin
select UPDATEXML(i_xml, '/decsn/fs/arp/text()', '5') into v_xml2 from dual;
return v_xml2;
end;

and when I call this function from an anonymous block like

set serveroutput on;
v_clob clob:=null;
v_xml1 xmltype;
begin
-- crdt_aplcn_oid,rte_one_fnc_src_id,crdt_dcsn_oid
v_xml1:=get_dtls_fn(v_xml);  -- v_xml I get if from another function call and this is a valid xml
v_clob := v_xml.getClobVal();
v_num:= 1;
dbms_output.put_line('vxml' || v_clob);
end;

I get the following error ORA-30625: method dispatch on NULL SELF argument is disallowed

what is the solution here    
0
Comment
Question by:chickanna
  • 6
  • 6
  • 3
15 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 250 total points
ID: 35020387
You need to look at what is being returned from:  get_dtls_fn(v_xml);

I cannot reproduce the error hardcoding your sample xml.
create or replace function get_dtls_fn(i_xml xmltype)
return xmltype
IS
  v_xml2 xmltype;
begin
select UPDATEXML(i_xml, '/decsn/fs/arp/text()', '5') into v_xml2 from dual;
return v_xml2;
end;
/

show errors

set serveroutput on;

declare
v_clob clob:=null;
v_xml1 xmltype;
begin
v_xml1:= xmltype('<decsn> <fs> <fstype> 2 </fstype> <fscmp>abc</fscmp> </fs> </decsn>');
v_clob := v_xml1.getClobVal();
dbms_output.put_line('vxml' || v_clob);
end;
/

Open in new window

0
 
LVL 73

Expert Comment

by:sdstuber
ID: 35020405
I don't have your v_xml declaration or the procedure that is populating it so I can't verify that.

However, using the xml content from your previous question
I constructed this test case and it works.

Note I changed the "getclob"  to be for v_xml1  not v_xml


CREATE OR REPLACE FUNCTION get_dtls_fn(i_xml XMLTYPE)
    RETURN XMLTYPE
IS
    v_xml2   XMLTYPE;
BEGIN
    SELECT UPDATEXML(i_xml, '/decsn/fs/arp/text()', '5') INTO v_xml2 FROM DUAL;

    RETURN v_xml2;
END;


DECLARE
    v_clob   CLOB := NULL;
    v_xml1   XMLTYPE;
    v_xml    XMLTYPE
        := xmltype(
               '<decsn> <fs> <fstype> 2 </fstype> <fscmp>abc</fscmp> <arp>3.4</arp> </fs> </decsn>');
BEGIN
    v_xml1  := get_dtls_fn(v_xml);
    v_clob  := v_xml1.getclobval();
    DBMS_OUTPUT.put_line('vxml' || v_clob);
END;

Open in new window

0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35020410
>>You need to look at what is being returned from:  get_dtls_fn(v_xml);

duh...

I meant to say the function where you get  v_xml
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35020430
I can't even reproduce that error with completely different XML:

...
v_xml1:= xmltype('<moe> <larry> <curley> 2 </curley> </larry> </moe>');
...
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 35020464
Note,  if your v_xml isn't properly initialized you'll get the error you are reporting.
I'd look at your OTHER routine that is supposed to be populating v_xml.

DECLARE
    v_clob   CLOB := NULL;
    v_xml1   XMLTYPE;
    v_xml    XMLTYPE;
       -- := xmltype(
         --      '<decsn> <fs> <fstype> 2 </fstype> <fscmp>abc</fscmp> <arp>3.4</arp> </fs> </decsn>');
BEGIN
    v_xml1  := get_dtls_fn(v_xml);   -- you'll get an error here because v_xml isn't initalized
    v_clob  := v_xml1.getclobval();
    DBMS_OUTPUT.put_line('vxml' || v_clob);
END;
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35020506
Please ignore what I posted in http:#a35020387

I copied/pasted wrong and sdstuber beat me to the code example.
0
 

Author Comment

by:chickanna
ID: 35020674
Okay.. experts .. here is what is happening.

The function where I get v_xml from is in a package called PKG_GET_RSO_DETAILS and the function name is get_rso_dtls which takes 3 input parameters.

I want to add the call to my function get_dtls_fn inside get_rso_details.

The current return value from get_rso_details is v_xml. I want to replace this with the call

v_xml:=get_dtls_fn(v_xml);

where inside the function get_dtls_fn the UPDATEXML statement is executed and an xmltype is returned.

my anonymous block is now

set serveroutput on;
declare v_xml xmltype;
v_clob clob:=null;
begin
v_xml:=PKG_GET_RSO_DETAILS.get_rso_dtls(54958300,'ABC',54945663);
v_clob := v_xml.getClobVal();
v_num:= 1;
dbms_output.put_line('vxml' || v_clob);
end;

When I execute this code I get the error
 ORA-30625: method dispatch on NULL SELF argument is disallowed
ORA-06512: at line 5

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 73

Expert Comment

by:sdstuber
ID: 35020693
PKG_GET_RSO_DETAILS.get_rso_dtls(54958300,'ABC',54945663);


this function call is not returning a valid xmltype
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35020699
The only way I reproduce that error is if I pass null into the function you wrote.

You can either change your function to handle null input or ensure you don't pass a null into the function.

0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35020704
forgot the example:

...
v_xml:=get_dtls_fn(null);
...

0
 
LVL 73

Expert Comment

by:sdstuber
ID: 35020707
You'll have to figure out where that function is going wrong.
Once it's fixed calling your get_dtls_fn function is a trivial addition.
0
 

Author Comment

by:chickanna
ID: 35020885
sdstuber, the call  PKG_GET_RSO_DETAILS.get_rso_dtls(54958300,'ABC',54945663);
is returning a valid xml. The last line in the function has return v_xml where v_xml is built before by a select statement. Only if I add a call to my function like

v_xml:=get_dtls_fn(v_xml);
return v_xml;

I get the error. If I dont add the call to my function and print out the xml I see the xml in the output. My function seems to be ok as all it is doing is getting an input xml and updating an element and returning an xmltype. don't you agree? Not sure how to correct this error.
0
 
LVL 73

Assisted Solution

by:sdstuber
sdstuber earned 250 total points
ID: 35020926
how do you know you are getting valid xml?

your last example code in http#35020674  produces the error but doesn't call your new function.
it only calls get_rso_dtls, and it gets the  error

So clearly your new function isn't the problem.

check if get_rso_dtls is returning NULL
0
 

Author Closing Comment

by:chickanna
ID: 35021422
Thank you experts. As you have written, the v_xml was returning null values in some cases. Once I fixed it my new function worked beautifully. Thanks again.
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 35021459
How does the "Accepted" post contribute to the answer?  As indicated by slightwv, that post should be ignored.

I believe http:#35020464 would be more appropriate since it's the first post to mention that your other routine is returning something uninitialized (ie NULL)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now