can we update the table by using cursors can anyone post
the query?

Answers were Sorted based on User's Feedback



can we update the table by using cursors can anyone post the query?..

Answer / bigben

yes you can
declare cursor using FOR UPDATE option

Is This Answer Correct ?    23 Yes 0 No

can we update the table by using cursors can anyone post the query?..

Answer / diana

Yes you can update the table using cursor....
for eg: if you want to update 3 columns like A,B,C the you
can write as:

Update Table_name
Set A = :Host varaible(value)
B = :Host varaible(value)
C = :Host varaible(value)
where current of C1(Cursor name)

Is This Answer Correct ?    9 Yes 0 No

can we update the table by using cursors can anyone post the query?..

Answer / amar

DECLARE
INT NUMBER:=0;
CURSOR C1 IS
SELECT COL1,COL2 FROM TABLE_NAME;
BEGIN
FOR RC IN C1 LOOP
UPDATE TABLE_NAME SET COL_NAME=RC.COL1,COL_NAME=COL2;
CNT:=CNT+1;
END LOOP;
END;

Is This Answer Correct ?    1 Yes 0 No

can we update the table by using cursors can anyone post the query?..

Answer / siri

suppose we want update ename in emp table using cursor....

declare crsorname cursor for
select * from emp
where dept='d005'
for update of ename....


upate emp
set ename=:ename
where current of cursor

Is This Answer Correct ?    0 Yes 0 No

can we update the table by using cursors can anyone post the query?..

Answer / mee

yes its possible

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More DB2 Interview Questions

What is db2 and what is the use of db2 optimizer?

0 Answers  


What is meant by isolation level?

3 Answers  


In cursor program perform para varying until 1 by 1 fetch para cursor------close para in the blank what will come for confirming in the database?

1 Answers   HCL,


What is a db2 schema?

0 Answers  


What are the functions of Bind?

2 Answers   Amdocs, IBM,






What is the COBOL picture clause of the following DB2 data types: DATE, TIME, TIMESTAMP?

3 Answers  


what is the sqlcode -501

5 Answers   IBM, Polaris, Zeus,


have 3 tables table1, table2 and table3 which contains employee information. table1 is master table, table2 contains emp details like emp no and so on, table 3 contains emp salary. so if any emp leave company between 25th - 30th of every month it has to get updated in tables. but it is not getting updated. What is the reason.

0 Answers  


In my table having 100 Rec. How can I delete the 7th row?? (we don't know what is data inside the table)

9 Answers   IBM,


What is the syntax for FETCH in DB2 ?

0 Answers   MCN Solutions,


What is sqlcode -811?

7 Answers   Accenture, CTS, TCS,


How do you Load a table ?? and what is Load replace ?

2 Answers   Xansa,


Categories