Always wanted to export items from your existing database into RSS with ColdFusion and syndicate it, but don’t know how?
Well, this is your lucky day! We’re going to show you how you can easily export your database records to RSS.
We’ll make some assumptions in this article to make things easier, and they are;
Ready to get started?
The first thing to do is go into your MS SQL database and create the following stored procedure that creates the RSS directly in your RDBMS.
CREATE PROCEDURE [dbo].[sp_rssProductFeed]
SET NOCOUNT ON;
SELECT 1 AS tag
When you execute this stored procedure you should get output like following (excluding the content).
<title>The name of your bulk upload.</title>
<description>A description of your content.</description>
<pubDate>Jan 5 2008 2:35PM GMT</pubDate>
<title>0.9m Lightweight Beach Ball</title>
<description>"0.9m Lightweight Beach Ball There is massive beach and poolside fun to be had with this vinyl multicolored beach ball. Note: Image shows 1.2m ball. Actual colours may vary, primary colours used are yellow, blue and red. 0.9m in diameter it can be manually inflated or by using a standard foot pump - see Accessories"</description>
<title>1 x decorated weight</title>
<description>Balloons 1 x decorated weight</description>
<title>1 x standard weight</title>
<description>Balloons 1 x standard weight</description>
All pretty simple so far!
The ColdFusion code to call this stored procedure is as following, just copy and paste it into a .cfm file, and run it.
***** Copyright 2007 Commerce Engine Pty Ltd (clickfind.com.au) *****
You can distribute this code and use it as long as these comments
remain in tact.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
<!--- call the stored procedure --->
datasource="your datasource name here">
<!--- assign a name to the resultset --->
// get the column names data from the resultset
columnName = rsRSSFeed.getMetaData().getColumnLabels();
// create the path where to store the file
storagePath = "c:\replace with where ever you want to store the file\";
// get the coloumn name
rssFeed = rsRSSFeed[ columnName[ 1 ] ];
<!--- write the file to disk --->
And voila! Just a few lines of code and you’re publishing RSS directly from your database. Building this structure through ColdFusion would really slow it down a lot. This actually works with thousands of records.
I hope you enjoyed this article, any questions, feel free to contact firstname.lastname@example.org make sure you refer to the original document as we might not know which one you are referring to.
Feel free to copy and distribute this tutorial, but reference to the author and sponsor.
Author: Taco Fleur
This article was sponsored by clickfind