dbTalk Databases Forums  

DB2 SQL16003N URSOR IDENTIFIED IN FETCH OR CLOSE STATEMENT IS NOTOPEN!!

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss DB2 SQL16003N URSOR IDENTIFIED IN FETCH OR CLOSE STATEMENT IS NOTOPEN!! in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
scv1977
 
Posts: n/a

Default DB2 SQL16003N URSOR IDENTIFIED IN FETCH OR CLOSE STATEMENT IS NOTOPEN!! - 04-26-2010 , 09:18 PM






Hi
I'm currently conversioning mssql to DB2(V9.7 Fix1)
The MSSQL has sources(SP,Function,XML Parsing)
In the SP(MSSQL) source, exists sp_xml_preparedocument function.
And we convert to DB2 using XMLTABLE,XMLPARSE
So in...
I have the following build problem with CODE executing the following.
The simplified code does the following(SQL16003N)
I think.... Since the XML source has multirow data....
We have to handle the cursor?? or Does The XML function exists for
bulk row proccesing
The Sample code is the following.

1) MSSQL
EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument

SELECT @CustName = ISNULL(CustName , ''),
@CustSeq = ISNULL(CustSeq , 0)

FROM OPENXML(@docHandle, N'/ROOT/DataBlock1', @xmlFlags)----
Quote:
Multi XML data
WITH ( CustName NVARCHAR(200),
CustSeq INT

)

1) DB2
select * from XMLTABLE('$i' PASSING
XMLPARSE(document
'<ROOT>
<DataBlock1>
<WorkingTag>A</WorkingTag>
<IDX_NO>1</IDX_NO>
<Status>0</Status>
<DataSeq>1</DataSeq>
<Selected>1</Selected>
<TABLE_NAME>DataBlock1</TABLE_NAME>
<CustName>CUST1</CustName>
<CustSeq>1</CustSeq>
</DataBlock1>
<DataBlock1>
<WorkingTag>A</WorkingTag>
<IDX_NO>2</IDX_NO>
<Status>0</Status>
<DataSeq>2</DataSeq>
<Selected>1</Selected>
<TABLE_NAME>DataBlock1</TABLE_NAME>
<CustName>CUST2</CustName>
<CustSeq>2</CustSeq>

</DataBlock1>
</ROOT>
') AS "i"
COLUMNS CustName VARCHAR(200) PATH 'ROOT/DataBlock1/CustName',
CustSeq INTEGER PATH 'ROOT/DataBlock1/CustSeq') AS X

Reply With Quote
  #2  
Old   
Matthias Nicola
 
Posts: n/a

Default Re: DB2 SQL16003N URSOR IDENTIFIED IN FETCH OR CLOSE STATEMENT IS NOTOPEN!! - 05-01-2010 , 01:59 AM






The first XPath in the XMLTABLE function, i.e. the so-called row-
generating expression, needs to iterate over the repeating element. In
your example the row-generating expression should be $i/ROOT/
DataBlock1.

Like his:

select *
from XMLTABLE('$i/ROOT/DataBlock1'
PASSINGXMLPARSE(document
'<ROOT>
<DataBlock1>
<WorkingTag>A</WorkingTag>
<IDX_NO>1</IDX_NO>
<Status>0</Status>
<DataSeq>1</DataSeq>
<Selected>1</Selected>
<TABLE_NAME>DataBlock1</TABLE_NAME>
<CustName>CUST1</CustName>
<CustSeq>1</CustSeq>
</DataBlock1>
<DataBlock1>
<WorkingTag>A</WorkingTag>
<IDX_NO>2</IDX_NO>
<Status>0</Status>
<DataSeq>2</DataSeq>
<Selected>1</Selected>
<TABLE_NAME>DataBlock1</TABLE_NAME>
<CustName>CUST2</CustName>
<CustSeq>2</CustSeq>

</DataBlock1>
</ROOT>
') AS "i"
COLUMNS CustName VARCHAR(200) PATH 'CustName',
CustSeq INTEGER PATH 'CustSeq') AS X;

CUSTNAME CUSTSEQ
-------------------- -------------------
CUST1 1
CUST2 2

2 record(s) selected.


You'll find many examples of the XMLTABLE function in this article:
http://www.ibm.com/developerworks/da...dm-0708nicola/


Hope this helps.

Matthias
http://www.tinyurl.com/pureXML

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.