Focal Point
Update Database Query

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

July 27, 2005, 12:02 PM
<Faisal I Rathor>
Update Database Query
I am getting all the values from one table and inserting into another table using Maintain tool.
Please see my code,
==========================================
MAINTAIN FILE e2fday AND e2fout

$$Declarations

Case Top
Reposition e2fday.E2FDAY.SNRF ;
Stack clear GETSTACK ;
For all next e2fday.E2FDAY into GETSTACK;
COMPUTE Cnt/I4 = 1
REPEAT WHILE GETSTACK.FocCount GE Cnt;
For all include e2fout.E2FOUT from GETSTACK(Cnt);
COMPUTE Cnt = Cnt + 1
ENDREPEAT;
COMMIT;
IF FocError NE 0 THEN TYPE Cnt;
Winform Show Form1;
EndCase
END
==========================================
My origional data contains 896 rows but 846 rows are inserted into second datasource.
Your comments or suggestions will be appreciated.
July 27, 2005, 12:39 PM
Maintain Wizard
If you are including less records than you are expecting, you are probably having collisions. Instances where you are trying to include a record whose keys have already been included. Your logic says to continue processing even after one of these occurs.

Your logic is a little non-standard. If you want to keep processing after a collision and keep track of the records not included, try this:

MAINTAIN FILE e2fday AND e2fout

$$Declarations

Case Top
Reposition e2fday.E2FDAY.SNRF ;
Stack clear GETSTACK ;
For all next e2fday.E2FDAY.SNRF into GETSTACK;
infer e2fday.E2FDAY.SNRF into COLSTACK;
COMPUTE Cnt/I4 = 1
REPEAT GETSTACK.FocCount;
Include e2fout.E2FOUT from GETSTACK(Cnt);
If Focerror ne 0 then
Copy from Getstack(Cnt)
INTO COLSTACK(COLSTACK.FOCCOUNT+1);
COMPUTE Cnt = Cnt + 1
ENDREPEAT;
COMMIT;
IF FocError NE 0 THEN TYPE Cnt;
Winform Show Form1;
EndCase
END

On your form, place an HTMLTable to display COLSTACK and you can see which records were not included.

I hope this helps
Mark
July 28, 2005, 05:12 AM
<Faisal I Rathor>
thanks for your help.
You are correct that my code is little bit non standard beceause I am new to WebFocus.