oracle存储过程中的select语句是怎样的
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;。
oracle select语句
1、from 后面可以接表
2、from 后面可以接视图
3、from 后面可以接子查询
你的理解是只能接表,你可以这么理解,from后面接的是数据集,表名也好子查询也好都是数据集。
-----
=>; 的作用是 给前面的参数赋值的意思。
比如:proc_test 过程中有三个参数
参数1,
参数2, --这个参数有默认值 1000
参数3
此时如果你想保留参数2的默认值既可以 proc_test(参数1=>20,参数3=>40)
这个时候相当于
proc_test(20,1000,40);
---
以上,希望对你有所帮助。
oracle 怎样将select 语句的查询结果作为另一个select 语句where 后面
你这样太复杂了。
无非就是下面几种:1. existswhere exists (select 1 from abc where xxx)2. inwhere xxx in (select xxx from abc where 。)3. = (只能返回一行)where xxx = (select xxx from abc where 。
)当然,子查询中是可以使用外部的表。比如select * from a where exists (select 1 from b where a.id = b.id)。
oracle的sql的select语句中有limit吗
limit是mysql里的,select * from a order by b limit 6,1,取得按b排序的第6行a的值
而在oracle中想要实现是通过rownum:
select * from a where rownumROWNUM是一个序列,是oracle数据库从数据文件或缓冲区中读取数据的顺序。它取得第一条记录则rownum值为1,第二条为2,依次类推。ROWNUM是一个序列,是oracle数据库从数据文件或缓冲区中读取数据的顺序。它取得第一条记录则rownum值为1,第二条为2,依次类推。