Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Problem ...
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00163903
Message ID:
00164070
Views:
13
>1. They must never have been included in a previous remittance.
>2. All invoices for the reporting period which have been paid in the
>reporting period or immediately preceding period must be included.
>3. Any invoices for the reporting period which have been paid in the
>immediately following period must be included.
>4. Any invoices more than two periods old must be included.
>
>5. Any invoices for the following period and paid in the following period must not be included. (This is the part which is giving me the trouble.)

>I'm trying to do this trough two views. The first, lv_ok_for_pf_payt, fulfills criteria #2 and #3.
>
>The second, lv_pfundrep, is intended to fulfill the remaining criteria. It all works except that #5 is never met. If an invoice generated in the following period is also paid in that period it is included, *and it shouldn't be*. I was hoping that the line:
> "AND alltrim( Invhead.cinvoi_key ) not in ( ?lcNextFiscPer_Key )"
>would force the exclusion.

So ok Miles, let's look at your second view...

>*************************************
>***** create view lv_PfundRep ******
>*************************************
>
>CREATE SQL VIEW lv_PfundRep AS ;
>SELECT Invhead.cinvoi_key, Invhead.cinvoiceno,;
> Invhead.ysubtotal,Invhead.ytotal, ;
> Invhead.lfullypaid, Invhead.cfiscper_key ;
> FROM hea!invhead INNER JOIN hea!company ;
> ON Invhead.ccompa_key = Company.ccompa_key;
> WHERE ( alltrim( Invhead.cinvoicetype ) not in ;
> ( "HFX", "MEM", "INT", "THEA" );
> AND Invhead.lpfundreport = .F.;
> AND Invhead.lfullypaid = .T.;
> AND alltrim( Invhead.cinvoi_key ) not in ( ?lcNextFiscPer_Key ) ;
> AND Invhead.cinvoi_key in ;
> ( select cInvoi_key from lv_ok_for_pf_payt ) );
> OR ;
> ( alltrim( Invhead.cinvoicetype ) not in ;
> ( "HFX", "MEM", "INT", "THEA" );
> AND InvHead.lCommitted = .T. ;
> AND Invhead.lpfundreport = .F.;
> AND InvHead.cFiscPer_Key < ?lcPrevFiscPer_Key );
> ORDER by cInvoi_Key

Just some thoughts,
instead of AND alltrim( Invhead.cinvoi_key ) not in ( ?lcNextFiscPer_Key ) ; why not a not equal condition instead of not in() ?

Since your condition #5 is not paid, I would think AND Invhead.lfullypaid = .T.; should be =.F. ?
Roxanne M. Seibert
Independent Consultant, VFP MCP

Code Monkey Like Fritos
Previous
Reply
Map
View

Click here to load this message in the networking platform