Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Record Process Time
Message
From
31/03/2004 05:10:22
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
30/03/2004 17:27:00
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00891016
Message ID:
00891104
Views:
27
Hi Jeffrey

>Can anyone tell me if there's an quicker way than what is currently coded? Is it necessary to update teh view before I continue processing? or can i just cotninue to add records and update the table once the process i complete?

There's a number of things you can do to improve the existing code.
SELE FEDLOG
SCAN
   SELECT V_UPNOMEN
*How are the parameters being set? I hope you didn't hard code a reference to FEDLOG into your view.
   =REQUERY()
	
   IF _TALLY = 0	&& REcord not found in Nomen table, THEN INSERT IN!
	INSERT INTO V_UPNOMEN(pk_nom_id, nsn, item_name, item_desc) VALUES (oVar.NextId, oVar.ThisNsn, ALLTRIM(oVar.Item_name), ALLTRIM(oVar.Item_desc))
* You don't need this since you're specifying the alias everywhere.
*	SELECT v_upNomen
   ELSE  &&RECORD FOUND IN NOMEN TABLE, CHECK IF UPDATES ARE NECESSARY
 
	DO CASE
           *You don't need to alltrim(). It's empty if there are just spaces.
           CASE EMPTY(V_UPNOMEN.item_desc)
	       REPLACE ITEM_DESC WITH ALLTRIM(UPPER(oVar.Item_Desc)) IN V_UPNOMEN
			
	   CASE EMPTY(V_UPNOMEN.item_name)
	      REPLACE ITEM_NAME WITH ALLTRIM(UPPER(oVar.Item_Name)) IN V_UPNOMEN
	ENDCASE
   endif		
*You don't need this, just add the alias to the tableupdate.
*	SELECT v_upNomen

	=TABLEUPDATE(.T.,v_upNomen)

*You don't need this as the data in the record should be
*correct since you just updated it, why get it again?
*	=REQUERY()
	
*You don't need this either.
*Scan/Endscan resets to the
*correct workarea.
*	SELECT FEDLOG
ENDSCAN
You cannot requery once you've changed the record, until you tableupdate/tablerevert.

Beyond that, the fact that you're doing this in a scan loop, makes me think it would be much faster to run one or two queries joining FEDLOG and NOMEN that determine

1) Which records in fedlog have no nomen records, then you mass add them.
2) Which records in fedlog have nomen records that need updating, then you mass update them.

I'm not sure how you are joining fedlog and nomen, so this is just a guess. Just make sure c_massadds matches the structure of nomen.

select fedlog.* from fedlog where fedlog.nomenid not in (select nomenid from nomen) into cursor c_massadds nofilter

select nomen
append from c_massadds

select fedlog.* from fedlog inner join nomen on fedlog.nomenid = nomen.nomenid and (empty(nomen.item_name) or empty(nomen.item_desc) into cursor massupdates

HTH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform