What is the purpose of coding FETCH in a SQL SELECT query?
Explain with an example in Detail?

Answers were Sorted based on User's Feedback



What is the purpose of coding FETCH in a SQL SELECT query? Explain with an example in Detail?..

Answer / guest

FETCH is used to retrieve a specific row from a result set
of the SELECT query and places them into local variables.

Is This Answer Correct ?    2 Yes 0 No

What is the purpose of coding FETCH in a SQL SELECT query? Explain with an example in Detail?..

Answer / anandrao

FETCH will give only the number of rows equal to the number
specified with FETCH from resultset given by query.
e.g. consider ACCOUNT_MASTER table contains 100 rows.
SELECT *
FROM ACCOUNT_MASTER
FETCH FIRST 10 ROWS ONLY.
Will give only first 10 rows of ACCOUNT_MASTER table from
100 rows of ACCOUNT_MASTER table

Is This Answer Correct ?    1 Yes 0 No

What is the purpose of coding FETCH in a SQL SELECT query? Explain with an example in Detail?..

Answer / siri reddy

Inorder to select first n number of rows fetch is used in
conjunction with select statement

Is This Answer Correct ?    1 Yes 1 No

What is the purpose of coding FETCH in a SQL SELECT query? Explain with an example in Detail?..

Answer / akviswa

PS: fetch can be used in select only in case of cursor
select

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More DB2 Interview Questions

Is it possible to alter a table – for example adding a column, when another user is accessing or updating some columns?

0 Answers  


If we have 100 records in the PF, we deleted all the records then what is the Size of the PF?

2 Answers  


What is the use of commit in db2?

0 Answers  


Hi i need to write a query on the following requirement. SELECT COMM_TEXT INTO :WS_MIKM_COMM_TEXT FROM MPIPROD.MIKMV01 WHERE ACCOUNT_NO = :WFD_ACCOUNT_NO AND (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT AND SUBSTR(COMM_TEXT,47,14) = :WS_DENY_DESC) OR (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT) The above query is to be modified. The requirement is if both the fields are equal then that has to be given priority. In the above query if it satisfies any one it comes out without checking if both being equal is possible.

1 Answers  


What is multi row fetch in db2?

0 Answers  


What is the significance of DB2 free space and what parameters control it?

1 Answers  


Explain the function done by data manager?

0 Answers  


How to rename a table in DB2 ?

0 Answers   MCN Solutions,


What is the connection string to connect to the DB2 Database ?

0 Answers   MCN Solutions,


What is universal database?

0 Answers  


What is a cursor and what is its function?

2 Answers  


What is db2 purescale?

0 Answers  


Categories