ORA-1460 while working with XML (merged 3) [message #547252] |
Tue, 13 March 2012 10:18 |
|
Hi!
I have a problem when trying to assign the value of a VARCHAR2 variable into a XMLType: ORA-1460 unimplemented or unreasonable conversion requested.
This is my code:
----------------------------------------------------------------
FUNCTION test(
xml_string IN VARCHAR2,
type IN VARCHAR2,
path_array IN VARCHAR2)
RETURN NUMBER AS
sub_xml XMLType;
index NUMBER;
path_find VARCHAR2(300);
existNode NUMBER;
number_nodes NUMBER;
xpath_main_node VARCHAR2(200);
BEGIN
number_nodes := 0;
SELECT xmltype(xml_string) INTO sub_xml from dual;
xpath_nodo_principal := '/' || tipo || 'Response/' || tipo || 'Result/child::node()';
sub_xml := sub_xml.EXTRACT(XPATH_HEADER, NAME_SPACE_GENERAL);
IF(sub_xml IS NOT NULL) THEN
...
-----------------------------------------------------------------
The error happens at SELECT xmltype(xml_string) INTO sub_xml from dual;
I really don't understand what's exactly happening cause this code works for some cases but this happens a lot too cause my application handles a lot of information. The length of xml_string in that moment is 4119.
Also the XML code I'm working with and I detected this one always goes wrong doesn't seem to have any errors.
Please I need some help here.
Thanks in advance.
|
|
|
|
|
|
Re: ORA/1460 in XML [message #547313 is a reply to message #547294] |
Tue, 13 March 2012 12:46 |
|
Sorry about the post it was my bad i think cause i tried to send the post again after an error i got.
Oracle9i
Client 8.0.6.0.0
Server 9.2.0.8.0
FUNCTION BE_P_CONTAR_NODOS_XML(
xml_string IN VARCHAR2,
tipo IN VARCHAR2,
path_arreglo IN VARCHAR2)
RETURN NUMBER AS
sub_xml XMLType;
indice NUMBER;
path_buscar VARCHAR2(300);
existeNodo NUMBER;
cantidad_nodos NUMBER;
xpath_nodo_principal VARCHAR2(200);
Lv_mensajeError VARCHAR2(200);
BEGIN
cantidad_nodos := 0;
BEGIN
SELECT xmltype(xml_string) INTO sub_xml from dual;
EXCEPTION
WHEN OTHERS THEN
Lv_mensajeError := length(Lv_XML) ||' '|| length(xml_string) ||' '|| SQLERRM;
INSERT INTO TEMP_XML VALUES (xml_string);
COMMIT;
END;
--EL XPATH ES GENERALEMNTE EN TODOS LOS REPONSE XML IGUAL A ESTE
xpath_nodo_principal := '/' || tipo || 'Response/' || tipo || 'Result/child::node()';
--SE EXTRAE LA RESPUESTA ELIMINANDO LOS ENCABEZADOS PRINCIPALES
sub_xml := sub_xml.EXTRACT(XPATH_ENCABEZADO, NAME_SPACE_GENERAL);
--EXTRAE EL CONTENIDO DE LA RESPUESTA
IF(sub_xml IS NOT NULL) THEN
--EXTRAE EL CUERPO DEL MENSAJE
sub_xml := sub_xml.EXTRACT(xpath_nodo_principal, NAME_SPACE_NODO);
LOOP
indice := cantidad_nodos + 1;
path_buscar := path_arreglo || '[' || TO_CHAR(indice) || ']';
existeNodo := sub_xml.EXISTSNODE(path_buscar, NAME_SPACE_NODO);
IF (existeNodo = 0) THEN
EXIT;
ELSE
cantidad_nodos := cantidad_nodos + 1;
END IF;
END LOOP;
ELSE
RETURN NULL;
END IF;
RETURN cantidad_nodos;
END BE_P_CONTAR_NODOS_XML;
-
Attachment: Test.txt
(Size: 3.96KB, Downloaded 2211 times)
|
|
|
|
Re: ORA/1460 in XML [message #547328 is a reply to message #547313] |
Tue, 13 March 2012 13:48 |
Solomon Yakobson
Messages: 3303 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
Spada wrote on Tue, 13 March 2012 13:46Sorry about the post
It is still a "bad post":
SQL> create or replace
2 FUNCTION BE_P_CONTAR_NODOS_XML(
3 xml_string IN VARCHAR2,
4 tipo IN VARCHAR2,
5 path_arreglo IN VARCHAR2)
6 RETURN NUMBER AS
7 sub_xml XMLType;
8 indice NUMBER;
9 path_buscar VARCHAR2(300);
10 existeNodo NUMBER;
11 cantidad_nodos NUMBER;
12 xpath_nodo_principal VARCHAR2(200);
13 Lv_mensajeError VARCHAR2(200);
14
15 BEGIN
16 cantidad_nodos := 0;
17 BEGIN
18 SELECT xmltype(xml_string) INTO sub_xml from dual;
19 EXCEPTION
20 WHEN OTHERS THEN
21 Lv_mensajeError := length(Lv_XML) ||' '|| length(xml_string) ||' '|| SQLERRM;
22 INSERT INTO TEMP_XML VALUES (xml_string);
23 COMMIT;
24 END;
25 --EL XPATH ES GENERALEMNTE EN TODOS LOS REPONSE XML IGUAL A ESTE
26 xpath_nodo_principal := '/' || tipo || 'Response/' || tipo || 'Result/child::node()';
27
28 --SE EXTRAE LA RESPUESTA ELIMINANDO LOS ENCABEZADOS PRINCIPALES
29 sub_xml := sub_xml.EXTRACT(XPATH_ENCABEZADO, NAME_SPACE_GENERAL);
30 --EXTRAE EL CONTENIDO DE LA RESPUESTA
31 IF(sub_xml IS NOT NULL) THEN
32 --EXTRAE EL CUERPO DEL MENSAJE
33 sub_xml := sub_xml.EXTRACT(xpath_nodo_principal, NAME_SPACE_NODO);
34 LOOP
35 indice := cantidad_nodos + 1;
36 path_buscar := path_arreglo || '[' || TO_CHAR(indice) || ']';
37 existeNodo := sub_xml.EXISTSNODE(path_buscar, NAME_SPACE_NODO);
38 IF (existeNodo = 0) THEN
39 EXIT;
40 ELSE
41 cantidad_nodos := cantidad_nodos + 1;
42 END IF;
43 END LOOP;
44 ELSE
45 RETURN NULL;
46 END IF;
47 RETURN cantidad_nodos;
48 END BE_P_CONTAR_NODOS_XML;
49 /
Warning: Function created with compilation errors.
SQL> show err
Errors for FUNCTION BE_P_CONTAR_NODOS_XML:
LINE/COL ERROR
-------- -----------------------------------------------------------------
20/13 PL/SQL: Statement ignored
20/40 PLS-00201: identifier 'LV_XML' must be declared
21/13 PL/SQL: SQL Statement ignored
21/25 PL/SQL: ORA-00942: table or view does not exist
28/5 PL/SQL: Statement ignored
28/32 PLS-00201: identifier 'XPATH_ENCABEZADO' must be declared
32/7 PL/SQL: Statement ignored
32/56 PLS-00201: identifier 'NAME_SPACE_NODO' must be declared
36/9 PL/SQL: Statement ignored
36/55 PLS-00201: identifier 'NAME_SPACE_NODO' must be declared
SQL>
SY.
|
|
|
Re: ORA/1460 in XML [message #547336 is a reply to message #547323] |
Tue, 13 March 2012 14:36 |
|
Alright, it seems like someone was trying to do some weird stuff in the code when I took it from there, yeah I am not the only one working on this.
I just compiled this so it should work.
Im sorry if im causing much trouble with this Im just too busy at work, painful day.
I uploaded the code in a TXT cause the forum wont let me post it.
|
|
|
|
Re: ORA/1460 in XML [message #547342 is a reply to message #547339] |
Tue, 13 March 2012 14:59 |
|
syakobson wrote on Tue, 13 March 2012 13:43Well, maybe now you'll post function call with ALL parameters?
SY.
The xml_string was uploaded before.
The other two parameters are attached.
|
|
|
Re: ORA/1460 in XML [message #547344 is a reply to message #547313] |
Tue, 13 March 2012 15:21 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
Spada wrote on Tue, 13 March 2012 13:46
Client 8.0.6.0.0
SELECT xmltype(xml_string) INTO sub_xml from dual;
Did this even exist in 8.0 client? Surely not in PL/SQL, right?
|
|
|
|
|
Re: ORA-1460 while working with XML (merged 3) [message #547498 is a reply to message #547252] |
Wed, 14 March 2012 08:07 |
Solomon Yakobson
Messages: 3303 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
Spada wrote on Tue, 13 March 2012 11:18I have a problem when trying to assign the value of a VARCHAR2 variable into a XMLType: ORA-1460 unimplemented or unreasonable conversion requested.
You are not telling the whole story. Look at function declaration - parameter xml_string is a VARCHAR2 while xml you attached is way longer that 4000 characters. It can't be passed to your function. So I don't know how did you get ORA-1460.
SY.
|
|
|
Re: ORA-1460 while working with XML (merged 3) [message #547522 is a reply to message #547498] |
Wed, 14 March 2012 09:50 |
|
syakobson wrote on Wed, 14 March 2012 07:07Spada wrote on Tue, 13 March 2012 11:18I have a problem when trying to assign the value of a VARCHAR2 variable into a XMLType: ORA-1460 unimplemented or unreasonable conversion requested.
You are not telling the whole story. Look at function declaration - parameter xml_string is a VARCHAR2 while xml you attached is way longer that 4000 characters. It can't be passed to your function. So I don't know how did you get ORA-1460.
SY.
When I do the debug the parameter it is passed without problems so I get the error ORA-1460 at this line:
SELECT xmltype(xml_string) INTO sub_xml from dual;
|
|
|
Re: ORA-1460 while working with XML (merged 3) [message #547530 is a reply to message #547498] |
Wed, 14 March 2012 10:06 |
cookiemonster
Messages: 13962 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
syakobson wrote on Wed, 14 March 2012 13:07Look at function declaration - parameter xml_string is a VARCHAR2 while xml you attached is way longer that 4000 characters. It can't be passed to your function.
It can if the function is being called by PL/SQL, varchar2 limit is 32767 in that case.
However the first thing the function does is use the parameter in a select. At which point the 4000 limit applies.
@Spada - you need to use a CLOB for the xml parameter.
|
|
|
|