Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TableUpdate in View
Message
From
09/08/2000 20:06:14
 
 
To
09/08/2000 17:30:49
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00403088
Message ID:
00403166
Views:
11
>I have a form with a Grid (using View, updateable, buffermode = 5)... before the grid appears, on the form it prompts the user to enter a value to retrieve records from the table (100,000+ records) then a grid appears (a view with anywhere between a couple records to a few hundred records)... in testing my view retrieved 248 records, I made a change to just one record... clicked save (=tableupdate(1,.T.,"TAcustView")), a message "Running query...." with a progress bar appeared, and it went into a loop 9 times then it finished. I tried again with a different value, changed one record, it looped 11 times. Another value, it retrieved just a few records, it looped once. That's really strange... why? I checked the modified records (as well as the appended records) and all appears OK... but I find it puzzling that =tableupdate would "requery" too many times....
>
>Here's the code:
>
>* after prompting user for a value, pass it to SQL View to retrieve records
>
PROCEDURE txtTAID.LostFocus
>if empty(this.value)
>
* if blank, ask user if wish to cancel
>
if msg(1,'TA Rep#')
>thisform.cmdQuit.click()
>return
>else
>thisform.txtTAID.setfocus()
>endif
>endif
>select TAcustView
>mTAID = this.value
>requery()
>if reccount() = 0
>msg(12,'No Assigned CMRs for this TA')
>thisform.txtTAID.setfocus()
>Endif
>ENDPROC
>
>
* save changes (relinquish CMR assignment(s) from one TA rep to another TA rep)
>
PROCEDURE clsdtlbtns.cmdSave.Click
>local mRecNo
>select TAcustView
>go top
>do while not eof()
>if not empty(TAcustView.assumer) and TAcustView.actflag = .T.
>mRecNo = recno()
>scatter memvar
>m.taid = m.assumer
>m.effmo = thisform.txtEffMo.value
>m.effsysdt = datetime()
>m.assumer = space(6)
>m.user = gcUser
>insert into TAcustView from memvar
>go mRecNo
>repl endmo with m.effmo, endsysdt with datetime(), actflag with .F.
>endif
>skip
>enddo
>=tableupdate(1,.T.,"TAcustView")
>thisform.showdetails(.F.)
>ENDPROC
>


* A litle rewrite, with a different approach:
PROCEDURE clsdtlbtns.cmdSave.Click
LOCAL cTempAlias,aFldStruct[1],oScatterObj,cAliasIn,tNewEMo,cOrder
cAliasIn = ALIAS()
cTempAlias = SYS(2015)
tNewEMo = thisform.txtEffMo.value
SELECT 0
cOrder = ORDER('TAcustView')
=AFIELDS(aFldStruc,'TAcustView')
CREATE CURSOR (cTempAlias) FROM ARRAY aFldStruc
SELECT TAcustView
SET ORDER TO 0
SCAN FOR actflag and ! EMPTY(assumer)
   SCATTER NAME oScatterObj MEMO
   WITH oScatterObj
      *  If any fields in TAcustView get filled automagically by defaults in
      *  the DBC at create, excluse them in SCATTER using the EXCEPT clause
      *
      .taid = .assumer
      .assumer = ''
      .effsysdt = DATETIME()
      .effmo = tNewEmo
      .user = gcUser
   ENDWITH
   SELECT (cTempAlias)
   APPEND BLANK
   GATHER NAME oScatterObj MEMO
   SELECT TAcustView
   repl endmo with tNewEMo, endsysdt with datetime(), actflag with .F.
ENDSCAN
*  You never reprocess the new records, since they haven't been added yet
APPEND FROM (DBF(cTempAlias))  && pull in the cursor
USE IN (cTempAlias)
=tableupdate(1,.T.,"TAcustView")
SET ORDER TO &cOrder
LOCATE
thisform.showdetails(.F.)
IF ! EMPTY(cAliasIn)
   SELECT (cAliasIn)
ELSE
   SELECT 0
ENDIF
ENDPROC
>And in the SQL View:
>
>SELECT Tacust.*, Cmr.cmrname;
> FROM crsdata!tacust LEFT OUTER JOIN crsdata!cmr ;
> ON Tacust.cmrno = Cmr.cmrno;
> WHERE Tacust.taid = ?mtaid;
> AND Tacust.actflag = .T.
> ORDER BY Tacust.cmrno, Tacust.effmo, Tacust.endmo
>

>
>TIA
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform