RDS Returns Data As-Is

Because RDS does its work separately from ASP, one complication is that the ASP script cannot intercept data being returned in order to format it. This means that the table in which the records will be displayed must be ready for DHTML binding, or the result set itself must contain all the necessary formatting.

Also, what you get from the database is exactly what will be displayed. For example, to bind data to a link, that data needs to be in the form of a link to begin with. (You cannot intercept a file name and change it into a link after it has been retrieved from the database.) To bind to an image, the returned data needs to be image data. One way around this difficulty is to use the SQL "stuff" command in your stored procedure, while retrieving the data from the database.

About the SQL "Stuff" Command

"Stuff" is an SQL call that inserts data into a string at a certain location and passes the string back as part of a datastream. In this way, the data passed back can be altered as it is being fetched from the database in various ways.

For example, the returned data can become a link bound to a client-side JavaScript function rather than just a number. The data that would otherwise be returned is the ID of the bib# of the library item, and that bib# is not a link. In this case, the CML application uses "stuff" to make a link out of that bib#.

For example, in the fm_fts_optAuthor_contains stored procedure, the following code uses two "stuff" commands:

exec("insert into " + @tblname + 
"Select distinct stuff('../images/icon.gif',15,0,coll) as Icon," +
"stuff('javascript:Dolong()',19,0,ltrim(str(t.bib#))) as Link," + 
"t.title,t.coll,t.call,convert(char(4),t.pubdate,112) as Pubdate " +
"from Title as t, Author as a, TitleAuth as ta " +
"where (t.bib# = ta.bib# and ta.auth# = a.auth#) and " + 
"t.n_items>0 AND CONTAINS(a.*, '" + @search + "')" + @where)

The first "stuff" command inserts an image (icon.gif) into the data returned, and the second inserts the JavaScript function Dolong.