Oracle利用游标返回结果集的的例子(C#)...(最爱)
create or replace package types as
type
cursorType is ref cursor;
end;
create or replace function testpro return
types.cursorType is
lc types.cursorType;
begin
open lc for select *
from test;
return lc;
end testpro;
OracleConnection("YourConnectString");
conn);
OracleType.Cursor);
ParameterDirection.ReturnValue;
OracleDataAdapter(cmd);
ds.Tables["test"];
CREATE OR REPLACE PACKAGE types_mei1
AS
TYPE myrctype1 IS REF CURSOR;
PROCEDURE get (p_id NUMBER, p_rc OUT myrctype1);
END types_mei1 ;
2、创建函数(或者存储过程)
create or replace function testpro_mei1(IV IN NUMBER) return types_mei1.myrctype1 is
lc types_mei1.myrctype1;
begin
open lc for select * from classes where ID=IV;
return lc;
end testpro_mei1;
=====================================下面是对通过单个ID查询的数据
create or replace package types_mei as
type cursorType is ref cursor;
end;
=============================================
CREATE OR REPLACE PACKAGE types_mei
AS
TYPE myrctype IS REF CURSOR;
PROCEDURE get (p_id NUMBER, p_rc OUT myrctype);
END types_mei ;
create or replace function testpro_mei(IV IN NUMBER) return types_mei.myrctype is
lc types_mei.myrctype;
begin
open lc for select * from test where ID=IV;
return lc;
end testpro;
=================================================
CREATE OR REPLACE PACKAGE types_mei1
AS
TYPE myrctype1 IS REF CURSOR;
PROCEDURE get (p_id NUMBER, p_rc OUT myrctype1);
END types_mei1 ;
create or replace function testpro_mei1(IV IN NUMBER) return types_mei1.myrctype1 is
lc types_mei1.myrctype1;
begin
open lc for select * from classes where ID=IV;
return lc;
end testpro_mei1;
===================================================
===================================
存储过程:
插入数据:
CREATE OR REPLACE Procedure p_insert_t_cls --存储过程名称
(
p_stuid in CLASSES.ID%type,
p_stuname in varchar
)
as
BEGIN
insert into classes
values
(p_stuid,p_stuname);
commit;
end;
===============================================
删除 :(带返回参数)
create or replace procedure proc_delete
(
isid in number , P_ROWS OUT NUMBER
)
is
begin
delete classes where id=isid;
If SQL%Found Then
DBMS_OUTPUT.PUT_LINE('删除成功!');
P_ROWS := 1;
Else
DBMS_OUTPUT.PUT_LINE('删除失败!');
P_ROWS := 0;
End If;
commit;
end
;
删除 : (不带返回参数)
create or replace procedure p_delete_t_cls1(
cla_id in Number
)
is
begin
DELETE FROM classes WHERE id = cla_id;
commit;
end p_delete_t_cls1;
删除 : (不带返回参数)指定ID删除
create or replace procedure p_delete_t_cls is
begin
DELETE FROM classes WHERE id = 7;
commit;
end p_delete_t_cls;
====================================================
修改数据:(不带返回参数)
create or replace procedure p_update_t_cls1(
p_stuid in Number,
p_stuname in Nvarchar2
)
is
begin
update classes x set x.classname = p_stuname where x.id = p_stuid;
commit;
end p_update_t_cls1;
修改数据: :(带返回参数)
create or replace procedure proc_update(
p_stuid in Number,
p_stuname in Nvarchar2,
P_ROW out number
)
is
begin
update classes set classname = p_stuname where id = p_stuid;
If SQL%Found Then
DBMS_OUTPUT.PUT_LINE('更新成功!');
P_ROW := 1;
Else
DBMS_OUTPUT.PUT_LINE('更新失败!');
P_ROW := 0;
End If;
commit;
end proc_update;
修改数据: : (不带返回参数)指定ID修改
create or replace procedure p_update_t_cls
is
begin
update classes x set x.classname = '44' where x.id = 3;
commit;
end p_update_t_cls;
====================================================
查询所有数据:(带返回参数 游标)
create or replace package types1 as
type cursorType1 is ref cursor;
end;
create or replace function testpro1 return types1.cursorType1 is
lc1 types1.cursorType1;
begin
open lc1 for select id,classname from classes;
return lc1;
end testpro1;
传递ID查询数据:(带返回参数 游标)传递ID查询数据
CREATE OR REPLACE PACKAGE pkg_test1
AS
TYPE myrctype IS REF CURSOR;
PROCEDURE get (p_id NUMBER, p_rc OUT myrctype);
END pkg_test1 ;
create or replace function testpro(IV IN NUMBER) return types.cursorType is
lc types.cursorType;
begin
open lc for select * from classes where ID=IV;
return lc;
end testpro;
====================================================
Oracle利用游标返回结果集的的例子(C#)...(最爱)的更多相关文章
- 利用游标返回结果集的的例子(Oracle 存储过程)JAVA调用方法和.NET调用方法
在sqlplus中建立如下的内容: 1.程序包 SQL> create or replace package types 2 as 3 type cursorType is re ...
- PB中用oracle的存储过程返回记录集做数据源来生成数据窗口,PB会找不到此存储过程及不能正常识别存储过程的参数问题(转)
(转)在PB中用oracle的存储过程返回记录集做数据源来生成数据窗口 首先oracle的存储过程写法与MSSQL不一样,差别比较大. 如果是返回数据集的存储过程则需要利用oracle的包来定义游标. ...
- Oracle中游标返回多条数据的情况
DECLARE -- 定义类型. TYPE test_type IS TABLE OF test_main%ROWTYPE; test_data test_type; -- 定义游标. CURSOR ...
- mybatis springmvc调用oracle存储过程,返回记录集
参考: http://bbs.csdn.net/topics/390866155 辅助参考: http://www.2cto.com/kf/201307/226848.html http://blog ...
- java调用oracle存储过程,返回结果集
package com.srie.db.pro; import java.sql.CallableStatement; import java.sql.Connection; import java. ...
- 怎样让Oracle的存储过程返回结果集
Oracle存储过程: CREATE OR REPLACE PROCEDURE getcity ( citycode IN VARCHAR2, ref_cursor OUT sys_refcursor ...
- oracle自定义函数返回结果集
首先要弄两个type,不知道什么鬼: 1. create or replace type obj_table as object ( id ), name ), ) ) 2. create or re ...
- oracle 存储过程 返回结果集
oracle 存储过程 返回结果集 CreationTime--2018年8月14日09点50分 Author:Marydon 1.情景展示 oracle存储过程如何返回结果集 2.解决方案 最简 ...
- Oracle 存储过程调用返回游标的另一个存储过程。
一个扩展存储过程调用另一个存储过程,示例: 被调用存储过程:最后会返回一个游标,游标返回一个值.调用这个存储过程的存储过程同样需要获取它. procedure SearchBill --根据到货单号查 ...
随机推荐
- Java核心技术卷1 第三章
1. Java区分大小写,下一段源代码中,关键字public称为访问修饰符,用于控制程序的其他部分对于这段代码的访问级别,关键字class表明Java程序中的全部内容都包含在类里面. 标准的类名命名规 ...
- error trying to exec 'cc1plus': execvp: 没有那个文件或目录
出现这个问题,有两种可能: 第一,你没有安装g++ 第二,你的gcc的版本和g++版本不相符合 安装gcc和g++及一些依赖包 sudo apt-get install build-essential ...
- PHP 数组使用之道
本文首发于 PHP 数组使用之道,转载请注明出处. 这个教程我将通过一些实用的实例和最佳实践的方式列举出 PHP 中常用的数组函数.每个 PHP 工程师都应该掌握它们的使用方法,以及如何通过组合使用来 ...
- Python接口测试中通过登录接口获取实时token
1.封装login_token 2.headers:对应登录请求头部信息 3.request_param:登录的参数数据 4.json.dumps:将一个Python数据结构转换为JSON 5.dic ...
- super在python中有什么用
所属网站分类: python高级 > 面向对象 作者:阿里妈妈 链接:http://www.pythonheidong.com/blog/article/74/ 来源:python黑洞网 有什么 ...
- Maximun product
Given a sequence of integers S = {S1, S2, ..., Sn}, you shoulddetermine what is the value of the max ...
- 我们参与投资36Kr股权众筹项目“易途8”的决策过程
背景 中文接机.中文送机.中文包车. 当地玩乐 最大的竞争对手:皇包车,15年9月A轮 其它对手:唐人接等,订单量无法和 皇包车.易途8比. 看好理由 1.旅游行业和境外自由行,是 ...
- //……关于promise
什么是promise? promise 翻译成中文的意思是 "承诺" ,一个承诺说出去了说明他是进行中的,承诺兑现了代表成功,没有兑现代表失败了. promise 对象的状态一旦发 ...
- c网购物车流程图
1. 流程图 2. 流程介绍 1) 客人浏览模式下(未登录状态)加入购物车 这个时候回校验一下商品的可售数量,以及状态等等,校验成功后会保存到cookie和memcache,数据操作校验以memcac ...
- Ubuntu中Hadoop环境搭建
Ubuntu中Hadoop环境搭建 JDK安装 方法一:通过命令行直接安装(不建议) 有两种java可以安装oracle-java8-installer以及openjdk (1)安装oracle-ja ...