Thursday, March 27, 2008

Please Print The Data

"Please print the data for me, in columns, so I can look at it."

That's a real request, from a real end user... and in a lot of shops that's what passes for specifications.

And there is nothing wrong with that... in this era of high efficiency and low overhead there's often no need to study every user request and examine its entrails for deep significance, before giving the user something to look at.
A quick question deserves a quick answer, and here's one from SQL Anywhere... a real answer, at a real client site just yesterday:

Step 1: Add the "-xs http(port=54321)" parameter the SQL Anywhere server command line to enable the built-in HTTP server, if it isn't already enabled:
"%ASANY9%\win32\dbsrv9.exe" -c 500M -o dbsrv9_log_ddd.txt -os 10M -x tcpip -xs http(port=54321) ddd.db
...watch out for wrapping, that's all on one line.

The default HTTP port is 80 and if that's what you want just code "-xs http". In this example 54321 is used to avoid collisions with other HTTP servers already running on the same machine.

Step 2: Restart the server, and run dbisql to create one web service for each columnar printout you want to produce:
CREATE SERVICE Indexes TYPE 'HTML'
AUTHORIZATION OFF USER DBA
AS SELECT tname AS table_name,
iname AS index_name,
indextype,
colnames
FROM SYS.SYSINDEXES
ORDER BY table_name,
index_name;
Step 3: Show the end user how to display and print the result in a browser:
http://pavilion2:54321/Indexes
where "pavilion2" is the computer running the SQL Anywhere network server (dbsrv9), "54321" is the HTTP port we chose, and "Indexes" is the name we gave the web service.

Bingo! Here's what the output looks like, in FireFox...

No comments: