Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Tai Nguyen
  Where is Tai Nguyen?
 
 United States
 Tai Nguyen
 To: Oliver Cortazar
  Where is Oliver Cortazar?
 San Luis Potosi
 Mexico
 Oliver Cortazar
 Tags
Subject: RE: need help with concatenance queries
Thread ID: 228704 Message ID: 228720 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Thursday, May 21, 2009 3:13:37 AM         
   


> > I need help with to concatenance the queries below. *** are where all the queries are (and they need to concatenance.)
> >
> > USE "C:\table1.dbf" AGAIN IN 0 SHARED
> > USE "C:\table2.dbf" AGAIN IN 0 SHARED
> > USE "C:\table3.dbf" AGAIN IN 0 SHARED
> > USE "C:\table4.dbf" AGAIN IN 0 SHARED
> >
> > initialVar = "TN"
> >
> > ***Select distinct u.uname as username,t.username as initials;
> > ***from table1 u, table2 t;
> > ***Where t.username=initialVar;
> >
> > SELECT * FROM table4 INTO ARRAY temp
> >
> > FOR i = 1 TO ALEN(temp,1)
> >
> > IF temp[i,2] = initialVar
> >
> > ***union;
> > ***select distinct t1.a as username, t1.user as initials ;
> > ***from table3 t1;
> > ***where t1.user = temp[i,3];
> >
> > initialVar = temp[i,3]
> >
> > ELSE
> >
> > ENDIF
> >
> > ENDFOR
> >
> > ***order username;
> > ***into cursor trainingRecords
> >
> >
> > &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
> >
> > Right here in this area where I want combine all the queries altogether and run it.
> > Last time with .Net using C#, I concatenanced all the queries at the end just fine
> > with quotations around them. With FoxPro I don't know how to do it. But if I try
> > to run a code like this, it will give me an error "unrecognized command verb" which
> > means not combined them right. Experts, thanks for your help.
> >
> > &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
> >
> > Tai Nguyen.
>
> Ok, try to put the query inside a
TEXT TO
block. This is a nice feature that VFP has that is not present in .NET
>
> Your code would be like this:
>
>
> TEXT TO SUBQUERY1 NOSHOW
> Select distinct u.uname as username,t.username as initials ;
> from table1 u, table2 t ;
> Where t.username=initialVar ;
> ENDTEXT
> 
> TEXT TO SUBQUERY2 NOSHOW
> union
> select distinct t1.a as username, t1.user as initials ;
> from table3 t1;
> where t1.user = temp[i,3];
> ENDTEXT
> 
> 
> TEXT TO SUBQUERY3 NOSHOW
> order username;
> Into cursor trainingRecords
> ENDTEXT
> 
> cQUERY=SUBQUERY1 + SUBQUERY2 + SUBQUERY3
> &cQUERY
> 


*********************************************
*********************************************

How do I execute cQUERY in the run-time and place the data into a cursor(write code to do that because I need to bind the trainingRecords cursor to the report)? How do I run that cQUERY to store all the data in the TrainingRecords cursor after concatenance them altogether? Thanks.

Tai Nguyen.

ENTIRE THREAD

need help with concatenance queries Posted by Tai Nguyen @ 5/20/2009 11:59:13 PM
RE: need help with concatenance queries Posted by Oliver Cortazar @ 5/21/2009 12:56:11 AM
RE: need help with concatenance queries Posted by Tai Nguyen @ 5/21/2009 3:13:37 AM
RE: need help with concatenance queries Posted by Oliver Cortazar @ 5/21/2009 8:16:31 PM
RE: need help with concatenance queries Posted by Tai Nguyen @ 5/22/2009 2:20:36 AM
RE: need help with concatenance queries Posted by Oliver Cortazar @ 5/22/2009 7:06:07 PM
RE: need help with concatenance queries Posted by Anders Altberg @ 5/22/2009 8:12:11 PM