Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%@LANGUAGE="VBSCRIPT"%><%'=====================================================' NEW VERSION' Package Inquiry utilities' Designed to be called via AJAX and to return' JSON formatted data to dynamic page'=====================================================%><%Option explicit' Good idea to set when using redirectResponse.Expires = 0 ' always load the page, dont store%><!--#include file="common/conf.asp"--><!--#include file="common/globals.asp"--><!--#include file="common/formating.asp"--><!--#include file="common/qstr.asp"--><!--#include file="common/common_subs.asp"--><!--#include file="common/common_dbedit.asp"--><!--#include file="class/classaspJSON.asp" --><%'------------ ACCESS CONTROL ------------------%><!--#include file="_access_control_login.asp"--><!--#include file="_access_control_general.asp"--><!--#include file="_access_control_project.asp"--><%'------------ Variable Definition -------------Dim parOprDim parPkgNameDim resultDim SqlQryDim rsQryparOpr = QStrPar("Opr")parPkgName = Trim(QStrPar("packageName"))result = -1If (parOpr = "checkName") Then' Test existance of a package name' Returns the PKG_ID of the package or 0'result = 0SqlQry = "SELECT pkg.*" &_" FROM packages pkg"&_" WHERE pkg.pkg_id != 0"&_" AND UPPER(pkg.pkg_name) = UPPER('"& parPkgName & "')"On Error Resume NextobjEH.ErrorRedirect = FALSEobjEH.TryORA ( OraSession )Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )objEH.CatchORA ( OraSession )If objEH.Finally ThenIf ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Thenresult = rsQry("pkg_id")End IfEnd IfrsQry.CloseSet rsQry = NothingElseIf (parOpr = "checkVer") Then'' Test the existance of a Package-Version' Returns the PV_ID of the package-Version or 0'result = 0SqlQry = "select pv.pkg_id, pv.PV_ID" &_" FROM packages pkg,"&_" package_versions pv"&_" WHERE pkg.pkg_id = pv.pkg_id"&_" AND UPPER(pkg.pkg_name) = UPPER('"& parPkgName & "')" &_" AND UPPER(pv.pkg_version) = UPPER('" & QStrPar("Version") & "')"On Error Resume NextobjEH.ErrorRedirect = FALSEobjEH.TryORA ( OraSession )Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )objEH.CatchORA ( OraSession )If objEH.Finally ThenIf ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Thenresult = rsQry("PV_ID")End IfEnd IFrsQry.CloseSet rsQry = NothingEnd IfDim oJSONSet oJSON = New aspJSONDim newitem'' Create JSON data for the user' Important fields' result'' Debug fields' QueryString' SqlQry' Request (Array)''Write single valueoJSON.data("result") = result' SQL error detection and reportingIf objEH.LastOraFailed ThenoJSON.data("error") = 1oJSON.data("emsgSummary") = objEH.MessageSummaryoJSON.data("emsgDetails") = objEH.MessageDetailsoJSON.data("SqlQry") = SqlQryEnd If' DEBUG: An array of the user provided requestsoJSON.data("QueryString") = Request.QueryStringSet oJSON.data("Request") = oJSON.Collection()Set newitem = oJSON.AddToCollection(oJSON.data("Request"))Dim variableNamefor each variableName in Request.QueryStringnewitem.add variableName, Request.QueryString(variableName)next'Return the objectResponse.Write oJSON.JSONoutput()%>