Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
nothing is wrong in my query..only facing problem when filling dataset..
following is my select query..only concentrate on the first case please
VB
strSql = ""
            strSql = "select B.STORE_NAME3,A.STORE,A.SALES_DATE,B.STORE_NAME," & vbCrLf
            strSql = strSql + " (CASE WHEN NVL(C.CUT_OFF_DATE,'31-JAN-2020')<=A.SALES_DATE THEN 'Y' ELSE 'N' END) ORPOS " & vbCrLf
            strSql = strSql + " ,SUM(CASE WHEN TRAN_TYPE='RES_TRN' THEN AMOUNT ELSE 0 END ) RES_TRN" & vbCrLf
            strSql = strSql + " ,SUM(CASE WHEN TRAN_TYPE='FIN' THEN AMOUNT ELSE 0 END ) FIN" & vbCrLf
            strSql = strSql + " ,SUM(CASE WHEN TRAN_TYPE='EBS' THEN AMOUNT ELSE 0 END ) EBS" & vbCrLf
            strSql = strSql + " ,cm.comments " & vbCrLf
            strSql = strSql + " from XXRMS.INH_TMP_SALES_COMPARISON_RPT A" & vbCrLf
            strSql = strSql + " left outer join rms12.SA_TRAN_ERROR_LOG CM on a.store = cm.store and a.sales_date = cm.tran_date " & vbCrLf
            strSql = strSql + " LEFT OUTER JOIN STORE B ON A.STORE=B.STORE" & vbCrLf
            strSql = strSql + " LEFT OUTER JOIN rms12.AHG_STORE C ON A.STORE=C.STORE" & vbCrLf
            strSql = strSql + " GROUP BY B.STORE_NAME3,A.STORE,A.SALES_DATE,B.STORE_NAME, " & vbCrLf
            strSql = strSql + " (CASE WHEN NVL(C.CUT_OFF_DATE,'31-JAN-2020')<=A.SALES_DATE THEN 'Y' ELSE 'N' END), cm.comments"

SKIP:
            cmd = New OleDbCommand(strSql, conn)
            'Dim dr As OleDbDataReader
            'dr = cmd.ExecuteReader
            'While dr.Read()
            '    MessageBox.Show(dr(4))
            'End While
            Dim dts As DataSet = New DataSet
            da = New OleDbDataAdapter(cmd)
            dt = New DataTable
            'dt.Locale = System.Globalization.CultureInfo.InvariantCulture
            da.Fill(dts)

when i am executing this query in TOAD it is giving me my expected result but when i am performing
VB
da.Fill(dts)

the character from case statement N which is showing correct in TOAD is showing Y in dataset
Posted
Updated 26-Jun-13 4:29am
v3

1 solution

what's the value of CUT_OFF_DATE for the case that's not working? And are CUT_OFF_DATE and SALES_DATE both date columns? Could be that you need a date conversion in there, as your fixed string will not be evaluated as a date. Try this instead:

strSql = strSql + " (CASE WHEN NVL(C.CUT_OFF_DATE,to_date('31-JAN-2020', 'dd-MMM-yyyy'))<=A.SALES_DATE THEN 'Y' ELSE 'N' END) ORPOS " & vbCrLf
 
Share this answer
 
Comments
Basmeh Awad 26-Jun-13 11:41am    
thanks for reply..i solved it its a format problem of NVL(CUT_OFF_DATE,to_date('30-JUN-2020','DD-MON-YYYY')

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900