I have a pretty complex VFP query with which I am having an issue.
The where clause is the issue. I recently added the view parameter vp_specialvafilter. It is a logical value (True/False).
At the same time I added to the where clause:
AND iif(?vp_specialvafilter,debit_pymts.cpurchases_id in (select vl_jdinv_PursToIncl.cdp_purchases_id FROM v_inmatetrustfund!vl_jdinv_PursToIncl) OR purchases.cinmates_id in (select vl_jdinv_InmsToIncl.cinmates_id FROM v_inmatetrustfund!vl_jdinv_InmsToIncl),.t.)
The issue:
Before any modifications I was getting many records.
Now, and with vp_specialvafilter set to false, I am getting 0 records.
If vp_specialvpfilter is false, I should get the records that I got before these modifications because the IIF would always return .t.
If vp_specialvpfilter is true, it would filter out some of the records.
If I change the iif portion to iif(?vp_specialvafilter,.t.,.t.) I get many records.
All that tells me that even though the 1st expression in my iif is not getting evaluated, it is somehow keeping me from getting any records.
Any help appreciated,
John
Code:
SELECT Debit_pymts.cid,;
Products.cproduct_groups_id,;
Bill_codes.cbill_code_cats_id,;
VL_JD_VNDRACCTPERPRODGRPBILLCDCAT.CPRODGRPBILLCDCATCOMBOS_ID,;
sum(Debit_pymts.yamtpaid) AS yamtpaid,;
Products.cproduct_name,;
Inmates.cinmate_number,;
Inmates.cso,;
PADR(ALLTRIM(Inmates.clast)+","+" "+ALLTRIM(Inmates.cfirst)+" "+ALLTRIM(Inmates.cmiddle),50) AS cname,;
Purchases.mnotes,;
"C" as ctype,;
Debit_pymts.cpurchases_id,;
Purchases.cinmates_id;
FROM inmatetrustfund!debit_pymts;
INNER JOIN inmatetrustfund!account_debits;
ON Debit_pymts.caccount_debits_id = Account_debits.cid;
INNER JOIN inmatetrustfund!purchases;
ON Debit_pymts.cpurchases_id = Purchases.cid;
INNER JOIN inmatetrustfund!bill_codes;
ON Purchases.cbill_codes_id = Bill_codes.cid;
INNER JOIN inmatetrustfund!products;
ON Purchases.cproducts_id = Products.cid;
INNER JOIN v_inmatetrustfund!VL_JD_VNDRACCTPERPRODGRPBILLCDCAT;
ON Products.cproduct_groups_id =;
VL_JD_VNDRACCTPERPRODGRPBILLCDCAT.cproduct_groups_id AND;
Bill_codes.cbill_code_cats_id =;
VL_JD_VNDRACCTPERPRODGRPBILLCDCAT.cbill_code_cats_id;
INNER JOIN inmatetrustfund!inmates;
ON Purchases.cinmates_id = Inmates.cid;
WHERE (EMPTY(Debit_pymts.cjdi_lineitems_id) OR;
ISNULL(Debit_pymts.cjdi_lineitems_id)) AND;
VL_JD_VNDRACCTPERPRODGRPBILLCDCAT.cvendor_accts_id =;
?VP_cvendor_accts_id AND;
TTOD(debit_pymts.ttxndatetm) <= ?VP_dcollectthru AND;
iif(?vp_specialvafilter,;
debit_pymts.cpurchases_id in (select;
vl_jdinv_PursToIncl.cdp_purchases_id;
FROM v_inmatetrustfund!vl_jdinv_PursToIncl) OR;
purchases.cinmates_id in (select vl_jdinv_InmsToIncl.cinmates_id;
FROM v_inmatetrustfund!vl_jdinv_InmsToIncl),.t.);
GROUP BY Debit_pymts.cpurchases_id;
ORDER BY Products.cproduct_name, Inmates.cinmate_number
The where clause is the issue. I recently added the view parameter vp_specialvafilter. It is a logical value (True/False).
At the same time I added to the where clause:
AND iif(?vp_specialvafilter,debit_pymts.cpurchases_id in (select vl_jdinv_PursToIncl.cdp_purchases_id FROM v_inmatetrustfund!vl_jdinv_PursToIncl) OR purchases.cinmates_id in (select vl_jdinv_InmsToIncl.cinmates_id FROM v_inmatetrustfund!vl_jdinv_InmsToIncl),.t.)
The issue:
Before any modifications I was getting many records.
Now, and with vp_specialvafilter set to false, I am getting 0 records.
If vp_specialvpfilter is false, I should get the records that I got before these modifications because the IIF would always return .t.
If vp_specialvpfilter is true, it would filter out some of the records.
If I change the iif portion to iif(?vp_specialvafilter,.t.,.t.) I get many records.
All that tells me that even though the 1st expression in my iif is not getting evaluated, it is somehow keeping me from getting any records.
Any help appreciated,
John