3.1.2.9 jdbc_query Element
The jdbc_query
element is used to define a theme
dynamically. This element and its associated <hidden_info>
element have the following definitions:
<!ELEMENT jdbc_query (#PCDATA, hidden_info?)>
<!ATTLIST jdbc_query
asis (TRUE|FALSE) "FALSE"
spatial_column CDATA #REQUIRED
key_column CDATA #IMPLIED
label_column CDATA #IMPLIED
label_style CDATA #IMPLIED
render_style CDATA #IMPLIED
x_column CDATA #IMPLIED
y_column CDATA #IMPLIED
datasource CDATA #IMPLIED
jdbc_host CDATA #IMPLIED
jdbc_port CDATA #IMPLIED
jdbc_sid CDATA #IMPLIED
jdbc_user CDATA #IMPLIED
jdbc_password CDATA #IMPLIED
jdbc_srid CDATA #IMPLIED
jdbc_mode (thin|oci8) "thin"
>
<!ELEMENT hidden_info (field+)>
<!ELEMENT field (#PCDATA)>
<!ATTLIST field
column CDATA #REQUIRED
name CDATA #IMPLIED
>
To define a theme dynamically, you must supply a valid SQL query as the
content of the <jdbc_query>
element. You must specify the
spatial_column (column of type SDO_GEOMETRY) and the JDBC connection information for
a dynamically defined theme (either datasource or the combination of
jdbc_host, jdbc_port, jdbc_sid, jdbc_user
, and
jdbc_password
). If the selectable_in_svg
attribute value is TRUE in the <theme>
element, you must use the
key_column
attribute in the <jdbc_query>
element to specify the name of a column that can uniquely identify each selected
feature from the JDBC query. The specified column must also appear in the SELECT
list in the JDBC query.
render_style
and label_style
are
optional attributes. For render_style
, for point features the
default is a red cross rotated 45 degrees, for lines and curves it is a black line 1
pixel wide, and for polygons it is a black border with a semitransparent dark gray
interior.
x_column
and y_column
are optional
attributes. If specified, they are used to define a point JDBC theme based on two
columns in a table, so that MapViewer can render a point theme based on values in
these columns. For more information, see Defining a Point JDBC Theme Based on Two Columns.
jdbc_srid
is an optional attribute that specifies the
coordinate system (SDO_SRID value) of the data to be rendered.
jdbc_mode
identifies the Oracle JDBC driver (thin or
oci8) to use to connect to the database.
asis
is an optional attribute. If it is set to TRUE,
MapViewer does not attempt to modify the supplied query string. If
asis
is FALSE (the default), MapViewer embeds the SQL query as
a subquery of its spatial filter query. For example, assume that you want a map
centered at (-122, 37) with size 1, and the supplied query is: SELECT
geometry, sales FROM crm_sales WHERE sales < 100000;
If asis
is FALSE, the actual query that MapViewer executes is
similar to:
SELECT * FROM
(SELECT geometry, sales FROM crm_sales WHERE sales < 100000)
WHERE sdo_filter(geometry, sdo_geometry(. . . -122.5, 36.5, -123.5, 37.5. . . ) ='TRUE';
In other words, the original query is further refined by a spatial filter query using
the current map window. However, if asis
is TRUE, MapViewer
executes the query as specified, namely: SELECT geometry, sales FROM
crm_sales WHERE sales < 100000;
The <hidden_info>
element specifies the list of attributes from
the base table to be displayed when the user moves the mouse over the theme's
features. The attributes are specified by a list of <field>
elements. Each <field>
element must have a
column
attribute, which specifies the name of the column from
the base table, and it can have a name
attribute, which specifies
the display name of the column. (The name
attribute is useful if
you want a text string other than the column name to be displayed.)
For examples of using the <jdbc_query>
element to
define a theme dynamically, see Example 3-2 and Example 3-4.
Parent topic: Map Request DTD