Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Append new record
Message
From
27/06/2005 03:38:18
 
 
To
27/06/2005 03:10:02
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01026609
Message ID:
01026626
Views:
15
hi,

thank you ,it works
but it summed all groups except the last group.




>Perhaps I'm being overly critical, but you really need to start learning how to debug these basic kinds of problems for yourself.
>
>I imagine that the SKIP command where you got the error gave an "End of File Encountered" message. (By the way, when you say that you get an error, it is always useful to include what the error message is. The more information you can provide, the easier it is to offer help).
>
>This error happens when you are already at EOF() and try to do a skip. The SUM command physically processes the entire table (unless you provide a SCOPE clause of some sort) and repositions the table at EOF(). You can check for this by examining RECNO() and EOF() before and after you issue the command.
>
>If the record pointer has moved as a result of the SUM command, that means you have to store the record number of the newly insertted record and then go back to it after you have done your SUM.
>
>So your code should be
>
>     IF NOT EOF()
>          INSERT BEFORE BLANK
>          m.lnCurRec = RECNO()
>          SUM VAL(LEFT(tot_m,8))*3600 + ;
>            VAL(SUBSTR(tot_m,6,3))*30 + ;
>            VAL(RIGHT(tot_m,6)) TO lnSec for m.divi = curbilldata.divi
>          m.dae= PADL(INT(lnSec/3600), 6, "0") + ":" + ;
>                 PADL(INT((lnSec%3600)/60),2, "0")
>          GOTO m.lnCurRec
>           replace m1_m WITH m.dae
>           SKIP &&& i get error
>     ENDIF
>
>
>>hi,
>>thank you very much,it works
>>another thing
>>i need to insert data at this new records as under
>>
>>
>>
>>
>>USE curbilldata
>>
>>DO WHILE NOT EOF()
>>     m.divi = curbilldata.divi
>>     DO WHILE m.divi = curbilldata.divi AND NOT EOF()
>>          SKIP
>>     ENDDO
>>     IF NOT EOF()
>>
>>
>>             INSERT BEFORE BLANK
>>SUM VAL(LEFT(tot_m,8))*3600 + ;
>>	VAL(SUBSTR(tot_m,6,3))*30 + ;
>>	VAL(RIGHT(tot_m,6)) TO lnSec for m.divi = curbilldata.divi
>>
>>m.dae= PADL(INT(lnSec/3600), 6, "0") + ":" + ;
>>				PADL(INT((lnSec%3600)/60),2, "0")
>>             replace m1_m WITH m.dae
>>          SKIP &&& i get error
>>     ENDIF
>>ENDDO
>>
>>
>>thanks.
>>>APPEND BLANK puts a new blank record at the end of the table and therefore does not put a blank record where you seem to be expecting it.
>>>
>>>There is an old INSERT command which is sill supported in VFP 6 for backwards compatability. I don't know if it has been kept in any of the later versions. So the code you want is
>>>
>>>
>>>USE table1
>>>DO WHILE NOT EOF()
>>>     m.divi = table1.divi
>>>     DO WHILE m.divi = table1.divi AND NOT EOF()
>>>          SKIP
>>>     ENDDO
>>>     IF NOT EOF()
>>>          INSERT BEFORE BLANK
>>>          SKIP
>>>     ENDIF
>>>ENDDO
>>>
>>>
>>>While the above code does (I think) what you asked for, I suggest you seriously rethink whatever it is you are trying to do that wants you to physically place a blank record before each change of divi. Putting any sort of index on divi will cause these blank records to move elsewhere in the ordered table. In addition, each time you INSERT BLANK BEFORE you are making a full copy of the table to insert the blank record. On large tables, this is hideously inefficient. While I don't know exactly what you need to get done, I'm sure there must be a better way than this to do it.
>>>
>>>
>>>
>>>>hi all,
>>>>
>>>>i need to append new record if the item name is different
>>>>ex..
>>>>
>>>>use table1
>>>>m.divi=divi
>>>>scan
>>>>if m.divi<>divi
>>>>append blank
>>>>endif
>>>>endscan
>>>>*****************************
>>>>ex....
>>>>
>>>>field name is divi
>>>>               a
>>>>               a
>>>>               a
>>>>---------------------->new record
>>>>               bb
>>>>               bb
>>>>---------------------> new record
>>>>               sss
>>>>               sss
>>>>                .
>>>>                .
>>>>
>>>>thanks.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform