Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to know no of records resultset contains in xml file

 
Anil Subudhi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to get no of record counts in xml file from resultset.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly how is a resultset getting turned into an XML file?

Are you able to parse the xml file into a DOM?

Bill
 
Anil Subudhi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i want to retrieve multiple records from database using resultset in xml file.Is there any way to get no of records present from db in xml file. My requirement is below red color x value i set to manually but i need it will set using auto return value by some function or any other way in xml file.
------------------------------------------------------------

<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd"
xmlns:db="http://www.milyn.org/xsd/smooks/db-routing-1.1.xsd"
xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.2.xsd"
xmlns:ds="http://www.milyn.org/xsd/smooks/datasource-1.1.xsd">

<ds:direct bindOnElement="#document" datasource="DB" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/dbase" username="root" password="praya123" autoCommit="false" />
<db:executor executeOnElement="Invoice" datasource="DB" executeBefore="true">
<db:statement>SELECT * FROM custinfo</db:statement>
<db:resultSet name="rs_custinfo" />
</db:executor>
<db:executor executeOnElement="Invoice" datasource="DB" executeBefore="true">
<db:statement>select * from callRates</db:statement>
<db:resultSet name="rs_callRates" />
</db:executor>
<db:executor executeOnElement="Invoice" datasource="DB" executeBefore="true">
<db:statement>select * from InvoiceSummary</db:statement>
<db:resultSet name="rs_InvoiceSummary" />
</db:executor>
<db:executor executeOnElement="Invoice" datasource="DB" executeBefore="true">
<db:statement>select * from InvoiceDetail</db:statement>
<db:resultSet name="rs_InvoiceDetail" />
</db:executor>

<ftl:freemarker applyOnElement="Invoice">
<ftl:template>

<!--
<#assign x=1>
<#list 1..x as i>


<DETAIL>
<DT_INV_HDR1>${rs_custinfo[i].BillingAccNo}</DT_INV_HDR1>
<DT_INV_HDR2>${rs_custinfo[i].CustNo}</DT_INV_HDR2>
<DT_INV_HDR3>${rs_custinfo[i].InvoiceNo}</DT_INV_HDR3>
<DT_INV_HDR4>${rs_custinfo[i].InvoiceDate}</DT_INV_HDR4>
<DT_INV_HDR5>${rs_custinfo[i].PaymentDueDate}</DT_INV_HDR5>
<DT_INV_HDR6/>
<DT_INV_HDR7/>
</DETAIL>

</#list>

-->

</ftl:template>
</ftl:freemarker>
</smooks-resource-list>
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your use of the "smooks" tools means I have not the faintest idea what is going on and I'm not about to spend any time on yet another toolkit.

Surely there is a smooks mailing list or users group that could handle the question.

Bill
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no way to get the number of records that will be available from a ResultSet using regular Java. The standard way is to read the records and count them as you go along.

To put it another way, modelling a ResultSet as an array is folly. You should model it as a List. Perhaps you can do that in this XML-based language; that would be your most practical approach if you are indeed forced to use a ResultSet. However the standard way to do this sort of thing is to read all of the ResultSet rows into a List of objects in the model tier, and then process that List in the view tier. That's true even if the language used for the view tier allows you to process ResultSets.

Although it strikes me that if this tool does indeed allow you to process ResultSets, it must therefore allow you to read through the records. And since it isn't possible to know in advance the number of records, and the designers surely would have known that, it must allow you to read through the records without knowing how many there will be. Are there no examples and tutorials available?
 
Colm Dickson
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.


I have been working with some xml and Java recently and I'd just like to add that in my situation, I was using Oracle also and it might be worth checking if your database can generate the xml with the row numbers as an xml attribute - certainly Oracle can produce an xml file with this embedded in it. However, as the previous post suggested, alternatively, count each record as they are output.

Colm
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic