Welcome, Guest Login

Support Center

Select a subset of record from a Data Source

Last Updated: Sep 08, 2016 04:58PM EDT
Select a subset of record from a Data Source
 
i.e. : Using Secondary Tables in Live Data Sources
 
ADVANCED TOPIC.


The sample XML below will be used to illustrate the concepts presented in this discussion.  

There are 4 <item> nodes, each representing a record.
They can be categorized by the value in the <type> nodes.

Let's say you would like to retrieve all the data at once, but show them in lists that only show records of one type.

As remote data sources do not filter data locally (their data source filters modify the query 
URL), the way to do this is by using secondary tables in the remote data source.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="http://www.ctv.ca/mar/xsl/rss.xsl"?>
<rss version="2.0">
    <channel>
		<item>
			<title><![CDATA[TestTitle]]></title>
			<link>http://eachscape.com/links</link>
			<guid>001</guid>
			<type>entertainment</type>
			<author><![CDATA[Steve Smith]]></author>
			<description><![CDATA[Steve Smith]]></description>
               </item>
		<item>
			<title><![CDATA[TestTitle2]]></title>
			<link>http://eachscape.com/links2</link>
			<guid>002</guid>
			<type>game</type>
			<author><![CDATA[Steve Smith]]></author>
			<description><![CDATA[Steve Smith]]></description>
               </item>
		<item>
			<title><![CDATA[TestTitle3]]></title>
			<link>http://eachscape.com/links3</link>
			<guid>002</guid>
			<type>game</type>
			<author><![CDATA[Steve Smith]]></author>
			<description><![CDATA[Steve Smith]]></description>
               </item>
		<item>
		<item>
			<title><![CDATA[TestTitle4]]></title>
			<link>http://eachscape.com/links4</link>
			<guid>002</guid>
			<type>entertainment</type>
			<author><![CDATA[Steve Smith]]></author>
			<description><![CDATA[Steve Smith]]></description>
               </item>
    </channel>
</rss>

Having that in mind, here are the steps to create the secondary data source.


1.
Create the data source datasource with one table (we call that the primary table).
It refers to all the data.

record /rss/channel/item name=allitems
  field author
  field description
  field enclosure
  field guid
  field link name=link2
  field pubDate
  field title name=title2
  field enclosure/@url name=image
end

2.
To create a secondary table, add another table descriptor after the one for the primary table.
Notice that we must also refer to the name of the primary table by adding “primary=allitems” on the record definition of the secondary table.
This identifies the secondary table, like this:

record /rss/channel/item name=allitems
  field author
  field description
  field enclosure
  field guid
  field link name=link2
  field pubDate
  field title name=title2
  field enclosure/@url name=image
end
record /rss/channel/item[type='entertainment'] name=entertainmentitems primary=allitems
  field author
  field description
  field enclosure
  field guid
  field link name=link2
  field pubDate
  field title name=title2
  field enclosure/@url name=image
end


3.
So now, in the entertainment view, If you create the list, you can refer table ds:/ABC/entertainmentitems as the datasource, assuming you named the data source ABC.


One thing that you need to remember is that “Refresh Data Source” on the primary table will refresh all the secondary data sources that depend on it. On the other hand, “Refresh Data Source” on the secondary data source will not cause the primary data source to be refreshed.

Help us improve! Rate this article:

Yes I found this article helpful

Ask a Question   

support@eachscape.com
http://assets0.desk.com/
false
eachscape
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete