This example uses Microsoft Access so you can try it without configuring a database server. You can readily adapt the script to work with Oracle, SQL Server, and other popular databases by changing the connector used. Please visit the RSSBus Connectors page on the web site to see the full range of database technologies and read/write operations supported by RSSBus.
If you want to run the demo yourself, first download and install a trial copy of RSSBus Desktop from the RSSBus Downloads page, and then download this database file and script.
Here is the Customers table from customers.mdb:
| CustomerID |
CompanyName |
FirstName |
LastName |
PhoneNumber |
| 1 |
Selecto Magic |
Bob |
Smith |
800-123-4567 |
| 2 |
Woonsocket Widgets |
Bob |
Jones |
800-321-4321 |
| 3 |
Spacely Sprokets |
Bob |
Rogers |
727-888-1234 |
Here is the RSBScript (select.rsb) that selects from Customers:
<rsb:info title="Feed of my Customer database"
description="append ?name=smith to URL to select customers">
<input name="name" description="Customer last name to select."/>
</rsb:info>
<!-- Set record selector for lastname if we got one as input -->
<rsb:notnull attr="name">
<rsb:set attr="rec:lastname" value="[name]" />
</rsb:notnull>
<rsb:set attr="database" value="customers.mdb"/>
<rsb:set attr="table" value="Customers"/>
<rsb:call op="accessSelect" output="out">
<!-- The body of call statement loops for each record -->
<rsb:push title="[access:firstname] [access:lastname] ([access:companyname])">
<!-- Push sends record fields to RSS output as attributes -->
<!-- Body of push becomes optional description attribute -->
id=[access:customerid], phone=[access:phonenumber]
</rsb:push>
</rsb:call>
To use this script, place the customers.mdb and select.rsb files in the www/ directory of your RSSBus installation, and call it with these URLs:
http://localhost:1110/select.rsb
http://localhost:1110/select.rsb?name=smith
Here is the RSS feed for the first URL, which returns all customers:
<rss version="2.0">
<channel>
<description>append ?name=smith to URL to select</description>
<generator>/n software RSSBus - http://www.rssbus.com</generator>
<link>http://127.0.0.1:1110/select.rsb</link>
<title>Feed of my Customer database</title>
<item>
<access:companyname>Selecto Magic</access:companyname>
<access:customerid>1</access:customerid>
<access:firstname>Bob</access:firstname>
<access:lastname>Smith</access:lastname>
<access:phonenumber>800-123-4567</access:phonenumber>
<description>id=1, phone=800-123-4567</description>
<title>Bob Smith (Selecto Magic)</title>
<guid isPermaLink="false">YAXH4HuKB1NKdNvv5SE10x6o6oU=</guid>
</item>
<item>
<access:companyname>Woonsocket Widgets</access:companyname>
<access:customerid>2</access:customerid>
<access:firstname>Bob</access:firstname>
<access:lastname>Jones
</access:lastname>
. . .
<title>Bob Rogers (Spacely Sprokets)</title>
<guid isPermaLink="false">/T4mn9va90YEe18LNiRO+YqqkSY=</guid>
</item>
</channel>
</rss>
You can follow the pattern shown to add more input selection parameters, or add the cols parameter to control the columns returned. See the online operation description for AccessOps for further details.
You can learn more about RSSBus by reading the RSSBus Server Quick Start Guide.
Downloads:
Database To Feed