Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Continuous invoice numbers
Message
From
16/06/2012 16:00:08
 
 
To
13/06/2012 09:57:26
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2003
Database:
MS SQL Server
Miscellaneous
Thread ID:
01545936
Message ID:
01546155
Views:
112
This text is Dragan Nedeljkovich wrote for me, because my English is not the best.
First, I want to thank Dragan, and everyone who are helped in this topic.
Yes, I finally, when I saved a header at the end of the transaction (before commit / Rollback), I call the table counter with Refresh (), increased the counter by one. Then I transfer of the header, the header again saved with tableupdate () and I do commit. If the counter returned null, Rollback to process the document level (header and lines,,,).

I do not use FLOCK () on the counter, do the lock itself TRANSACTION.
Why? Because at one point, the data can be transferred into a RDBMS (MS SQL Srv, postgreskl ...), FLOCK / UNLOCK, them there not used.

Example:
...
oKD=CREATEOBJECT("PromKD")       && Header
...
oKD.oDat.BeginTrans()
...
SELECT CaIdDok                                     && CursorAdapter Counter table IdDok

oKD.oIdDok.NewBrFakCA(this.ckljucimefak )

llOk=IIF(ISNULL(lcId),.F.,.T.)
...

IF llOk
  sele v_promkd                                   && CursorAdapter Header table
  repl next 1 BrFak With lcId
   llOk= tableUpd()
ENDIF

if llOk
   oKD.oDat.Committrans()
ELSE
    oKD.oDat.RollBackTrans()
ENDIF
*****
NewBrFakCA
LPARAMETERS tcKey
LOCAL lnRetVal, ;
   lnwa, ;
   lcid, ;
   lcKey
      
lcKey=tcKey      
lcId=null

lnwa=SELECT(0)      

SELECT Caiddok

LOCAL a,lnnrf
a=0
lnR=-6

DO WHILE a<15 AND lnRl<>0

    SELE CaIdDok

    =REFRESH()
    
     lcId=ALLT(STR(VAL(Vrednost) + 1))

    UPDATE CaIdDok SET Vrednost = lcId

     IF  !TABLEUPDATE()
          =AERROR(aErrA)
       lnRetVal = aErrA[1]
    ELSE
           lnRetVal= 0
    ENDIF

    IF lnRetVal<>0
         SELECT  CaIdDok
         =TABLEREVERT(.t.)
         a=a+1
     ELSE
          SELECT CaIdDok
          EXIT		
    ENDIF

ENDDO
  
SELECT (lnwa)

lcId=IIF(lnRetVal = 0,lcid,null)

RETURN lcId
...

Inside the
DO WHILE a<15 AND lnRl<>0
, an error occurs 130 or 1585.
Question: where and when to call the table counter (CaIdDok)?
Within a transaction, when I call the counter table (CaIdDok), properly done only Refresh(), but CursorRefresh() or Requery() not done.
And... Sorry, my English is not the best.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform