表如下: 如下存储过程使用游标遍历所有数据: 运行截图如下: 如果需要添加一个返回的结果集添加如下即可: Select ‘ok’; 运行截图如下: 使用for循环进行遍历,运行截图如下 源码如下: 一般获取单条数据可以这样做: 运行截图如下: 源码如下: 这里还可以增加if等功能 源码如下:
CREATE OR REPLACE PROCEDURE "CFFTEST"."SELECT_STUDENT"("id" IN INT) AS myId int; myName varchar(50); cursor myCursor is select id, name from cfftest.student; BEGIN open myCursor; loop fetch myCursor into myId, myName; exit when myCursor%notfound; print 'id: ' || myId || ' name' || myName; end loop; close myCursor; END;
CREATE OR REPLACE PROCEDURE "CFFTEST"."SELECT_STUDENT"("id" IN INT) AS myId int; myName varchar(50); cursor myCursor is select id, name from cfftest.student; BEGIN open myCursor; loop fetch myCursor into myId, myName; exit when myCursor%notfound; print 'id: ' || myId || ' name' || myName; end loop; close myCursor; select 'ok'; END;
CREATE OR REPLACE PROCEDURE "CFFTEST"."SELECT_STUDENT"("id" IN INT) AS BEGIN for recordOne in (select id, name from cfftest.student) loop print recordOne.id || ' ' || recordOne.name; end loop; select 'ok'; END;
CREATE OR REPLACE PROCEDURE "CFFTEST"."SELECT_STUDENT"("id" IN INT) AS myname varchar(50); BEGIN select name into myname from cfftest.student where id="id"; print 'name is ' || myname; END;
CREATE OR REPLACE PROCEDURE "CFFTEST"."SELECT_STUDENT"("id" IN INT) AS myCount int; BEGIN select count(*) into myCount from cfftest.student where id="id"; if myCount > 0 then select '存在数据'; else select '不存中数据'; end if; END;
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算