Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3892 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
4
'                  NEW VERSION
5
'       Package Inquiry utilities
6
'       Designed to be called via AJAX and to return
7
'       JSON formatted data to dynamic page
8
'=====================================================
9
%>
10
<%
11
Option explicit
12
' Good idea to set when using redirect
13
Response.Expires = 0   ' always load the page, dont store
14
%>
15
 
16
<!--#include file="common/conf.asp"-->
17
<!--#include file="common/globals.asp"-->
18
<!--#include file="common/formating.asp"-->
19
<!--#include file="common/qstr.asp"-->
20
<!--#include file="common/common_subs.asp"-->
21
<!--#include file="common/common_dbedit.asp"-->
22
<!--#include file="class/classaspJSON.asp" -->
23
<%
24
'------------ ACCESS CONTROL ------------------
25
%>
26
<!--#include file="_access_control_login.asp"-->
27
<!--#include file="_access_control_general.asp"-->
28
<!--#include file="_access_control_project.asp"-->
29
<%
30
'------------ Variable Definition -------------
31
Dim parOpr
32
Dim parPkgName
33
Dim result
34
Dim SqlQry
35
Dim rsQry
36
 
37
parOpr = QStrPar("Opr")
38
parPkgName = Trim(QStrPar("packageName"))
39
result = -1
40
 
41
If (parOpr = "checkName") Then
42
 
43
    ' Test existance of a package name
44
    ' Returns the PKG_ID of the package or 0
45
    '
46
    result = 0
47
    SqlQry = "SELECT pkg.*" &_
48
         "  FROM packages pkg"&_
49
         " WHERE pkg.pkg_id != 0"&_
50
         "   AND UPPER(pkg.pkg_name) = UPPER('"& parPkgName & "')"
51
 
52
    On Error Resume Next
53
    objEH.ErrorRedirect = FALSE
54
    objEH.TryORA ( OraSession )
55
    Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
56
    objEH.CatchORA ( OraSession )
57
 
58
    If objEH.Finally Then
59
        If ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Then
60
            result = rsQry("pkg_id")
61
        End If
62
    End If
63
 
64
    rsQry.Close
65
    Set rsQry = Nothing
66
 
67
ElseIf (parOpr = "checkVer") Then
68
    '
69
    ' Test the existance of a Package-Version
70
    ' Returns the PV_ID of the package-Version or 0
71
    '
72
    result = 0
73
    SqlQry = "select pv.pkg_id, pv.PV_ID" &_
74
         "  FROM packages pkg,"&_
75
         "       package_versions pv"&_
76
         " WHERE pkg.pkg_id = pv.pkg_id"&_
77
         "   AND UPPER(pkg.pkg_name) = UPPER('"& parPkgName & "')" &_
78
         "   AND UPPER(pv.pkg_version) = UPPER('" & QStrPar("Version") & "')"
79
 
80
    On Error Resume Next
81
    objEH.ErrorRedirect = FALSE
82
    objEH.TryORA ( OraSession )
83
    Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
84
    objEH.CatchORA ( OraSession )
85
 
86
    If objEH.Finally Then
87
        If ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Then
88
            result = rsQry("PV_ID")
89
        End If
90
    End IF
91
 
92
    rsQry.Close
93
    Set rsQry = Nothing
94
End If
95
 
96
 
97
Dim oJSON
98
Set oJSON = New aspJSON
99
Dim newitem
100
 
101
'
102
'   Create JSON data for the user
103
'   Important fields
104
'       result
105
'
106
'   Debug fields
107
'       QueryString
108
'       SqlQry
109
'       Request (Array)
110
'
111
'Write single value
112
oJSON.data("result") = result
113
 
114
' SQL error detection and reporting
115
If objEH.LastOraFailed Then
116
    oJSON.data("error") = 1
117
 
118
    oJSON.data("emsgSummary") = objEH.MessageSummary
119
    oJSON.data("emsgDetails") = objEH.MessageDetails
120
    oJSON.data("SqlQry") = SqlQry
121
End If
122
 
123
' DEBUG: An array of the user provided requests
124
oJSON.data("QueryString") = Request.QueryString
125
 
126
Set oJSON.data("Request") = oJSON.Collection()
127
Set newitem = oJSON.AddToCollection(oJSON.data("Request"))
128
Dim variableName
129
for each variableName in Request.QueryString
130
    newitem.add variableName, Request.QueryString(variableName)
131
next
132
 
133
'Return the object
134
Response.Write oJSON.JSONoutput()
135
%>
136
 
137
 
138
 
139