when we are tying to update a table having 100 rows. if the
program abends when updating 51 row . how to start updating
again from the 51 row .what was the logic

Answers were Sorted based on User's Feedback



when we are tying to update a table having 100 rows. if the program abends when updating 51 row . ..

Answer / abhijit18in2002

when we are tying to update a table having 100 rows.
if the program abends when updating 51 row . how to start
updating again from the 51 row .
what was the logic


Ans: The Possible answer would be..if you had used COMMIT
before 51st ROW .. the Former records
would have been updated in the table .. If No COMMIt was
used.. The whole transaction would have been
ROLLBACKED.

Now If you want to start a fresh Transaction and want to
start Updating directly from 51st Row
Then There are two ways

1> Perform a loop to scroll till u have read 50 rows
Then Point ur cursor as CURRENT to the 51st Row
Start Updating the Records Till end of table.

or

2> Declare a Scrollable cursor & use FETCH ABSOLUTE option
to fetch a particular row directly


EXEC SQL FETCH ABSOLUTE +51 C1
INTO :TEMP1, :TEMP2, :TEMP3;


this statement fetches the 51st row of the Table

Is This Answer Correct ?    8 Yes 5 No

when we are tying to update a table having 100 rows. if the program abends when updating 51 row . ..

Answer / kamra2010

1) Create two work files, say WORK-1 and WORK-2.
2) Unload the table into file WORK-1.
3) Pass the commit frequency through the JCL to the program.
4) Program logic:
(i) read the input file WORK-1
(ii) update the table
(iii) if the number of records updated in the table is
equal to the commit frequency then apply COMMIT command.
Also, write the last committed record into the output file
WORK-2. (this record will be used for restart logic)

(iv) In Restart process,
a. read the output file record
b. next, the input file will be read untill it
finds the corresponding output file record
c. follow the same step 4(i) to step 4(iii)

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More DB2 Interview Questions

How is a typical DB2 batch program executed ?

1 Answers  


How to insert more than one record using insert?

7 Answers   Atos Origin, IBM,


What is copy book?

1 Answers   Thomson Reuters,


How do you simulate the explain of an embedded sql statement in spufi/qmf?

0 Answers  


Can there be more than one cursor open for any program?

0 Answers  






What is the difference between IN subselects and EXISTS subselect?

1 Answers   HCL, PreVator, TCS,


What is dbrm library?

0 Answers  


in the CURSOR declare statement, if i am using an where clause and trying to compare the value with a host-varialble. EXEC SQL DECLARE C1 CURSOR FOR SELECT DEPTNO, DEPTNAME, MGRNO FROM DEPARTMENT WHERE ADMRDEPT = :ADM-DEPT Where would i need to provide value to this host-variable in the where clause. how could i pass value to this host-variable to check it.

2 Answers   iGate,


What do the initials DDL and DML stand for and what is their meaning?

2 Answers  


How connect db2 database to datastage?

0 Answers  


what is the syntax for FOR UPDATE CLAUSE in cursor declaration and how can u update using cursor? is it possible to update multiple rows at a time.

2 Answers   Syntel,


In cobol+DB2program if the code of cobol program has changed than i have to do precompilation once again?

6 Answers   TCS,


Categories