Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update Command not Updating at once
Message
From
31/10/2006 12:25:02
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Client/server
Title:
Update Command not Updating at once
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01165839
Message ID:
01165839
Views:
52
I have a Chart of accounts master table, which I also use for trial balance.
The master table has year opening balance in columns Ob_Dr & Ob_Cr.
The Coding of Account have 5 levels.
*------------------------------------------------------
*AC_NO               | AC_LEVEL | OB_DR    | OB_CR
*------------------------------------------------------
1                    |  1       |          |          |
1-01                 |  2       |          |          |
1-01-001             |  3       |          |          |
1-01-001-001         |  4       |          |          |
1-01-001-001-00001   |  5       | 500.00   |          |
1-01-001-001-00002   |  5       | 400.00   |          |
1-01-001-001-00003   |  5       |          |  300.00  |
1-01-001-002         |  4       |          |          |
1-01-001-002-00001   |  5       |  100.00  |          |
1-01-001-002-00002   |  5       |  600.00  |          |
1-01-002             |  3       |          |          |
1-01-002-001         |  4       |          |          |
1-01-002-001-00001   |  5       |  800.00  |          |
1-01-002-001-00002   |  5       |          |  600.00  |



*(Dashes are not part of Data)
Only ac_level = 5 can have the data. Which then i update to parent a/c.
 Trial Balance Should have
*------------------------------------------------------
*AC_NO               | AC_LEVEL | OB_DR    | OB_CR
*------------------------------------------------------
1                    |  1       |2400.00   |  900.00  |
1-01                 |  2       |2400.00   |  900.00  |
1-01-001             |  3       |1600.00   |  300.00  |
1-01-001-001         |  4       | 900.00   |  300.00  |
1-01-001-002         |  4       | 700.00   |          |
1-01-002             |  3       | 800.00   |  600.00  |
1-01-002-001         |  4       | 800.00   |  600.00  |
The following code is doing fine to get this result. But problem is that when i run for first time it just update upto level 4.
2nd time upto level 3.
3rd time upto level 2.
4th time upto level 1.
Question is: WHY IT IS NOT UPDATING AT ONCE?
local lcSql  ,;
      lcAcNo ,;
      lnAcLen,;
      lcLvl  ,;
      lnObDr ,;
      lnObCr
* Vmfc is view on SQLExpress
text to lcSql noshow 
   select * from Vmfc order by ac_level desc, ac_no desc
endtext
*
if SQLExec(hConn,lcSql, 'mfc') < 0
   return
endif
*
text to lcSql noshow
   update acc_mf 
      set ob_dr = ?0, ob_cr = ?0 
    where ac_level < '5'
endtext
=SQLExec(hConn, lcSql)
*
select mfc
go top
do while !eof() and ac_level != '1'
   lcLvl = ac_level
   do while !eof() and ac_level = lcLvl
      lcAcNo = getPrntAC(mfc.ac_no) && Returns Parent A/C Code   
      lnAcLen= len(lcAcNo)
      lnObDr = 0
      lnObCr = 0
      do while !eof() and ac_level + left(ac_no, lnAcLen) = lcLvl + lcAcNo
         lnObDr = lnObDr + mfc.ob_dr
         lnObCr = lnObCr + mfc.ob_cr
         skip
      enddo
*/    This block has the problem
      text to lcSql noshow
         update acc_mf
            set ob_dr = ob_dr + ?lnObDr,
                ob_cr = ob_cr + ?lnObCr
          where ac_level < '5'
            and ac_no = ?lcAcNo
      endtext
      =SQLExec(hConn, lcSql)
*//
      select mfc
   enddo
enddo
*
use in mfc
Next
Reply
Map
View

Click here to load this message in the networking platform