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 --根据到货单号查 ...
随机推荐
- ubuntu14.04 Google Chrome can not be run as root
问题如下图:
- mysql查询排名
student_work表 student_info表 sql语句:按grade从高到低排名 结果:
- Java线程和多线程(一)——线程的基本概念
Java 线程是一个轻量级执行任务的处理单元.Java提供了Thread类来支持多线程,开发者在应用中可以创建多个线程来支持并发执行任务. 在应用中存在两种类型的线程,用户线程和守护线程.当我们启动应 ...
- 《 阿Q正传》-鲁迅 词语解释 | 经典语录
词语解释 “太上有立德,其次是立功,其次是立言,虽久不废,此之谓不朽”.-出自<左传>-左丘明(春秋末期) 解释:(1)最上等的是树立德行,其次是建功立业,再其次是创立学说,即使过了很久也 ...
- java生成6位随机数字
//生成6位随机数字 System.out.println((int)((Math.random()*9+1)*100000)); //生成5位随机数字 System.out.println((int ...
- 九度oj 题目1058:反序输出
题目1058:反序输出 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:9677 解决:3495 题目描述: 输入任意4个字符(如:abcd), 并按反序输出(如:dcba) 输入: 题目可 ...
- memcache 原理 & 监测 & 查看状态 & stats & 结构
Mencache内存存储方式:slab/LRU,采用预先申请固定大小的内存页(slab/page),然后再把内存分成多个块(chunk) 先放一张从网上找到的memcache内存结构图,觉得非常的赞:
- Swoole 入门学习(二)
Swoole 入门学习 swoole 之 定时器 循环触发:swoole_timer_tick (和js的setintval类似) 参数1:int $after_time_ms 指定时间[毫秒] ...
- Android定位(是否使用GPS进行定位)
TencentLocationRequest request = TencentLocationRequest.create(); request.setRequestLevel(TencentLoc ...
- Educational Codeforces Round 41 B、C、D
http://codeforces.com/contest/961 B题 可以将长度为k的连续区间转化成1 求最大和 解析 简单尺取 #include <stdio.h> #include ...