Focal Point
KEY VALUE CHANGE

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

March 01, 2006, 07:00 AM
Busca
KEY VALUE CHANGE
I need t replace a key value for all records in a Focus db (not in interactive mode)
In Focus I made it with SCAN command and
-REPEAT of DM
In WF 5.x this feature has been removed.
How can I do ?
I NEED THIS FEATURE TO SAFE TIME, MONEY and TO AVOID ERRORS (HOLD and LOAD)
Someone can help me ?
Thanks Paolo
March 01, 2006, 08:17 AM
Maintain Wizard
You could use Maintain to accomplish this. You would read in all the values. Make a copy of the stack and change the keyfield. Then include the new records and delete the old. The code would look like:

MAINTAIN FILE file
FOR ALL NEXT keyfield INTO STK
INFER keyfield INTO NEWSTK
STACK COPY FROM STK INTO NEWSTK
COMPUTE I/I4=1;
REPEAT NEWSTK.FOCCOUNT
COMPUTE NEWSTK(I).keyfield = 'NEW VALUE';
COMPUTE I=I+1;
ENDREPEAT
FOR ALL INCLUDE keyfield FROM NEWSTK
IF FOCERROR = 0 THEN
FOR ALL DELETE keyfield FROM STK
END
March 01, 2006, 08:23 AM
Busca
Thanks, but this works also if the key field is in the parent segment an the db has got other childs segment ?
I don't know if DELETE works right.
Thanks
Paolo
March 01, 2006, 10:39 AM
Maintain Wizard
It will work with parent / child relationships. You just need to add the child field to the NEXT, INCLUDE and DELETE statements. Using the CAR file, it would look like:

NEXT COUNTRY CAR INTO STK

INCLUDE COUNTRY CAR FROM NEWSTK

DELETE COUNTRY CAR FROM STK
March 03, 2006, 09:20 AM
Busca
Sorry but I get

(FOC03833) Internal Error detected in MASPAR :Inconsistent KEY information:
ERROR AT OR NEAR LINE 16 IN PROCEDURE TSTMAINT FOCEXEC *
(FOC03833) Internal Error detected in MASPAR :MATCH:

with the following statement

MAINTAIN FILE CAR
FOR ALL NEXT COUNTRY CAR INTO STK
INFER COUNTRY INTO NEWSTK
STACK COPY FROM STK INTO NEWSTK
COMPUTE I/I4=1;
REPEAT NEWSTK.FOCCOUNT
COMPUTE NEWSTK(I).COUNTRY='PIPPO';
TYPE NEWSTK(I).COUNTRY ;
COMPUTE I=I+1;
ENDREPEAT
FOR ALL INCLUDE COUNTRY CAR FROM NEWSTK
IF FOCERROR = 0 THEN
FOR ALL DELETE COUNTRY CAR FROM STK
END
END
-RUN

Where is the error ?
Paolo
PS I have never used maintain
March 03, 2006, 01:08 PM
Maintain Wizard
In your scenario, you would need to include the CAR field to NEWSTK. Try this...

MAINTAIN FILE CAR
FOR ALL NEXT COUNTRY CAR INTO STK
INFER COUNTRY CAR INTO NEWSTK
STACK COPY FROM STK INTO NEWSTK
COMPUTE I/I4=1;
REPEAT NEWSTK.FOCCOUNT
COMPUTE NEWSTK(I).COUNTRY='PIPPO';
TYPE NEWSTK(I).COUNTRY ;
COMPUTE I=I+1;
ENDREPEAT
FOR ALL INCLUDE COUNTRY CAR FROM NEWSTK
IF FOCERROR = 0 THEN
FOR ALL DELETE COUNTRY CAR FROM STK
END
-RUN
March 07, 2006, 04:16 AM
Busca
Sorry but I get the error
ex tstmaint
(FOC03833) Internal Error detected in MASPAR :Inconsistent KEY information:
ERROR AT OR NEAR LINE 16 IN PROCEDURE TSTMAINT FOCEXEC *
(FOC03833) Internal Error detected in MASPAR :MATCH:
with the following statement:
USE
/u/abp0/car.foc
END

MAINTAIN FILE CAR
FOR ALL NEXT COUNTRY CAR INTO STK
INFER COUNTRY CAR INTO NEWSTK
STACK COPY FROM STK INTO NEWSTK
COMPUTE I/I4=1;
REPEAT NEWSTK.FOCCOUNT
COMPUTE NEWSTK(I).COUNTRY='PIPPO';
TYPE NEWSTK(I).COUNTRY ;
COMPUTE I=I+1;
ENDREPEAT
FOR ALL INCLUDE COUNTRY CAR FROM NEWSTK
IF FOCERROR = 0 THEN
FOR ALL DELETE COUNTRY CAR FROM STK
END
-RUN
March 07, 2006, 08:09 AM
Maintain Wizard
I don't know why you are getting an error.
Try this. Before the INCLUDE and before the DELETE insert the line:
REPOSITION COUNTRY

If that doesn't help, comment out the DELETE and INCLUDE statements. See if you are actually retrieving the data from the CAR file. Make a back-up of the CAR.FOC file and just put the DELETE back in. See if the DELETE or the INCLUDE is causing the error.

What release and platform are you on?
March 10, 2006, 04:03 AM
Busca
>>ex tstmaint
DELETE commented:
(FOC03833) Internal Error detected in MASPAR :Inconsistent KEY information:
ERROR AT OR NEAR LINE 17 IN PROCEDURE TSTMAINT FOCEXEC *
(FOC03833) Internal Error detected in MASPAR :MATCH:

INCLUDE commented:
>>ex tstmaint
(FOC03833) Internal Error detected in MASPAR :Inconsistent KEY information:
ERROR AT OR NEAR LINE 20 IN PROCEDURE TSTMAINT FOCEXEC *
(FOC03833) Internal Error detected in MASPAR :MATCH:

Both commented:
>>ex tstmaint
PIPPO
PIPPO
PIPPO
PIPPO
PIPPO
PIPPO
PIPPO
PIPPO
PIPPO
PIPPO

TRANSACTIONS: COMMITS = 1 ROLLBACKS = 0
SEGMENTS : INCLUDED = 0 UPDATED = 0 DELETED = 0
--------------------------------------
Release:
RELEASE = R720532B
GEN_NUM = 01.07
SOURCE_DATE = 09/29/2004 15:59:01
BUILD_DATE = 09/29/2004 22:51:19
INSTALLATION_DATE = 11/09/2004 13:31:23

ON AIX 4.3.3

Thanks
Paolo
March 10, 2006, 09:48 AM
Maintain Wizard
I am starting to think you cannot update that file. Let's try a very simple test. What does this yield:

MAINTAIN FILE CAR
COMPUTE COUNTRY = 'USA';
INCLUDE COUNTRY;
END

See if this includes USA as a country.

Mark
March 10, 2006, 10:04 AM
Tony A
Not wishing to butt in Mark, but are we sure that Paolo's USE is functioning and not pointing to an empty or non-existant FOC file?

Paolo,

Try this first -

USE
/u/abp0/car.foc
END
TABLE FILE CAR
BY COUNTRY
END


If you get a report output then we know your USE is working, if not .... then fix that first.

Now try Mark's request and progress.

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 
March 20, 2006, 07:08 AM
Busca
We are going to migrate to a new IBM machine with AIX5.3 (new library, etc...)
I have installed wf5.3.2 on the machine and here
the same test on mantain procedure works fine
I don't know why.
However my problem has been resolved; thanks to all.