zoukankan      html  css  js  c++  java
  • sql:oracle, CURSOR

      

    Cursors
    You use a cursor to fetch rows returned by a query. You retrieve the rows into the cursor using a
    query and then fetch the rows one at a time from the cursor. You typically use the following five
    steps when using a cursor:
    1. Declare variables to store the column values for a row.
    2. Declare the cursor, which contains a query.
    3. Open the cursor.
    4. Fetch the rows from the cursor one at a time and store the column values in the variables
    declared in Step 1. You would then do something with those variables, such as display
    them on the screen, use them in a calculation, and so on.
    5. Close the cursor.

    1.T-SQL用法三(游标和Fetch) http://www.cnblogs.com/McJeremy/archive/2008/09/26/1299818.html

    use pubs
    go
    --1,2 declare
    declare @auid char(12),@aulname varchar(20),@aufname varchar(20), @st char(2),@auinfo varchar(50)
    declare auth_cur cursor for select au_id, au_lname, au_fname, state from authors
    --3.open open auth_cur
    --4.fetch fetch next from auth_cur into @auid,@aulname,@aufname, @st while (@@fetch_status=0) begin print '作者编号: '+@auid print '作者姓名: '+@aulname+','+@aufname print '所在州: '+@st print '--------------------------' fetch next from auth_cur into @auid,@aulname,@aufname, @st end --5,6.close, deallocate close auth_cur deallocate auth_cur

      

  • 相关阅读:
    Omi框架学习之旅
    Omi框架学习之旅
    Omi框架学习之旅
    加密解密
    RSA加密解密
    CMDB后台管理(AutoServer)
    CMDB Autoclient思路分析
    CMDB开发(需求分析)
    Django之model操作(续)
    Django之Model操作
  • 原文地址:https://www.cnblogs.com/mylinux/p/4992130.html
Copyright © 2011-2022 走看看