1 / 19

Select * from Student

What Will Be the Output Of. Select * from Student. I want to Display the LAST record I may require to move to the First record I want to go to record no 5 I want to go the next record … Previous Record. I am Sorry ????. Select Statement . Select……….

thimba
Download Presentation

Select * from Student

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What Will Be the Output Of Select * from Student

  2. I want to Display the LAST record I may require to move to the First record I want to go to record no 5 I want to go the next record … Previous Record..

  3. I am Sorry ???? Select Statement

  4. Select……… • Operations in a relational database act on a complete set of rows. • The set of rows returned by a SELECT statement consists of all the rows that satisfy the conditions in the WHERE clause of the statement. • This complete set of rows returned by the statement is known as the result set

  5. I am Sorry ???? Select Statement I am Comfortable cursor

  6. Cursor • Is a database object who can navigate the records one by one not as a whole. • Using cursor we can move forward, backward, jump some records ahead, position the record pointer at any position. • We can able to update / Delete current records.

  7. Cursors extend result processing by: • Allowing positioning at specific rows of the result set. • Retrieving one row or block of rows from the current position in the result set. • Supporting data modifications to the rows at the current position in the result set. • Providing Transact-SQL statements in scripts, stored procedures, and triggers access to the data in a result set.

  8. Types of Cursor

  9. Attribute

  10. Steps to Declare & use • Declare the Cursor • Open the cursor • Fetch the Cursor • Close the Cursor

  11. Declaring DECLARE cursor_name CURSOR [ FORWARD_ONLY | SCROLL ] [ STATIC |DYNAMIC ] FOR select_statement [ FOR UPDATE [ OF column_name [ ,...n ] ] ]

  12. Declaring a Forward readonly Cursor DECLARE frd_cur CURSOR FORWARD_ONLY STATIC FOR Select * from student Declaring a Forward Updateable Cursor DECLARE frd_cur CURSOR FORWARD_ONLY Dynamic FOR Select * from student

  13. Opening The Cursor Open <cursor_name> This will Open the cursor for use.

  14. Fetching FETCH         [ [ NEXT | PRIOR | FIRST | LAST                 | ABSOLUTE { n }                 | RELATIVE { n }             ]             FROM         ] <cursor_name >

  15. Closing the Cursor Close <cur_name> This will Close the Cursor.

  16. Example (Forward Readonly) Declare cur1 Cursor for Select * from stud Open cur1 Fetch next from cur1 Close cur1

  17. Example (Forward Dynamic) 1. Declare cur1 Cursor dynamic for Select * from stud for update 2. Open cur1 3. Fetch next from cur1

  18. Deleting the Current Record using Cursor Delete from stud where current of cur1

  19. Example (Scroll Readonly) Declare cur1 Cursor Scroll for Select * from stud Open cur1 Fetch absolute 5 from cur1 Fetch relative 5 from cur1 Close cur1

More Related