<%@LANGUAGE="VBSCRIPT"%> <% '===================================================== ' view_package_owner_json.asp ' Designed NOT to be used by a Scroller, but to load all the data ' when the table is first created. Want to retain the checkbox values '===================================================== %> <% Option explicit ' Essential to get UTF through all the hoops. ie: VÄSTTRAFIK (VTK) Response.ContentType = "text/html" Response.AddHeader "Content-Type", "text/html;charset=UTF-8" Response.CodePage = 65001 Response.CharSet = "UTF-8" %> <% '------------ Variable Definition ------------- Dim result : result = -1 Dim SqlQry Dim rsQry Dim parRtagId : parRtagId = Request("rtag_id") ' Init the output JSON class ' Operations can add data ' Default data will be added at the end Dim oJSON :Set oJSON = New aspJSON Dim newitem ' Basic Header ' draw - sequence check ' sReq_* - Debug oJSON.data("draw") = CLng(Request.QueryString("draw")) Dim vName for each vName in Request.QueryString oJSON.data("sReq_" & vName) = Request.QueryString(vName) next ' Extract selected range result = 0 ' Define the data items to extract from the database ' An array of items to extract ' Dim dataCols: dataCols = Array ( _ "pv.pv_id", _ "pv.pkg_id", _ "p.PKG_NAME", _ "pv.PKG_VERSION", _ "pv.PV_DESCRIPTION", _ "v.VIEW_NAME", _ "u.FULL_NAME", _ "pv.COMMENTS",_ "u.USER_NAME",_ "u.USER_EMAIL", _ "pv.v_ext", _ "rc.SDKTAG_ID") ' Dim determine sorting options 'On Error goto 0 'Response.Write "
"

' Create a list of cols that we need. Avoids ambiguity in selections
Dim x,colList,colListJoin
For x = Lbound(dataCols) to Ubound(dataCols)
    colList = colList & colListJoin & dataCols(x)
    colListJoin = ","
Next
Dim sortString
sortString = "ORDER BY UPPER(p.PKG_NAME) asc"

SqlQry =  "select " & colList &_ 
            " FROM package_versions pv, " &_
            "  RELEASE_CONTENT rc, " &_
            "  PACKAGES p, " &_
            "  VIEWS v, " &_
            "  USERS u " &_
            " WHERE rc.rtag_id = " & parRtagId &_
            "  AND rc.pv_id     = pv.pv_id " &_
            "  and p.PKG_ID = pv.pkg_id " &_
            "  and rc.BASE_VIEW_ID = v.VIEW_ID " &_
            "  and pv.OWNER_ID = u.USER_ID " &_
            sortString

' Assist in debug
oJSON.data("SqlQry") = SqlQry

' Perform the database query
Set oJSON.data("data") = oJSON.Collection()
On Error Resume Next
objEH.ErrorRedirect = FALSE
objEH.TryORA ( OraSession )
Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
objEH.CatchORA ( OraSession )
' Process each row and return required fields to the user
If objEH.Finally Then
   While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
        Set newitem = oJSON.AddToCollection(oJSON.data("data"))
'On Error GOTO 0
        ' Attempt to speed up access to the data
        '    Extract all fields for the row
        '    Access fields by index
        Dim fields
        Set fields = rsQry.Fields

        Dim pv_id        : pv_id = fields(0)
        Dim pkg_id       : pkg_id = fields(1)
        Dim pkg_name     : pkg_name = fields(2)
        Dim pkg_version  : pkg_version = fields(3)
        Dim description  : description = CleanUpJson(Server.HTMLEncode(fields(4)))
        Dim baseName     : baseName = fields(5)
        Dim uFull        : uFull = fields(6)
        Dim uName        : uName = fields(8)
        Dim uEmail       : uEmail = fields(9)
        Dim v_ext        : v_ext = fields(10) 
        Dim comments     : comments = CleanUpJson(Server.HTMLEncode(fields(7)))
        Dim sdkId        : sdkId = fields(11) 

        Set fields = nothing

        newitem(0) = pv_id
        newitem(1) = "" & pkg_name & ""
        newitem(2) = "" & pkg_version & ""
        newitem(3) = baseName
        newitem(4) = description
        newitem(5) = uFull
        newitem(6) = uName
        newitem(7) = uEmail
        newitem(8) = sdkId

        rsQry.MoveNext
   Wend
   oJSON.data("result") = 0
End IF

rsQry.Close
Set rsQry = Nothing

'
' SQL error detection and reporting
If objEH.LastOraFailed Then
    oJSON.data("error") = 1

    oJSON.data("emsgSummary") = objEH.MessageSummary
    oJSON.data("emsgDetails") = objEH.MessageDetails
    oJSON.data("SqlQry") = SqlQry
End If

'Return the object
Response.Write oJSON.JSONoutput()
Set oJSON = Nothing
Call Destroy_All_Objects
%>