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

      

  • 相关阅读:
    Springboot + Mybatis 多数据源配置
    构建微服务:Spring boot 入门篇
    IDEA SpringBoot代码修改热部署/加载
    vue-cli知识点
    vuex知识点
    正则基本知识
    多行SQL语句拼成一条数据
    软件的版本控制
    ASP.NET 表单验证实现浅析
    建造者模式
  • 原文地址:https://www.cnblogs.com/mylinux/p/4992130.html
Copyright © 2011-2022 走看看