Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with SQL statement
Message
 
To
05/06/2009 08:39:55
Alp Berker
Defense Finance and Accounting Services
Indianapolis, Indiana, United States
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01403892
Message ID:
01403905
Views:
66
>I have a SQL query as follows:
>
>Select q.*, a.rsc, a.eor, a.wgc, '2P + DE - DF' as Lrdt,;
> Sum(a.amt)+ Sum(b.amt)- Sum(c.amt) as Lcol,;
> d.rdt as Rrdt,;
> Sum(d.amt) as RCol;
>From Qlp-All q;
>Left Outer Join EndofYear a On a.verlvlkey = q.verlvlkey+'2P'+ q.recordtype;
>Left Outer Join Reimbursements b On b.verlvlkey = q.verlvlkey+'DE'+ q.recordtype;
>Left Outer Join Reimbursements c On c.verlvlkey = q.verlvlkey+'DF'+ q.recordtype;
>Left Outer Join EndofPeriod d On d.verlvlkey = q.verlvlkey+'DH'+ q.recordtype;
>Where (a.RDT = '2P' or b.RDT = 'DE' or c.RDT = 'DF' or d.RDT = 'DH') and !q.OA = '00';
>Having q.RecordType = 'DM';
>Group By q.verlvlKey
>
>
>When I run the query, I get the message:
>
>Program Error: File c:\document\locals\temp\00007imh002o.tmp is too large
>
>Which leads me to believe that for some reason it is hitting the 2 GB barrier on creating the resulting set when the query is run.
>I have already tried different things, like eliminating the Where clause and putting the conditions in the join statements, deleted all the tags and recreate them and it still gives me an error. The number of records I am pulling is about 50,000, so the resulting size shouldn't be an issue.
>I have plenty of swap space on the disk, but I am not sure if this is hardware or query related.
>I have other SQl statements thst work fine, but this is te only one that uses the reimbursement table twice for calculations.
>I would like to leave this as 1 query and not break into 2 queries if possible.
>I open to suggestions and will try different options, and different ideas are encouraged. I need to understand why this query doesn't work when ones similar to it work fine.
>thanks,
>Alp

Having clause is not used this way. Anyway I would do it differently:
Select q.*, a.rsc, a.eor, a.wgc, '2P + DE - DF' as Lrdt,; 
       Sum(a.amt)+ Sum(b.amt)- Sum(c.amt) as Lcol,;
       d.rdt as Rrdt,; 
       Sum(d.amt) as RCol; 
From (select * from Qlp-All where recordType='DM') q; 
Left Outer Join (select * from EndofYear where RDT = '2P') a On a.verlvlkey = q.verlvlkey+'2P'+ q.recordtype;
Left Outer Join (select * from Reimbursements where RDT = 'DE' ) b On b.verlvlkey = q.verlvlkey+'DE'+ q.recordtype;
Left Outer Join (select * from Reimbursements where RDT = 'DF' ) c On c.verlvlkey = q.verlvlkey+'DF'+ q.recordtype;
Left Outer Join (select * from EndofPeriod where RDT = 'DH') d On d.verlvlkey = q.verlvlkey+'DH'+ q.recordtype;
Group By verlvlKey
Also, using a,b,c,d ... (intil k, I believe) is not a good idea since VFP reserved them as designations for workareas.
Good Luck
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform