Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Method Call from within a select statement returns
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01131155
Message ID:
01131190
Views:
13
>I have a select statement that calls a method to return a value:
>
>Following is a stripped down version to get the gist.
>
>   select vin_ref, thisform.yGetAging()as vin_aging
>      from scvndino
>
>*yGetAging Method*
>with thisform
>   do case	
>      case vin_duedate  >= .ydDate
>         return 'Current'
>      case between(vin_duedate,.ydDate-10,.ydDate - 1)
>	 return '1 - 10'
>      case between(vin_duedate,.ydDate-20,.ydDate - 11)
>	 return '11 - 20'
>      case between(vin_duedate,.ydDate-30,.ydDate - 21)
>	 return '21 - 30'
>      case between(vin_duedate,.ydDate-60,.ydDate - 31)
>	 return '31 - 60'
>      case between(vin_duedate,.ydDate-90,.ydDate - 61)
>	 return '61 - 90'
>      case between(vin_duedate,.ydDate-120,.ydDate - 91)
>	 return '91- 120'
>      otherwise
>	 return '121+'
>   endcase
>endwith
>
>
>
>Prior to VFP 9 this worked fine. I am finding now that the record pointer in the scvndino table is not on the correct record anymore in the method. If the select statement is going through a hundred records this method returns the results for the first record in the table all 100 times.
>
>Sending vin_duedate as a parameter to the method and replacing "vin_duedate" with this parameter DOES work. My concern is that I have code like this all over the place. Is there something else I'm missing?


Paul, if this is the real code for the method, you didn't need a method at all:
*** VFP9:
ldDate = .ydDate
*select vin_ref,;
       PADR(ICASE(vin_duedate  >= ldDate, [Current],;
             BETWEEN(vin_duedate, ldDate- 10, ldDate- 1), ' 1 -  10',;
             BETWEEN(vin_duedate, ldDate- 20, ldDate-11), '11 -  20',;
             BETWEEN(vin_duedate, ldDate- 30, ldDate-21), '21 -  30',;
             BETWEEN(vin_duedate, ldDate- 40, ldDate-31), '31 -  40',;
             BETWEEN(vin_duedate, ldDate- 60, ldDate-41), '41 -  60',;
             BETWEEN(vin_duedate, ldDate- 90, ldDate-61), '61 -  90',;
             BETWEEN(vin_duedate, ldDate-120, ldDate-91), '91 - 120',;
             [121+]),8);
 from scvndino


*** Smaller versions:
ldDate = .ydDate
select vin_ref,;
       PADR(IIF(vin_duedate  >= ldDate, [Current],;
       IIF(BETWEEN(vin_duedate, ldDate- 10, ldDate- 1), ' 1 -  10',;
       IIF(BETWEEN(vin_duedate, ldDate- 20, ldDate-11), '11 -  20',;
       IIF(BETWEEN(vin_duedate, ldDate- 30, ldDate-21), '21 -  30',;
       IIF(BETWEEN(vin_duedate, ldDate- 40, ldDate-31), '31 -  40',;
       IIF(BETWEEN(vin_duedate, ldDate- 60, ldDate-41), '41 -  60',;
       IIF(BETWEEN(vin_duedate, ldDate- 90, ldDate-61), '61 -  90',;
       IIF(BETWEEN(vin_duedate, ldDate-120, ldDate-91), '91 - 120',;
             [121+])))))))),8);
 from scvndino
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform