oracle存储过程用法
存储过程在服务器端早已编辑执行过的代码。用户要做的只是调用和接收存储过返回的结果。所以调用存储过程比普通的用查询语句返回值要快得多,存储过程的执行速度更快,存 储过程是保存起来的可以接受和返回用户提供的参数的 Transact-SQL 语句的集合。可以创建一个过程供永久使用,或在一个会话中临时使用(局部临时过程),或在所有会话中临时使用(全局临时过程)。
oracle 存储过程的基本语法 及注意事项
1.基本结构
CREATE OR REPLACE PROCEDURE 存储过程名字
(
参数1 IN NUMBER,
参数2 IN NUMBER
) IS
变量1 INTEGER :=0;
变量2 DATE;
BEGIN
END 存储过程名字
1、is和as没有区别;
2、参数是从存储过程外面传入的值;而变量是在存储过程里面定义的。
2.SELECT INTO STATEMENT
将select查询的结果存入到变量中,可以同时将多个列存储多个变量中,必须有一条
记录,否则抛出异常(如果没有记录抛出NO_DATA_FOUND)
例子:
BEGIN
SELECT col1,col2 into 变量1,变量2 from typestruct where xxx;
EXCEPTION
WHEN NO_DATA_FOUND THEN
xxxx;
END;
...
3、变量赋值
变量名 := 值;
E.g:
create or replace procedure test(workDate in Date) is
x number(4,2);
begin
x := 1;
end test;
4、判断语句:
if 比较式 then begin end; end if;
E.g
create or replace procedure test(x in number) is
begin
if x >0 then
begin
x := 0 - x;
end;
end if;
if x = 0 then
begin
x: = 1;
end;
end if;
end test;
5、For 循环
For ... in ... LOOP
--执行语句
end LOOP;
(1)循环遍历游标
create or replace procedure test() as
Cursor cursor is select name from student; name varchar(20);
begin
for name in cursor LOOP
begin
dbms_output.putline(name)
相关文档:
1 . set database to archivelog mode
Sql代码
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE&n ......
安装oracle 11g以后 无法启动dbconsole 。通过两天的努力终于解决了
1 发现日志报 端口5520已经被占用,无法使用,打开 /%ORACLE_HOME%/oc4j/je22/OC4J_DBConsole_localhost_orcl/config/rmi.xml
发现 port="5520" ssl-port="5520" 端口号使用相同,于是修改 port="5521" ssl-port=" ......
oracle and sqlsever 常用数学函数对比
数学函数
1.绝对值
S:select abs(-1) value
O:select abs(-1) value from dual
2.取整(大)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.取整(小)
S:select floor(-1.001) value ......
每个Oracle用户都有一个名字和口令,并拥有一些由其创建的表、视图和其他资源。Oracle角色(role)就是一组权限(privilege)(或者是每个用户根据其状态和条件所需的访问类型)。用户可以给角色授予或赋予指定的权限,然后将角色赋给相应的用户。一个用户也可以直接给其他用户授权。
数据库系统权限(Database System Privil ......
应个报表要求做个
时间 双色球, 胜负彩。。。。。
200905 销量 销量
200906 销量 销量
200907 &n ......