Focal Point
UPDATE Records

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3001030861

May 15, 2006, 12:58 PM
JOE
UPDATE Records
Help! I'm new to focus. I need to update a focus database. What I neeed to do seems basic? How do you for example update all records in field team that contain "night A" to "night b". I've been stuck for days. In Access this is a simple update query. Any example files that anyone can send me. Thanks,


WebFocus 7.7.02 WinXP
May 15, 2006, 01:10 PM
susannah
In order to physically update the records,
you need to use the MODIFY command
so, best to download and read the MODIFY manual.
Its pretty straight forward.
You can temporarily redefine a field, withoug physically updating the records using a DEFINE
either in the master or in your fex
DEFINE FILE filename
MYFIELD/A20=IF MYFIELD CONTAINS 'night A' THEN 'night B' ELSE MYFIELD;
END
This approach just redefines the value for reporting purposes, without physical change.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
May 15, 2006, 01:15 PM
Maintain Wizard
Joe
We have a product called Maintain. This product allows for easy Updates, Includes and Deletes. It is available in WebFOCUS and on the Mainframe. To do what you want, create a new procedure or Focexec. As long as the field is not a key field, updating is no problem.

MAINTAIN FILE
FOR ALL NEXT field1 INTO STK
WHERE field2 EQ 'night A'
COMPUTE I/I2=1;
REPEAT STK.FOCCOUNT
COMPUTE STK(I).field2 = 'night B';
COMPUTE I=I+1;
ENDREPEAT
FOR ALL UPDATE field2 FROM STK;
END

That's it. Here, file is the name of your file, field1 is the key field in the segment and field2 is the field that we are updating. I hope this helps.

Mark

This message has been edited. Last edited by: Maintain Wizard,
May 15, 2006, 01:16 PM
<DocServices>
MODIFY is documented in the following manual:
FOCUS for Mainframe Maintaining Databases 7.3 (DN1001059.1003).
May 15, 2006, 02:01 PM
JOE
Thanks, but I found out that Marketteam is unique and will not work. However, I think what I should do is the following:

TABLE FILE WKLYGFOC

BY PPNUMBER
BY WEEK_OF
BY MARKET
BY TEAM
WHERE WEEK_OF EQ '4/30/2006'
ON TABLE HOLD AS WGPJUNK
END


MAINTAIN FILE WKLYGFOC
FOR ALL NEXT WEEK_OF INTO STK
WHERE MARKET EQ 'Night'
WHERE TEAM EQ 'A'
COMPUTE I/I2=1;
COMPUTE I/I2=2;
REPEAT STK.FOCCOUNT
COMPUTE STK(I).MARKET = 'New';
COMPUTE STK(I).TEAM = 'Night Team';
COMPUTE I=I+1;
COMPUTE I=I+2;
ENDREPEAT
FOR ALL UPDATE MARKET FROM STK;
FOR ALL UPDATE TEAM FROM STK;
END

I need to update the field Market and the field team which are not unique. When I run this code I receive an error message. Any other help would be appreciated.

Thanks,


WebFocus 7.7.02 WinXP
May 15, 2006, 05:19 PM
susannah
Do you have a license for the MAINTAIN product?
if not, that may explain the error.
MODIFY you don't need a license for




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
May 15, 2006, 10:57 PM
JOE
No, I do not have a license that I'm aware of. Can the Modify command update all records permanatly in the database. This is what I'll need to do.

Thanks,


WebFocus 7.7.02 WinXP
May 16, 2006, 04:49 AM
Tony A
Joe,

Yes, MODIFY will permanently update records of your choosing. For some examples look in your IBINCCEN folder (or your Country equivalent) and look at those fexes that begin "load...". These are the fexes that are used to create the New Century Corp demo databases (All FOCUS). Some are multi segment DBs and you can see how navigating to a lower segment can take place.

But, before you venture forth into the land of MODIFY, what DB are you using as there might be altenatives (SQL UPDATE etc.)?

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
May 16, 2006, 08:17 AM
Maintain Wizard
If MARKET and TEAM are not keys, then this should work:

MAINTAIN FILE WKLYGFOC
FOR ALL NEXT WEEK_OF INTO STK
WHERE MARKET EQ 'Night'
and TEAM EQ 'A'
COMPUTE I/I2=1;
REPEAT STK.FOCCOUNT
COMPUTE STK(I).MARKET = 'New';
COMPUTE STK(I).TEAM = 'Night Team';
COMPUTE I=I+1;
ENDREPEAT
FOR ALL UPDATE MARKET TEAM FROM STK;
END
May 16, 2006, 08:45 AM
TexasStingray
All, you sure about MODIFY not needing a license I was under the impression that MODIFY and MAINTAIN both required a license. IBI allows you to use modify for Temporary files in a TABLE request, but if it is not a temporary file then a license is required, and if the file is a FOCUS database then the FDS requires a license.




Scott

yep
Modify comes with; its the backbone of the whole shebang. its what makes focus focus.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID