Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GETNEXTMODIFIED() detect add new rec
Message
From
23/11/2006 11:09:33
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01172021
Message ID:
01172083
Views:
14
>>>>>Does anyone know if GETNEXTMODIFIED() detects the addition of (maybe several) records to a buffered table, obviously, before TableUpdate() is issued?
>>>>>
>>>>>The new records will have had fields filled in before saving.
>>>>>
>>>>>'ppreciate it
>>>>>
>>>>>Terry
>>>>
>>>>Hey Terry,
>>>>It's all about GetNextModified() :)
>>>>ie:
>>>>
>>>>lnNext = GetNextModified(0)
>>>>do while m.lnNext # 0
>>>>  go m.lnNext
>>>>  if m.lnNext < 0 && new record
>>>>*...
>>>>  else && update
>>>>*...
>>>>  endif
>>>>  lnNext = GetNextModified(m.lnNext)
>>>>enddo
>>>>
Cetin
>>>
>>>Thank you, Cetin & Boris
>>>
>>>Thing is, I don't want to manufacture the save code. I've already got a class save method snippet from way, way back - half inherited and half altered by me, as follows:
>>>
>>>
>>>CASE Not lInDBC AND (ATC("2", GetFldState(-1)) <> 0 OR ATC("3", GetFldState(-1)) <> 0)
>>>	* Field was edited - in Free Table
>>>	* Since free tables are not supported by transactions,
>>>	* we must process record by record
>>>	lnModRecord = GetNextMod(0)
>>>  DO WHILE lnModRecord <> 0	                  && loop locks all records
>>>    GO lnModRecord
>>>    llSuccess                 = RLOCK()	&& Try to lock record
>>>    IF Not llSuccess			&& Failed to lock record
>>>	lcErrorMessage       = "Record in use by another user"
>>>	UNLOCK ALL
>>>	EXIT
>>>    EndIf
>>>    IF Not llHadMessage	&& so we don't repeat alert
>>>        * See if record(s) modified by another user
>>>        FOR lnFldCnt = 1 TO FCOUNT()
>>>	 IF TYPE(FIELD(lnFldCnt)) = "G"	&& Skip for General fields
>>>	     LOOP					
>>>	 ENDIF
>>>	 IF OLDVAL(FIELD(lnFldCnt)) <> CURVAL(FIELD(lnFldCnt))
>>>	     llHadMessage    = .T.
>>>   	     IF sysConfirm("The record has been changed by another user while you've been editing it.  " + ;
>>>                            "Do you want to overwrite the other user's changes with your own?")
>>>	         llOverwrite = .T.
>>>	     ELSE
>>>		llSuccess   = .F.
>>>		UNLOCK ALL
>>>		EXIT
>>>	     ENDIF
>>>          ENDIF OLDVAL()
>>>        ENDFOR
>>>    ENDIF Not llHadMessage
>>>    lnModRecord               = GetNextMod(lnModRecord)
>>>  ENDDO
>>>
>>>
>>>
>>>but afaik it's only been used to save one new rec at at time, as in a standard form new - input data - save scenario. In this case I create one record then maybe 3-4 "sister" recs and need to save them all together, or none at all, and it can't be done in a transaction, as theyt're free 2.6 tables. I feel that the above code would do just that. What do you think?
>>
>>This code didn't look like all-none to me.
>
>
>What does that mean? It isn't al the code but just that snippet that doesn't deal with deleted recs, or those in a database. i.e. it deals with saving non-dbc free tables.
>
>I should have said this portion would rarely be used as the saving of dbc tables in my apps would be dealt with in another CASE, in a transaction.
>
>Do you think it would work? It needs to recognise up to 4 new recs, with field data input, and save them.
>
>>And fox2x tables can be included in a transaction. For a transaction all you need is a dbc.
>
>I know that but the tables belong to a FPD2.6 app. If I added them to a VFP7 dbc then they'd get changed to a "future" format that the 2.6 sys didn't recognise wouldn't they?

Terry,
I can't be much explanatory right now (time wise). If you create a dbc with views in it for 2x they'd be transactional.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform