Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One SCAN FOR statement with two different criteria.
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00426667
Message ID:
00426670
Vues:
27
Hi, Elgin!

Try to use 'SET FILTER' command. So you will need only 'SCAN' without any conditions in you stored procedure. This command is also optimizable when scanning records despite '&', that is not tru for many other commands. Following is sample how procedure call will look like in the form which used to select options for report:
local lcFilter
&& process controls on form and set filter conditions accordingly
lcFilter = ''
do case
  case thisform.opgRecords = 1 && ALL
    && no filter - process all records
    lcFilter = ''
  case thisform.opgRecords = 2 && Range
    lcFilter = 'CustID >= ' + allt(str(thisform.nCustIDRangeFrom)) + ;
      ' AND CustID <= ' + allt(str(thisform.nCustIDRangeTo))
  case thisform.opgRecords = 2 && Just 1 selected customer
    lcFilter = 'CustID = ' + allt(str(thisform.nCustID))
endcase
IF ... && Upsino was selected
  lcFilter = lcFilter + iif(empty(lcFilter), '', ' AND ') + ;
    'Upsino = [' + thisform.txtUpsino.Value + ']'
ENDIF

&& set filter to prepared expression
SELECT Nameplatv
SET FILTER TO &lcFilter

&& Call stored procedure
= PrepareReportCursor()

&& remove filter after work
SET FILTER TO 
>SCAN FOR Custid = gcCustid
> Alot of Code..
>ENDSCAN




>I have a stored procedure that is used to create a report cursor. In this procedure is a SCAN FOR.... END SCAN that has alot of code in between for selecting data from my 5 child tables that I do not want to repeat if possible. However, I would like to give the user a few options for selecting the Parent records that will be included in the report.
>
>The statment currently looks like this for running the report for the currently selected Parent record:
>
>SELECT Namplatv
>SCAN FOR Custid = gcCustid AND Upsino = gcUpsino
>
> Alot of Code for Building reportcursor.
>
>ENDSCAN
>
>I would like to give them the option to select All records for the current CUSTID like:
>
>SELECT Nameplatv
>SCAN FOR Custid = gcCustid
> Alot of Code..
>ENDSCAN
>
>Or even a Range of records specified. This Stored procedure is launched from a button on a form called "ReportSelect" that I use to set which of two report forms to be used.
>
>I don't know how to change my "SCAN FOR" criteria according to what they select. I've tried using variables in place of the criteria and as expected did not work.
>
>Not sure if I'm approaching this correctly. My main goal is to not have to repeat all that code within the SCAN command.
>
>Thanks a million.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform