SQL query in the HTTP Server
You can create HTML pages containing SQL query results by using "/Query?". To do so, you must first make up the appropriate query string (see SQL in Control, basics and SQL Panel, basics). You must also create an HTML base page as a reference.
The SQL query requires the following parameters:
Parameter | Contents |
---|---|
file | Specifies the base HTML file (for example, query/testQuery.html) |
query |
Query string (for example, SELECT+'_online.._value'+FROM+'Ex*') Caution: Replace spaces in the query string with '+'. |
lines | Optional: number of lines per HTML page [default 100] |
head | Optional: HTML table header from the results of the query [with header=1, default =0] |
You should always call the query tables from fixed links (see "Calling HTML references") so as to avoid faulty query strings. The query tables can, however, be called directly from a web browser (see example below).
The base page must be saved as an HTML page and must contain a table lines placeholder #table inside the TABLE tags.
The following table explains all placeholders used on the base page.
Placeholder | Meaning / purpose |
---|---|
#table | Inserts the result lines at this point |
#lines | Optional: Display number of result lines |
#page, #pages | Optional: Page number and total number of pages |
#next | Optional: If the results span multiple pages, you can browse using the <<<>>> links |
Example
The example displays all DPE online values and times that start with "Example" and are not invalid:
-
1. Query string:
SELECT '_online.._value', '_online.._stime'
FROM+'Example*' WHERE ('_online.._invalid'=0)
-
2. The following base HTML page is saved under
<proj_path>/data/http/<language>/query/testQuery.html .
<html><head><title>Events</title></head>
<body bgcolor="c0c0c0"><basefont face="arial">
<H3 align=center>Query Result - #page/#pages</H3>
<p>Number: #lines
<center><table BORDER="1" WIDTH="100%" NOSAVE bgcolor="c0c0c0">
<tr bgcolor="#8888FF">
<th><FONT SIZE=2>DPE</th>
<th><FONT SIZE=2>Value</th>
<th><FONT SIZE=2>Time</th> </tr>
#table
</table></center>
<center><b>#next</b></center></p>
</body></html>
-
3. Open the table in a browser as follows:
http://localhost/Query?file=query/testQuery.html%20&query=SELECT+'_online..
_value',+'_online.._stime'+FROM+'Example*'+WHERE+('_online.._invalid'=0)
A fixed link to table (in a file):
<a href="/Query?file=query/testQuery.html &query=SELECT+'_online.._value',+'_online.._stime'+FROM+'Example*'+WHERE+
('_online.._invalid'=0)&lines=20&head=0" target="result">List all example DPs that are not invalid</a>