XML functions
Posted in 2014
Topics: Stored Procedures & SPL, Jobs, Consulting & Announcements
Hi community.
Do you have experience in using XML functionality in IDS 11.50? There are a
sample .NET program and stored procedure later in this topic. The problem is -
the program starts 100 parallel threads with test_existsnode functions. As a
result existsnode function execution time grows till more than 30 seconds and
the program receives {"ERROR [HY000] [Informix .NET
provider][Informix]Function (existsnode) Exception received for ICU memory
allocation."}. Perhaps I am doing something wrong. Another possible way for
problem resolving is to use any alternative way - working datablade module
(also commercial) or use any self-made module (but also working). Please
comment.
Regards.
Promised .NET program:
public static void test_existsnode()
{
try
{
var x = new List<int>();
for (var i = 0; i < 100; i++)
{
x.Add(i);
}
Parallel.ForEach(x, (i) =>
{
using (var db = new Db("test_existsnode", i))
{
var dr = db.Reader;
while (dr.Read())
{
}
}
});
}
catch (Exception ex)
{
throw ex;
}
}
Promised stored procedure:
CREATE PROCEDURE test_existsnode(p_i INT) RETURNING INT;
DEFINE v_i INT;
FOR v_i IN (1 TO 1000)
RETURN p_i WITH RESUME;
RETURN v_i WITH RESUME;
RETURN
existsnode('<decl_plan><row><id_nodoklmaks>990969903</id_nodoklmaks></row></decl
_plan>','/decl_plan') WITH RESUME;
RETURN
existsnode('<decl_plan><row><id_nodoklmaks>990969903</id_nodoklmaks></row></decl
_plan>','/decl_plan/row[1]/id_nodoklmaks') WITH RESUME;
RETURN
existsnode('<decl_plan><row><id_nodoklmaks>990969903</id_nodoklmaks></row></decl
_plan>','/decl_plan/row[2]/id_nodoklmaks') WITH RESUME;
RETURN
extractvalue('<decl_plan><row><id_nodoklmaks>990969903</id_nodoklmaks></row></de
cl_plan>','/decl_plan/row[1]/id_nodoklmaks') WITH RESUME;
RETURN
extractvalue('<decl_plan><row><id_nodoklmaks>990969903</id_nodoklmaks></row></de
cl_plan>','/decl_plan/row[2]/id_nodoklmaks') WITH RESUME;
END FOR;
END PROCEDURE;
Hello, John.
I am not familiar with this kind of loops in procedures, but....
Have you tried to run a simple statement into your .net program, like the ones
showed in Knowledge Center pages?
Eg1:
SELECT [fields] FROM [table]
WHERE existsnode(warehouse_spec, '/Warehouse/Docks') = 1;
Eg2:
SELECT extractvalue(col2, '/personnel/person[3]/name/given') FROM tab;
I suppose you are facing those memory issues because of the size of your
projection, or a very long resultset. Those examples are extracting from
relational data, so if you are extracting from a XML document, you might
change the code to your specific needs.
In case you can use a simple one, just to test, remove your loop, or set it to
execute only once, and test it.
I think you might be trying to reinvent the wheel....
Hope it helps.
Regards.
Alexandre Marini
IBM Informix Certified Professional v10 / v11.50 / v11.70 / v12.10
IBM Information Management Informix Technical Professional
IBM Certified Developer - Informix Genero
BRIUG website administrator
Informix independent consultant
> To: ids@iiug.org
> From: ifmx@inbox.lv
> Subject: XML functions [34325]
> Date: Wed, 10 Dec 2014 04:11:53 -0500
>
> Hi community.
>
> Do you have experience in using XML functionality in IDS 11.50? There are a
> sample .NET program and stored procedure later in this topic. The problem is
-
> the program starts 100 parallel threads with test_existsnode functions. As a
> result existsnode function execution time grows till more than 30 seconds and
> the program receives {"ERROR [HY000] [Informix .NET
> provider][Informix]Function (existsnode) Exception received for ICU memory
> allocation."}. Perhaps I am doing something wrong. Another possible way for
> problem resolving is to use any alternative way - working datablade module
> (also commercial) or use any self-made module (but also working). Please
> comment.
>
> Regards.
>
> Promised .NET program:
>
> public static void test_existsnode()
>
> {
>
> try
>
> {
>
> var x = new List<int>();
>
> for (var i = 0; i < 100; i++)
>
> {
>
> x.Add(i);
>
> }
>
> Parallel.ForEach(x, (i) =>
>
> {
>
> using (var db = new Db("test_existsnode", i))
>
> {
>
> var dr = db.Reader;
>
> while (dr.Read())
>
> {
>
> }
>
> }
>
> });
>
> }
>
> catch (Exception ex)
>
> {
>
> throw ex;
>
> }
>
> }
>
> Promised stored procedure:
>
> CREATE PROCEDURE test_existsnode(p_i INT) RETURNING INT;>
> DEFINE v_i INT;
>
> FOR v_i IN (1 TO 1000)
>
> RETURN p_i WITH RESUME;
>
> RETURN v_i WITH RESUME;
>
> RETURN
>
existsnode('<decl_plan><row><id_nodoklmaks>990969903</id_nodoklmaks></row></decl
_plan>','/decl_plan')
> WITH RESUME;
>
> RETURN
>
existsnode('<decl_plan><row><id_nodoklmaks>990969903</id_nodoklmaks></row></decl
_plan>','/decl_plan/row[1]/id_nodoklmaks')
> WITH RESUME;
>
> RETURN
>
existsnode('<decl_plan><row><id_nodoklmaks>990969903</id_nodoklmaks></row></decl
_plan>','/decl_plan/row[2]/id_nodoklmaks')
> WITH RESUME;
>
> RETURN
>
extractvalue('<decl_plan><row><id_nodoklmaks>990969903</id_nodoklmaks></row></de
cl_plan>','/decl_plan/row[1]/id_nodoklmaks')
> WITH RESUME;
>
> RETURN
>
extractvalue('<decl_plan><row><id_nodoklmaks>990969903</id_nodoklmaks></row></de
cl_plan>','/decl_plan/row[2]/id_nodoklmaks')
> WITH RESUME;
>
> END FOR;
> END PROCEDURE;
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>