Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL WHERE clause when an expression is required
Message
 
To
14/06/2003 18:09:02
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00800159
Message ID:
00800293
Views:
23
John,

Not clear what does ?v_invoices.lpaid mean: sign "?" indicates that user should type the value, but v_invoices.lpaid seems it is the field lpaid in the already open table v_invoices.

Anyway, this should work:

CREATE SQL VIEW V_lineitems ;
AS SELECT lineitems.entdate, lineitems.ytotal_revenue,;
lineitems.ytotal_tax;
FROM lineitems;
WHERE lineitems.invoicesid =IIF(?v_invoices.lpaid,;
v_invoices.invoiceid, space(len(lineitems.invoicesid)))

>Table Invoices: 1 rec per invoice
>Table LineItems: 1 rec per lineitem that can be attached to any ONE invoice.
>
>CREATE SQL VIEW "V_lineitems" ;
> AS SELECT lineitems.entdate, lineitems.ytotal_revenue,;
> lineitems.ytotal_tax;
> FROM lineitems;
> WHERE (IIF(?v_invoices.lpaid;
> ,lineitems.invoicesid =;
> ?v_invoices.invoiceid, EMPTY(lineitems.invoicesid)))
>
>The view, v_invoices is in scope when this sql is executed.
>
>I probably just don't know how to write the WHERE clause when the WHERE clause needs to contain an expression.
>Just to explain, The WHERE clause I have (above) says:
>If v_invoices.lpaid is true include in my view all lineitems where lineitems.invoicesid = v_invoices.invoiceid BUT if v_invoices.lpaid is false, include in my view all lineitems where lineitems.invoicesid is empty.
>
>That is what i want to do. It is not working.
>
>Thanks,
>John
Previous
Reply
Map
View

Click here to load this message in the networking platform