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

      

  • 相关阅读:
    [php]php时间戳当中关于时区的问题
    [jQuery] jQuery如何获取同一个类标签的所有的值
    sed 命令基础
    Docker 学习第6课
    Docker 学习第五课
    Docker 学习第四课
    Docker 学习第三课
    Docker 学习第二课
    Docker学习第一课
    XdeBug的使用
  • 原文地址:https://www.cnblogs.com/mylinux/p/4992130.html
Copyright © 2011-2022 走看看