[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 884
  • Last Modified:

Oracle xpath

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
chickanna
Asked:
chickanna
  • 6
  • 6
  • 3
2 Solutions
 
slightwv (䄆 Netminder) Commented:
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
 
sdstuberCommented:
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
 
slightwv (䄆 Netminder) Commented:
>>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
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

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

...
v_xml1:= xmltype('<moe> <larry> <curley> 2 </curley> </larry> </moe>');
...
0
 
sdstuberCommented:
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
 
slightwv (䄆 Netminder) Commented:
Please ignore what I posted in http:#a35020387

I copied/pasted wrong and sdstuber beat me to the code example.
0
 
chickannaAuthor Commented:
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
 
sdstuberCommented:
PKG_GET_RSO_DETAILS.get_rso_dtls(54958300,'ABC',54945663);


this function call is not returning a valid xmltype
0
 
slightwv (䄆 Netminder) Commented:
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
 
slightwv (䄆 Netminder) Commented:
forgot the example:

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

0
 
sdstuberCommented:
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
 
chickannaAuthor Commented:
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
 
sdstuberCommented:
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
 
chickannaAuthor Commented:
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
 
sdstuberCommented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now