Autodesk 15606-011408-9300 Developer Guide - Page 90

Setting Up the Query, Controlling the Output, Seeing the Results

Page 90 highlights

Setting Up the Query First we'll build the statement. If your map links to a table called Parcel_Data through a data source Assessor, will look like this: SELECT * FROM Parcel_Data The NAME attribute specifies the name of the ColdFusion query. This name can be anything you want, as long as it matches the name specified later in . The DATASOURCE attribute is the OLE DB data source name (DSN), in this case Assessor. Between the beginning and end tags is a SQL statement specifying which part of the table you want to look at (this selection is known as a recordset.) In this case, we're selecting everything (*) from the Parcel_Data table. Controlling the Output Now we'll assemble the statement. If you want to display the parcel number, owner's name, and year built, your tag will look like this: Parcel Number: #APN# Owner Name: #Owner_Name# Year Built: #Year_Built# The QUERY attribute tells ColdFusion which recordset you'd like to display; this attribute matches the NAME you specified in . The names within pound signs (#APN#, #Owner_Name#, #Year_Built#) are ColdFusion variables that match column names in the database table (for example, #APN# refers to the APN column). Everything else is straight HTML. Seeing the Results Now we're ready to load the page in the browser. However, because this particular table has more than 5,000 records, selecting everything in it might not be such a good idea. Let's limit the output by showing only houses built in 1963. To do so, go back to and change the SQL statement to the following: SELECT * FROM Parcel_Data Where Year_Built = '1963' 90 | Chapter 6 Using Reports to Query and Update Data Sources

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208

90
|
Chapter 6
Using Reports to Query and Update Data Sources
Setting Up the Query
First we
ll build the
<CFQUERY>
statement. If your map links to a table called
Parcel_Data
through a data source
Assessor
,
<CFQUERY>
will look like
this:
<CFQUERY NAME="get_parcel_info" DATASOURCE="Assessor">
SELECT * FROM Parcel_Data
</CFQUERY>
The
NAME
attribute specifies the name of the ColdFusion query. This name
can be anything you want, as long as it matches the name specified later in
<CFOUTPUT>
. The
DATASOURCE
attribute is the OLE DB data source name
(DSN), in this case
Assessor
. Between the
<CFQUERY>
beginning and end
tags is a SQL statement specifying which part of the table you want to look
at (this selection is known as a
recordset
.) In this case, we
re selecting every-
thing (
*
) from the
Parcel_Data
table.
Controlling the Output
Now we
ll assemble the
<CFOUTPUT>
statement. If you want to display the
parcel number, owner
s name, and year built, your tag will look like this:
<CFOUTPUT QUERY="get_parcel_info">
<P>Parcel Number: #APN#<BR>
<P>Owner Name: #Owner_Name#<BR>
<P>Year Built: #Year_Built#</P>
</CFOUTPUT>
The
QUERY
attribute tells ColdFusion which recordset you
d like to display;
this attribute matches the
NAME
you specified in
<CFQUERY>
. The names
within pound signs (
#APN#
,
#Owner_Name#
,
#Year_Built#
) are
ColdFusion variables that match column names in the database table (for
example,
#APN#
refers to the
APN
column). Everything else is straight HTML.
Seeing the Results
Now we
re ready to load the page in the browser.
However, because this particular table has more than 5,000 records, selecting
everything in it might not be such a good idea. Let
s limit the output by
showing only houses built in 1963. To do so, go back to
<CFQUERY>
and
change the SQL statement to the following:
SELECT * FROM Parcel_Data Where Year_Built = '1963'