Customizing the SELECT template

<< Click to Display Table of Contents >>

Navigation:  Using s-Dashboard > Working with Panels > s-Dashboard Input Overview > Setting Input Preferences >

Customizing the SELECT template

Previous pageReturn to chapter overviewNext page

By default, a dashboard frame uses either SELECT * FROM <input> SELECT (if Include ROWTIME is not selected) or SELECT STREAM ROWTIME,* FROM <input> (if Include ROWTIME is selected).

You can use the SELECT template to modify this SELECT statement that's used to get the data for that frame of the dashboard. To do so, you need to know both SQL and JavaScript. For assistance in implementing this template, please contact SQLstream support at support@sqlstream.com.

The SELECT statement uses an JavaScript Underscore template that accepts a series of variables. For example, the above default SELECT statement would be represented in the template as SELECT <%= selection %> FROM <%= from %>.

The following variables are available inside a template:

Variable

Meaning

schema

The schema for the selected input.

object

The name of the selected input stream/table/view

type

The type of SQL object selected: stream, table, or view.

streaming

A Boolean value that is true if the input is streaming.

tableview

A Boolean value that is true if the input option to view views as tables is true

rowtime

A Boolean value that is true if the rowtime input option is true

selection

The object of the SELECT clause: the part that goes between SELECT and FROM, such as STREAM ROWTIME,*, or *, depending on input options.

from

The full name of the stream, table or view.

msg

The message on the s-dashboard blackboard for the current 'Listen to' channel.

Example

This following statement added to the SELECT template adjusts the SELECT statement for the stream or table:

SELECT <%= selection %> FROM <%= from %> <% if (msg && msg.id) print( 'WHERE "state" = ' + "'" + msg.id.substring(4) +"'"); %>

The statement adds a WHERE clause to the table's SELECT statement when a state is selected.