My requirement wholly depends on the
I am filtering my gridview on the basis of
So, what my requirement is,
project_nameeither any one can be used for filtering my gridview.
Currently my debugged query works exactly fine for any two parameters.
Below is my debugged query:-
SELECT DISTINCT sv.mkey, vehicle_no, TO_CHAR (date_in, 'dd-MM-yyyy') || ' & ' || time_in vehicleindate_time, TO_CHAR (date_out, 'dd-MM-yyyy') || ' & ' || time_out vehicleoutdate_time, gate_no_in || ' & ' || gate_no_out ingate_outgateno, gd.good_type goods_type, net_weight netweight, TO_CHAR (challan_date, 'dd-MM-yyyy') || ' & ' || challan_no challandate_no, remark_in remarkin, NULL receipt_no, date_in FROM xxcus.xxgid_supinv sv, xxcus.xx_supinv_goodtype gd, xxcus.xxacl_xxgid_user_mst ms WHERE (gd.good_type_code(+) = sv.good_type) AND ( sv.project_id = '1368' AND TO_CHAR (date_in, 'dd-MM-yyyy') = '26-11-2015' OR vehicle_no = '0' ) AND sv.delete_flag = 'N' ORDER BY date_in DESC, vehicle_no
The above query shows me the exact result for
Date which I entered.
But when I add the third parameter say
Vehicle_no it doesn't show the data for that exact
vehicle_no it still shows me the same data which I looked for
I am using Oracle for the database.
LATEST UPDATE WHICH IS NOT WORKING
I am confused as how to deal with the query, as Balazs' solution was working fine when I selected,
Date and then
vehicle_no (not necessary). But it was not fetching proper result when I took first as
Vehicle_no. Any guesses why?
The issue is when I only filter with
Vehicle_nothe date_column value comes as
0so it doesn't show me any row, which is incorrect as I have data for that
I have used
Balaz's second query for the solution which is below
WHERE (gd.good_type_code(+) = sv.good_type) AND ( sv.project_id = '1368' AND TO_CHAR (date_in, 'dd-MM-yyyy') = '26-11-2015' AND vehicle_no = decode(:vehicle_no, '0', vehicle_no, :vehicle_no) )