Hi , I am posting some interview ques .
what is the use of cursors ? what is the diff between
select and cursor ? bith are used for data retrival ..
rite?
Answers were Sorted based on User's Feedback
Answer / yuvaevergreen
>>Cursors are memory structures used to handle multiple
rows at a time.
>>Though,select statement can fetch only multiple rows, we
cannot handle multiple rows using host variables.
Basic difference would be single row handling and multiple
rows handling.
Is This Answer Correct ? | 6 Yes | 0 No |
Answer / reddy
cursors are used to retrieve multiple rows . Cussors will
retrieve one row at a time and save the data in the
hostvariables.For retreiving the 2 nd row, we need to
repeat the loop.the same process is continued at the end of
data.
select stmt will retrieve multiple rows at a time. assume
that there are 10 rows in a table.
EX: EXEC SQL
SELECT empno , ename into :hvempno ,:hvename from emp;
END EXEC;
Here the above sql query reults all the 10 rows. But , the
host variables will hold only one row of data.the remaining
9 rows will not be stored any where.
hope this may help u
Is This Answer Correct ? | 4 Yes | 4 No |
Is the primary key a clustered index?
Can a primary key have null values? If we try to insert a null value in a primary key column, will it work or give an error code?
what's the error code for Unique Index Violation?
What do you mean by storage group (stogroup)?
What's the maximum number of characters that a tablename can have?
assume ther are 5000 records in a database and want to fetch using cursor. cursor fetches only 3000 records and fetch is not happening for remaining 2000 records. why it happens and how to rectify it
What is a root page?
What are host variables in db2?
what is rebinding ?
What is the function of buffer manager?
Shall i use this query to retrieve first 4 records, Select empno, sal from emptbl where empno < 5. like this can we fetch first 100 records?
if suppose i am having an ACCOUNT table with 3 coloumns ACC. NO,ACC. NAME,ACC. AMOUNT . If a unique index is also defined on ACC.NO and ACC.NAME then write a query to retrieve account holders records who have more than 1 ACC.