PageRenderTime 21ms CodeModel.GetById 18ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 1ms

/SQL/scripts/tools/query.asp

http://github.com/khaneh/Orders
ASP | 156 lines | 150 code | 6 blank | 0 comment | 2 complexity | d43f976f574b407d7303132caf9e3e19 MD5 | raw file
  1<!-- #INCLUDE FILE="../inc/mla_sql_include.asp" -->
  2<%
  3	Dim myStrTree
  4	Dim myDbTbl
  5	Dim myObjRS, myStrRet, myStrQuery, Field, myArrBinary()
  6	Dim myObjStr, myStrClass, i, j, myStrValue, myArrTmp
  7	Dim myMaxCount
  8
  9	openConnection
 10
 11	If Request.Form("mla_query_submit") <> "" Then
 12		myStrQuery = Request.Form("mla_query_value")
 13		If myStrQuery <> "" Then
 14			Set myObjStr = New mlt_string
 15			Set myObjRS = Server.Createobject("ADODB.Recordset")
 16			myObjRS.ActiveConnection = gObjDC
 17			myObjRS.CursorLocation=3
 18			If Request.Form("mla_query_plan") <> "" Then 
 19				myObjRS.LockType = 1
 20			Else
 21				myObjRS.LockType = 3
 22			End If
 23			myMaxCount = CLng(Request.Form("mla_rec_count"))
 24			On Error Resume Next
 25			gObjDC.execute "USE [" & rembracket(Request.Form("mla_query_db")) & "]"
 26			If Request.Form("mla_query_plan") <> "" Then gObjDC.execute "SET SHOWPLAN_TEXT ON"
 27			myObjRS.Open myStrQuery
 28			If Err < 0 Then
 29				If Request.Form("mla_query_plan") <> "" Then gObjDC.execute "SET SHOWPLAN_TEXT OFF"
 30				Set myObjRS = Nothing
 31				Call mla_displayError(Err, myStrQuery)
 32			End If				
 33			Do Until myObjRS Is Nothing
 34				If myObjRS.Properties("Asynchronous Rowset Processing") = 16 Then
 35					myObjStr.strAppend "<P>" & vbCrLf
 36					myObjStr.strAppend "<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=2 ALIGN=CENTER CLASS=""content"" WIDTH=""100%"" SUMMARY=""Result Content"">"
 37					myObjStr.strAppend "<THEAD><TR>" & vbCrLf
 38					i = 0
 39					For Each Field In myObjRS.Fields
 40						ReDim Preserve myArrBinary(i)
 41						myObjStr.strAppend "<TD CLASS=""collabel"">" & Field.Name & "</TD>" & vbCrLf
 42						myArrBinary(i) = (Field.Type = 128 Or Field.Type =  204 Or Field.Type = 205)
 43						i = i + 1
 44					Next
 45					myObjStr.strAppend "</TR></THEAD>" & vbCrLf
 46					myObjStr.strAppend "<TBODY>" & vbCrLf
 47					i = 0
 48					Do While Not myObjRS.EOF
 49						If myMaxCount > 0 And i > myMaxCount Then Exit Do
 50						If i MOD 2 = 0 Then myStrClass = "odd" Else myStrClass = "even" End If
 51						myObjStr.strAppend "<TR CLASS=""" & myStrClass & """>" & vbCrLf
 52						j = 0
 53						For Each Field In myObjRS.Fields
 54							If isNull(Field.Value) Then
 55								myStrValue = "<SPAN CLASS=""moreinfo"">(" & myTObj.getTerm(60) & ")</SPAN>"
 56							ElseIf myArrBinary(j) Then
 57								myArrTmp= bin2hex(Field.Value, mla_cfg_maxdisplayedbin)
 58								If myArrTmp(1) Then
 59									myStrValue = txt2html(myArrTmp(0)) &" <SPAN CLASS=""moreinfo"">(...)</SPAN>"
 60								Else
 61									myStrValue = txt2html(myArrTmp(0))
 62								End If
 63							Else
 64								If Request.Form("mla_query_plan") = "" Then
 65									myArrTmp= getStrBegin(CStr(Field.Value), mla_cfg_maxdisplayedchar)
 66									If myArrTmp(1) Then
 67										myStrValue = txt2html(myArrTmp(0)) & " <SPAN CLASS=""moreinfo"">(...)</SPAN>"
 68									Else
 69										myStrValue = txt2html(myArrTmp(0))
 70									End If
 71								Else
 72									myStrValue = txt2html(CStr(Field.Value))
 73								End If
 74							End If
 75							myObjStr.strAppend "<TD>" & myStrValue & "</TD>" & vbCrLf
 76							j = j + 1
 77						Next
 78						myObjStr.strAppend "</TR>" & vbCrLf
 79						i = i + 1
 80						myObjRS.MoveNext
 81					Loop
 82					myObjStr.strAppend "</TBODY>" & vbCrLf
 83					myObjStr.strAppend "</TABLE>" & vbCrLf
 84					myObjStr.strAppend myObjRS.RecordCount &  " " & myTObj.getTerm(420) & "</P>" & vbCrLf
 85				Else
 86					myObjStr.strAppend myTObj.getTerm(421) &"<BR>" & vbCrLf
 87				End If
 88				Set myObjRS = myObjRS.NextRecordset
 89			Loop
 90			Set myObjRS = Nothing
 91			If Request.Form("mla_query_plan") <> "" Then gObjDC.execute "SET SHOWPLAN_TEXT OFF"
 92			myStrRet = myObjStr.getStr()
 93			Set myObjStr = Nothing
 94		End If
 95	End If
 96	myDbTbl = getDbList()
 97	myStrTree = getTreeStr("2_4", Array()) & " \ " & myTObj.getTerm(31) 
 98	closeConnection
 99%>
100<!-- #INCLUDE FILE="../inc/metaheader.asp" -->
101<BODY>
102	<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
103	<!--
104	function resetForm() {
105		document.mla_query.mla_query_value.value=""; 
106		document.mla_query.mla_query_value.focus(); 
107		return (true);
108	}
109
110	function checkForm(pForm) {
111		if (document.nocheck) return (true);
112		if (isEmpty(pForm.mla_query_value)) {
113			pForm.mla_query_value.focus();
114			return (false);
115		}
116		return (true);
117	}
118	//-->
119	</SCRIPT>
120	<P CLASS="treeinfo"><% = myStrTree %></P>
121
122	<FORM NAME="mla_query" METHOD=POST ACTION="query.asp" onSubmit = "return (checkForm(this));">
123		<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 CLASS="hcontent" SUMMARY="Query Analyser">
124			<TR><TD CLASS="caption"><A HREF=# onclick="openPopUp('query.asp', '<% = Replace(time(), ":", "") %>', 600, 400, 10, 10);"><IMG SRC="../../themes/<% = mla_cfg_theme %>/images/action/new.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALIGN="RIGHT" ALT="New"></A><IMG SRC="../../themes/<% = mla_cfg_theme %>/images/mylittletree/query.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALIGN="MIDDLE" ALT="Query Analyser"> <% = myTObj.getTerm(31) %></TD></TR>
125			<TR>
126				<TD>
127					<B><% = myTObj.getTerm(120) %></B> : <% = getListBox("mla_query_db", myDbTbl, 0, 0, "", Request.Form("mla_query_db"), "alphanumeric", "") %>
128					&nbsp;
129					<B><% = myTObj.getTerm(422) %></B> : <INPUT TYPE="checkbox" NAME="mla_query_plan">
130					&nbsp;
131					<B><% = myTObj.getTerm(423) %></B>   : 
132						<SELECT NAME="mla_rec_count">
133							<OPTION>50</OPTION>
134							<OPTION>100</OPTION>
135							<OPTION>500</OPTION>
136							<OPTION>1000</OPTION>
137							<OPTION VALUE="-1"><% = myTObj.getTerm(424) %></OPTION>
138						</SELECT>
139				</TD>
140			</TR>
141			<TR><TD><TEXTAREA NAME="mla_query_value" ROWS="10" COLS="30" CLASS="objtext_edit" TITLE="<% = myTObj.getTerm(31) %>"><% = Request.Form("mla_query_value") %></TEXTAREA></TD></TR>
142			<TR><TD>&nbsp;</TD></TR>
143			<TR>
144				<TD ALIGN=CENTER>
145					<INPUT TYPE="button" VALUE="<% = myTObj.getTerm(50) %>" NAME="mla_query_reset" onclick="resetForm();"> &nbsp;
146					<INPUT TYPE="submit" VALUE="<% = myTObj.getTerm(54) %>" NAME="mla_query_submit">
147				</TD>
148			</TR>
149		</TABLE>
150	</FORM>
151
152	<% = myStrRet %>
153
154</BODY>
155</HTML>
156<!-- #INCLUDE FILE="../inc/mla_sql_end.asp" -->