| 5048 |
dpurdie |
1 |
<%@LANGUAGE="VBSCRIPT"%>
|
|
|
2 |
<%
|
|
|
3 |
'=====================================================
|
|
|
4 |
' sdk_names_json.asp
|
|
|
5 |
' Ajax support for table of SDK names
|
|
|
6 |
' Designed to be driven by the jquery tablescroller
|
|
|
7 |
'=====================================================
|
|
|
8 |
%>
|
|
|
9 |
<%
|
|
|
10 |
Option explicit
|
|
|
11 |
' Essential to get UTF through all the hoops. ie: VÄSTTRAFIK (VTK)
|
|
|
12 |
Response.ContentType = "text/html"
|
|
|
13 |
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
|
|
|
14 |
Response.CodePage = 65001
|
|
|
15 |
Response.CharSet = "UTF-8"
|
|
|
16 |
%>
|
|
|
17 |
<!--#include file="common/conf.asp"-->
|
|
|
18 |
<!--#include file="common/globals.asp"-->
|
|
|
19 |
<!--#include file="common/qstr.asp"-->
|
|
|
20 |
<!--#include file="common/common_subs.asp"-->
|
|
|
21 |
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT>
|
|
|
22 |
<%
|
|
|
23 |
'------------ Variable Definition -------------
|
|
|
24 |
Dim result : result = -1
|
|
|
25 |
Dim SqlQry
|
|
|
26 |
Dim rsQry
|
|
|
27 |
|
|
|
28 |
' Init the output JSON class
|
|
|
29 |
' Operations can add data
|
|
|
30 |
' Default data will be added at the end
|
|
|
31 |
Dim oJSON :Set oJSON = New aspJSON
|
|
|
32 |
Dim newitem
|
|
|
33 |
|
|
|
34 |
'
|
|
|
35 |
' Determine the size of the record set
|
|
|
36 |
' Gives bad results when searching
|
|
|
37 |
Dim MaxCount : MaxCount = 0
|
|
|
38 |
|
|
|
39 |
SqlQry = "select count(*) as count from SDK_NAMES skn"
|
|
|
40 |
|
|
|
41 |
On Error Resume Next
|
|
|
42 |
objEH.ErrorRedirect = FALSE
|
|
|
43 |
objEH.TryORA ( OraSession )
|
|
|
44 |
Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
|
|
|
45 |
objEH.CatchORA ( OraSession )
|
|
|
46 |
If ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Then
|
|
|
47 |
MaxCount = rsQry("COUNT")
|
|
|
48 |
End If
|
|
|
49 |
rsQry.Close
|
|
|
50 |
Set rsQry = Nothing
|
|
|
51 |
|
|
|
52 |
' Basic Header
|
|
|
53 |
' iTotalRecords = total records without any filtering/limits
|
|
|
54 |
' iTotalDisplayRecords = filtered result count
|
|
|
55 |
|
|
|
56 |
oJSON.data("sEcho") = CInt(Request.QueryString("sEcho"))
|
|
|
57 |
oJSON.data("iTotalRecords") = MaxCount
|
|
|
58 |
oJSON.data("iTotalDisplayRecords") = MaxCount
|
|
|
59 |
|
|
|
60 |
' Assist in debug
|
|
|
61 |
oJSON.data("iReqDisplayStart") = CInt(Request.QueryString("iDisplayStart"))
|
|
|
62 |
oJSON.data("iReqDisplayLength") = CInt(Request.QueryString("iDisplayLength"))
|
|
|
63 |
|
|
|
64 |
Dim vName
|
|
|
65 |
for each vName in Request.QueryString
|
|
|
66 |
oJSON.data("sReq_" & vName) = Request.QueryString(vName)
|
|
|
67 |
next
|
|
|
68 |
|
|
|
69 |
' Extract selected range
|
|
|
70 |
result = 0
|
|
|
71 |
dim firstRow,lastRow
|
|
|
72 |
firstRow = CInt(Request.QueryString("iDisplayStart"))
|
|
|
73 |
lastRow = firstRow + CInt(Request.QueryString("iDisplayLength"))
|
|
|
74 |
|
|
|
75 |
' Define the data items to extract from the database
|
|
|
76 |
' An array of items to extract
|
|
|
77 |
'
|
|
|
78 |
Dim dataCols: dataCols = Array ( _
|
| 5097 |
dpurdie |
79 |
"skn.sdk_id", _
|
|
|
80 |
"skn.sdk_name", _
|
|
|
81 |
"skn.sdk_comment",_
|
| 5102 |
dpurdie |
82 |
"p.proj_name",_
|
| 5103 |
dpurdie |
83 |
"v.view_name", _
|
|
|
84 |
"p.proj_id" _
|
| 5097 |
dpurdie |
85 |
)
|
| 5048 |
dpurdie |
86 |
|
|
|
87 |
' Define array of colums to sort by
|
|
|
88 |
' Must match user sort column request
|
|
|
89 |
Dim sortCols: sortCols = Array ( _
|
| 5097 |
dpurdie |
90 |
"skn.sdk_id",_
|
|
|
91 |
"UPPER(skn.sdk_name)",_
|
|
|
92 |
"UPPER(skn.sdk_comment)",_
|
| 5102 |
dpurdie |
93 |
"UPPER(p.proj_name)",_
|
| 5097 |
dpurdie |
94 |
"UPPER(v.view_name)" )
|
| 5048 |
dpurdie |
95 |
|
|
|
96 |
' Dim determine sorting options
|
|
|
97 |
'On Error goto 0
|
|
|
98 |
'Response.Write "<pre>"
|
|
|
99 |
Dim sortString
|
|
|
100 |
If Request.QueryString("iSortCol_0") <> "" Then
|
|
|
101 |
sortString = " ORDER BY " & sortCols(CInt(Request.QueryString("iSortCol_0")))
|
|
|
102 |
sortString = sortString & " " & Request.QueryString("sSortDir_0")
|
|
|
103 |
Else
|
|
|
104 |
sortString = " ORDER BY " & sortCols(CInt(1)) & "asc"
|
|
|
105 |
End If
|
|
|
106 |
|
|
|
107 |
' Filter (search )
|
|
|
108 |
Dim searchString
|
|
|
109 |
If Request.QueryString("sSearch") <> "" Then
|
|
|
110 |
searchString = " AND upper(sdk_name) LIKE upper('%" & Request.QueryString("sSearch") & "%')"
|
|
|
111 |
End If
|
|
|
112 |
|
|
|
113 |
' Create a list of cols that we need. Avoids ambiguity in selections
|
|
|
114 |
Dim x,colList,colListJoin
|
|
|
115 |
For x = Lbound(dataCols) to Ubound(dataCols)
|
|
|
116 |
colList = colList & colListJoin & dataCols(x)
|
|
|
117 |
colListJoin = ","
|
|
|
118 |
Next
|
|
|
119 |
|
|
|
120 |
Dim whereString
|
| 5102 |
dpurdie |
121 |
whereString = " WHERE skn.view_id = v.view_id AND skn.proj_id = p.proj_id"
|
| 5097 |
dpurdie |
122 |
|
| 5048 |
dpurdie |
123 |
Dim BasicSql
|
|
|
124 |
BasicSql = "select " & colList &_
|
| 5102 |
dpurdie |
125 |
" from SDK_NAMES skn, VIEWS v, PROJECTS p " &_
|
| 5048 |
dpurdie |
126 |
whereString &_
|
|
|
127 |
searchString &_
|
|
|
128 |
sortString
|
|
|
129 |
|
|
|
130 |
SqlQry = "select * from ( "&_
|
|
|
131 |
"select a.*, ROWNUM rnum from (" & BasicSql &_
|
|
|
132 |
") a where ROWNUM <= " & lastRow &_
|
|
|
133 |
") where rnum >= " & firstRow
|
|
|
134 |
|
|
|
135 |
' Assist in debug
|
|
|
136 |
oJSON.data("BasicSql") = BasicSql
|
|
|
137 |
'oJSON.data("SqlQry") = SqlQry
|
|
|
138 |
|
|
|
139 |
' Perform the database query
|
|
|
140 |
Set oJSON.data("aaData") = oJSON.Collection()
|
|
|
141 |
On Error Resume Next
|
|
|
142 |
objEH.ErrorRedirect = FALSE
|
|
|
143 |
objEH.TryORA ( OraSession )
|
|
|
144 |
Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
|
|
|
145 |
objEH.CatchORA ( OraSession )
|
|
|
146 |
' Process each row and return required fields to the user
|
|
|
147 |
If objEH.Finally Then
|
|
|
148 |
On Error goto 0
|
|
|
149 |
|
|
|
150 |
While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
|
|
|
151 |
Set newitem = oJSON.AddToCollection(oJSON.data("aaData"))
|
|
|
152 |
|
|
|
153 |
' Attempt to speed up access tot he data
|
|
|
154 |
' Extract all fields for the row
|
|
|
155 |
' Access fields by index
|
|
|
156 |
Dim fields
|
|
|
157 |
Set fields = rsQry.Fields
|
|
|
158 |
Dim sdk_id : sdk_id = fields(0)
|
|
|
159 |
Dim sdk_name : sdk_name = fields(1)
|
|
|
160 |
Dim sdk_comment : sdk_comment = fields(2)
|
| 5102 |
dpurdie |
161 |
Dim proj_name : proj_name = fields(3)
|
|
|
162 |
Dim view_name : view_name = fields(4)
|
| 5103 |
dpurdie |
163 |
Dim proj_id : proj_id = fields(5)
|
| 5048 |
dpurdie |
164 |
|
|
|
165 |
Set fields = nothing
|
|
|
166 |
|
|
|
167 |
newitem(0) = sdk_id
|
|
|
168 |
newitem(1) = sdk_name
|
|
|
169 |
newitem(2) = sdk_comment
|
| 5116 |
dpurdie |
170 |
newitem(3) = proj_name
|
| 5102 |
dpurdie |
171 |
newitem(4) = view_name
|
| 5116 |
dpurdie |
172 |
newitem(5) = proj_id
|
| 5048 |
dpurdie |
173 |
|
|
|
174 |
rsQry.MoveNext
|
|
|
175 |
Wend
|
|
|
176 |
End IF
|
|
|
177 |
|
|
|
178 |
rsQry.Close
|
|
|
179 |
Set rsQry = Nothing
|
|
|
180 |
|
|
|
181 |
'
|
|
|
182 |
' SQL error detection and reporting
|
|
|
183 |
If objEH.LastOraFailed Then
|
|
|
184 |
oJSON.data("error") = 1
|
|
|
185 |
|
|
|
186 |
oJSON.data("emsgSummary") = objEH.MessageSummary
|
|
|
187 |
oJSON.data("emsgDetails") = objEH.MessageDetails
|
|
|
188 |
oJSON.data("SqlQry") = SqlQry
|
|
|
189 |
End If
|
|
|
190 |
|
|
|
191 |
'Return the object
|
|
|
192 |
Response.Write oJSON.JSONoutput()
|
|
|
193 |
'OraSession.Dispose()
|
|
|
194 |
%>
|