Select Case SQL recordset help

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Select Case SQL recordset help

    I was given the following SQL statement to drop into DMX and create a
    recordset: SELECT CASE 'allotype' CASE 'STRATEGY': strSQL = 'select
    STRTGY_ALLOC_AMT ' & _ 'from DIM_STRTGY_ALLOC, DIM_DDO, DIM_FY, ' & _
    'DIM_STRTGY ' & _ 'where DIM_STRTGY_ALLOC.STRTGY_ALLOC_DDO_ID =
    DIM_DDO.DDO_ID ' & _ 'and DIM_STRTGY_ALLOC.STRTGY_ALLOC_AY = DIM_FY.FY_ID
    ' & _ 'and DIM_STRTGY_ALLOC.STRTGY_ALLOC_STRTGY_ID = DIM_STRTGY.STRTGY_ID '
    & _ 'and DIM_DDO.DDO_DSCR_SHORT = 'ddo' ' & _ 'and DIM_FY.FY_CHAR =
    'yr' ' & _ 'and DIM_STRTGY.STRTGY_NBR = 'strategy' ' CASE 'BUDGET
    OBJECT': strSQL = 'select BUDG_OBJT_ALLOC_AMT ' & _ 'from
    DIM_BUDG_OBJT_ALLOC, DIM_DDO, DIM_FY, ' & _ 'DIM_BUDG_OBJT ' & _ 'where
    DIM_BUDG_OBJT_ALLOC.BUDG_OBJT_ALLOC_DDO_ID = DIM_DDO.DDO_ID ' & _ 'and
    DIM_BUDG_OBJT_ALLOC.BUDG_OBJT_ALLOC_AY = DIM_FY.FY_ID ' & _ 'and
    DIM_BUDG_OBJT_ALLOC.BUDG_OBJT_ALLOC_BUDG_OBJT_ID = DIM_BUDG_OBJT.BUDG_OBJT_ID '
    & _ 'and DIM_DDO.DDO_DSCR_SHORT = 'ddo' ' & _ 'and DIM_FY.FY_CHAR =
    'yr' ' & _ 'and DIM_BUDG_OBJT.BUDG_OBJT_NBR = 'budgobj' ' & _ CASE
    'STAFFING': strSQL = 'select STAFFING_ALLOC_AMT ' & _ 'from
    DIM_STAFFING_ALLOC, DIM_DDO, DIM_FY, ' & _ 'DIM_FTE_CLASS ' & _ 'where
    DIM_STAFFING_ALLOC.STAFFING_ALLOC_DDO_ID = DIM_DDO.DDO_ID ' & _ 'and
    DIM_STAFFING_ALLOC.STAFFING_ALLOC_AY = DIM_FY.FY_ID ' & _ 'and
    DIM_STAFFING_ALLOC.STAFFING_ALLOC_FTE_CLASS_ID = DIM_FTE_CLASS.FTE_CLASS_ID '
    & _ 'and DIM_DDO.DDO_DSCR_SHORT = 'ddo' ' & _ 'and DIM_FY.FY_CHAR =
    'yr' ' & _ 'and DIM_FTE_CLASS.FTE_CLASS_NBR = 'FTEClass' ' END SELECT I'm
    passing the the following variable values using a QueryString: ddo =
    Request.QueryString('ddo') yr = Request.QueryString('yr') allotype =
    Request.QueryString('allotype') strategy = Request.QueryString('strategy')
    budgobj = Request.QueryString('BO') FTEClass = Request.QueryString('FTEClass')
    I need to re-write the SQL so I can pass in the values from QueryString and
    process the data. I need to remove all the VbScript code and just have a clean
    SQL statement where I can pass in the values from the QueryString. I'm trying
    to adjust the SQL so that when I open the recordset, I would have the
    following: rsAlloOrigAmt.Source = 'SELECT CASE... or rsFundOrigAmt.Source =
    strSQL I'm having some difficulty ammending this statement. I'm getting a
    case syntax error. Thanks, -D-

    -D- Guest

  2. Similar Questions and Discussions

    1. Complicated "CASE WHEN" query for Dreamweaver Recordset
      Hello, I have a table called "categories_ctg" with the following fields: id_ctg, int(11), auto_increment idctg_ctg, int(11)(can be NULL)...
    2. sql select case statement
      Hi, Im trying to put together a sql select case statement for coldfusion - can anyone please check over my code and see if i am going along the...
    3. recordset.recordcount return allways -1 on select statements
      Greetings On my ASP application I want to retrieve the number (Recordset.recordCount property) of records affected by a select statement, but I...
    4. #23026 [Com]: Make Zend case-sensitive (classes, functions, remove case-insensitive)
      ID: 23026 Comment by: nvivo at mandic dot com dot br Reported By: mfischer@php.net Status: Open Bug Type: ...
    5. RecordSet.Move or RecordSet.AbsolutePosition??
      Hi, I'm trying to use either one of these methods to position the cursor in a specific position inside a recordset, but neither one seems to...
  3. #2

    Default Re: Select Case SQL recordset help

    As a follow-up, I've built my recordset like the following: <% Dim
    rsAllOrigAmt__ddo rsAlloOrigAmt__ddo = 'xyz' If (Request.QueryString('ddo') <>
    '') Then rsAlloOrigAmt__ddo = Request.QueryString('ddo') End If %> <% Dim
    rsAlloOrigAmt__yr rsAlloOrigAmt__yr = 'xyz' If (Request.QueryString('yr') <>
    '') Then rsAlloOrigAmt__yr = Request.QueryString('yr') End If %> <% Dim
    rsAlloOrigAmt__allotype rsAlloOrigAmt__allotype = 'xyz' If
    (Request.QueryString('allotype') <> '') Then rsAlloOrigAmt__allotype =
    Request.QueryString('allotype') End If %> <% Dim rsAlloOrigAmt__strategy
    rsAlloOrigAmt__strategy = 'xyz' If (Request.QueryString('strategy') <> '') Then
    rsAlloOrigAmt__strategy = Request.QueryString('strategy') End If %> <% Dim
    rsAlloOrigAmt__budgobj rsAlloOrigAmt__budgobj = 'xyz' If
    (Request.QueryString('BO') <> '') Then rsAlloOrigAmt__budgobj =
    Request.QueryString('BO') End If %> <% Dim rsAlloOrigAmt__FTEClass
    rsAlloOrigAmt__FTEClass = 'xyz' If (Request.QueryString('FTEClass') <> '') Then
    rsAlloOrigAmt__budgobj = Request.QueryString('FTEClass') End If %> <% Dim
    rsAlloOrigAmt Dim rsAlloOrigAmt_numRows SELECT CASE rsAlloOrigAmt__allotype
    CASE 'STRATEGY': strSQL = 'select STRTGY_ALLOC_AMT ' &amp; _ 'from
    DIM_STRTGY_ALLOC, DIM_DDO, DIM_FY, ' &amp; _ 'DIM_STRTGY ' &amp; _ 'where
    DIM_STRTGY_ALLOC.STRTGY_ALLOC_DDO_ID = DIM_DDO.DDO_ID ' &amp; _ 'and
    DIM_STRTGY_ALLOC.STRTGY_ALLOC_AY = DIM_FY.FY_ID ' &amp; _ 'and
    DIM_STRTGY_ALLOC.STRTGY_ALLOC_STRTGY_ID = DIM_STRTGY.STRTGY_ID ' &amp; _ 'and
    DIM_DDO.DDO_DSCR_SHORT = 'rsAlloOrigAmt__ddo' ' &amp; _ 'and DIM_FY.FY_CHAR =
    'rsAlloOrigAmt__yr' ' &amp; _ 'and DIM_STRTGY.STRTGY_NBR =
    'rsAlloOrigAmt__strategy' ' CASE 'BUDGET OBJECT': strSQL = 'select
    BUDG_OBJT_ALLOC_AMT ' &amp; _ 'from DIM_BUDG_OBJT_ALLOC, DIM_DDO, DIM_FY, '
    &amp; _ 'DIM_BUDG_OBJT ' &amp; _ 'where
    DIM_BUDG_OBJT_ALLOC.BUDG_OBJT_ALLOC_DDO_ID = DIM_DDO.DDO_ID ' &amp; _ 'and
    DIM_BUDG_OBJT_ALLOC.BUDG_OBJT_ALLOC_AY = DIM_FY.FY_ID ' &amp; _ 'and
    DIM_BUDG_OBJT_ALLOC.BUDG_OBJT_ALLOC_BUDG_OBJT_ID = DIM_BUDG_OBJT.BUDG_OBJT_ID '
    &amp; _ 'and DIM_DDO.DDO_DSCR_SHORT = 'rsAlloOrigAmt__ddo' ' &amp; _ 'and
    DIM_FY.FY_CHAR = 'rsAlloOrigAmt__yr' ' &amp; _ 'and DIM_BUDG_OBJT.BUDG_OBJT_NBR
    = 'rsAlloOrigAmt__budgobj' ' &amp; _ CASE 'STAFFING': strSQL = 'select
    STAFFING_ALLOC_AMT ' &amp; _ 'from DIM_STAFFING_ALLOC, DIM_DDO, DIM_FY, ' &amp;
    _ 'DIM_FTE_CLASS ' &amp; _ 'where DIM_STAFFING_ALLOC.STAFFING_ALLOC_DDO_ID =
    DIM_DDO.DDO_ID ' &amp; _ 'and DIM_STAFFING_ALLOC.STAFFING_ALLOC_AY =
    DIM_FY.FY_ID ' &amp; _ 'and DIM_STAFFING_ALLOC.STAFFING_ALLOC_FTE_CLASS_ID =
    DIM_FTE_CLASS.FTE_CLASS_ID ' &amp; _ 'and DIM_DDO.DDO_DSCR_SHORT =
    'rsAlloOrigAmt__ddo' ' &amp; _ 'and DIM_FY.FY_CHAR = 'rsAlloOrigAmt__yr' '
    &amp; _ 'and DIM_FTE_CLASS.FTE_CLASS_NBR = 'rsAlloOrigAmt__budgobj' ' END
    SELECT Set rsAlloOrigAmt = Server.CreateObject('ADODB.Recordset')
    rsAlloOrigAmt.ActiveConnection = MM_DBConn_STRING rsAlloOrigAmt.Source = strSQL
    rsAlloOrigAmt.CursorType = 0 rsAlloOrigAmt.CursorLocation = 2
    rsAlloOrigAmt.LockType = 1 rsAlloOrigAmt.Open() rsAlloOrigAmt_numRows = 0 %>
    <% If NOT rsAlloOrigAmt.EOF Then Dim y y = Request.QueryString('LoopNum')
    Session('ddomenuA' &amp; y) = Request.QueryString('ddo') Session('yrA' &amp; y)
    = Request.QueryString('yr') Session('allocationtypeA' &amp; y) =
    Request.QueryString('allotype') Session('strategyB' &amp; y) =
    Request.QueryString('strategy') Session('BOA' &amp; y) =
    Request.QueryString('BO') Session('FTEClassA' &amp; y) =
    Request.QueryString('FTEClassA') Session('origBAA' &amp; y) =
    rsAlloOrigAmt.Fields.Item('BUDGET_AMT_AMT').Value
    Response.Redirect('request.asp?#alloanchor') else %> I think I've built the
    recordset correctly, but how can I get the variable value for the QueryString
    to not be a string as in the following line: 'and DIM_DDO.DDO_DSCR_SHORT =
    'rsAlloOrigAmt__ddo' ' &amp; _ The quotes seem to keep 'rsAlloOrigAmt__ddo'
    from being a variable value from the QueryString Thanks, -D-

    -D- Guest

  4. #3

    Default Re: Select Case SQL recordset help

    I corrected the problem...I needed to concatenate the variable values within the SQL string.

    Thanks,
    -D-
    -D- Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139