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;
如何在存储过程中调用其他的存储过程(这些都是带参数的)
一个带参数的存储过程。
sql> create or replace procedure helloworld1 (
2 p_user_name varchar2
3 ) as
4 begin
5 dbms_output.put_line('hello ' || p_user_name || '!');
6 end helloworld1;
7 /procedure created.
sql> create or replace procedure callhelloworld1 (
2 p_user varchar2
3 ) as
4 begin
5 -- 调用存储过程的 存储过程
6 helloworld1(p_user);
7 end callhelloworld1;
8 /procedure created.
执行
sql> set serveroutput on
sql> exec callhelloworld1( 'tom' );
hello tom!pl/sql procedure successfully completed.

oracle asm指的是“自动存储管理”,是一种卷管理器,可自动管理磁盘组并提供有效的数据冗余功能;它是做为单独的Oracle实例实施和部署。asm的优势:1、配置简单、可最大化推动数据库合并的存储资源利用;2、支持BIGFILE文件等。

方法:1、利用“select*from user_indexes where table_name=表名”语句查询表中索引;2、利用“select*from all_indexes where table_name=表名”语句查询所有索引。

在Oracle中,可利用lsnrctl命令查询端口号,该命令是Oracle的监听命令;在启动、关闭或重启oracle监听器之前可使用该命令检查oracle监听器的状态,语法为“lsnrctl status”,结果PORT后的内容就是端口号。

在oracle中,可以利用“TO_SINGLE_BYTE(String)”将全角转换为半角;“TO_SINGLE_BYTE”函数可以将参数中所有多字节字符都替换为等价的单字节字符,只有当数据库字符集同时包含多字节和单字节字符的时候有效。

在oracle中,可以利用“drop sequence sequence名”来删除sequence;sequence是自动增加数字序列的意思,也就是序列号,序列号自动增加不能重置,因此需要利用drop sequence语句来删除序列。

在oracle中,可以利用“select ... From all_tab_columns where table_name=upper('表名') AND owner=upper('数据库登录用户名');”语句查询数据库表的数据类型。

方法:1、利用“LOWER(字段值)”将字段转为小写,或者利用“UPPER(字段值)”将字段转为大写;2、利用“REGEXP_LIKE(字符串,正则表达式,'i')”,当参数设置为“i”时,说明进行匹配不区分大小写。

方法:1、利用“alter system set sessions=修改后的数值 scope=spfile”语句修改session参数;2、修改参数之后利用“shutdown immediate – startup”语句重启服务器即可生效。


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

드림위버 CS6
시각적 웹 개발 도구
