爱问知识人 爱问教育 医院库

oracle存储过程中的select语句是怎样的?

首页

oracle存储过程中的select语句是怎样的?

oracle存储过程中的select语句是怎样的?

提交回答

全部答案

    2017-07-27 18:05:42
  •   create or replace procedure pro_test
    is
    begin
    select * from t_test;
    end pro_test;
    这个存储过程正确吗?
    昨天因为这个,耽误了好久(在一个存储过程中用了select语句,但既没有用游标也没有用into)。
       在存储过程(oracle数据库)中如果用了select语句,要么使用"select into 变量"语句要么使用游标,oracle不支持单独的select语句(如表述有误请指出)。 select into 比较简单,但是如果返回的是一个结果集就无法满足要求了。
       游标分Cursor型游标和SYS_REFCURSOR型游标两种 Cursor型游标--不能用于参数传递 create or replace procedure pro_test() is cusor_1 Cursor is select 字段名 from 表名 where 条件; (或者 select class_name into cursor_2 from class where 。
      。。; cursor的另一种用法,需要写在begin和end之间) begin select class_name into cursor_2 from class where 。。。; 可以使用 for xxx in cursor loop 。
      。。。 end loop; --对Cursor进行遍历 end pro_test; SYS_REFCURSOR型游标 create or replace procedure pro_test(rsCursor out SYS_REFCURSOR) is cursor SYS_REFCURSOR; name varhcar(20); begin open cursor for select name from student where 。
      。。; --使用open来打开进行赋值 --遍历 loop fetch cursor into name --fetch into来打开遍历的每条数据 exit when cursor%NOTFOUND; --未找到记录信息 dbms_output。
      putline(xxxx); end loop; rsCursor := cursor; end pro_test;。

    以***

    2017-07-27 18:05:42

类似问题

换一换
  • 系统软件 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):