Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


suppose in my table 10 rows are there , i want to update odd
rows salary as 90000 ? how u do it ? any one help me ? what
do we use here cursor-fetch or normal sql ?

Answers were Sorted based on User's Feedback



suppose in my table 10 rows are there , i want to update odd rows salary as 90000 ? how u do it ? a..

Answer / pandu

Hi Krishna, Actually your answer is ok but i have a small
doubt "he want to update odd rows salary as 9000" but in ur
answer i didn't find the odd rows.how will you divide that
table in odd rows and even rows? kindly tell me.

Is This Answer Correct ?    4 Yes 1 No

suppose in my table 10 rows are there , i want to update odd rows salary as 90000 ? how u do it ? a..

Answer / vaneeshkhurana

Basically we can create a structure where first fetch then
update the fetch 2 times and update once again fetch 2 times
and update once again fetch 2 times and update once... and
keep on fetching 2 times and updating it once till table
code 100 comes.

This will update only the odd rows.

Is This Answer Correct ?    0 Yes 0 No

suppose in my table 10 rows are there , i want to update odd rows salary as 90000 ? how u do it ? a..

Answer / saurabh

It can be achieved using the scroll able cursor along with the Relative option while updating the queue.

Is This Answer Correct ?    0 Yes 0 No

suppose in my table 10 rows are there , i want to update odd rows salary as 90000 ? how u do it ? a..

Answer / harsha

The first answer is correct. It has a logic to select only
ODD rows(look at the two fetch statements).

Another logic to select only ODD rows.
SELECT SAL FROM EMP WHERE MOD(SAL,2)=1

Is This Answer Correct ?    1 Yes 2 No

suppose in my table 10 rows are there , i want to update odd rows salary as 90000 ? how u do it ? a..

Answer / krishna

Declare:
EXEC SQL
DECLARE CURSOR C1 FOR SELECT SAL FROM EMP FOR
UPDATE SAL
END-EXEC.
OPEN:
OPEN C1
FETCH:
PERFORM UNTILL SQLCODE=100
FETCH C1 INTO :SAL
UPDATE EMP SET SAL=9000 WHERE CURRENT OF C1
FETCH C1 INTO :SAL
END-PERFORM

Is This Answer Correct ?    10 Yes 13 No

Post New Answer

More DB2 Interview Questions

What does reorg do in db2?

0 Answers  


There is a 5000 EMP in company.how we find out the 5th highest getting salary employee outof 5000 employes........

10 Answers   IBM,


What is the difference between static and dynamic SQL?

1 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,


What is null indicator in db2?

0 Answers  


When do you specify the isolation level?

0 Answers  


How do you retrieve the first 5 characters of firstname column of db2 table emp?

1 Answers  


How does one remove entries from the SCT02 table?

1 Answers  


Q4. How will you get the count of record without using COUNT verb in query?

2 Answers   IBM,


we can code COPY DCLGEN or INCLUDE DCLGEN, At which stage of the precompilation , dclgen get expanded if we write 1) copy 2) include one question about dclgen.. Is it mandatory to use declare table in dclgen.. I think no...but it will be used by the precompiler to validate the table name,column name etc.., can one clear my doubt ..is it necessary to include declare table or not?

2 Answers  


What is a base table?

2 Answers  


When can an insert of a new primary key value threaten referential integrity?

2 Answers   Mind Tree,


Categories