Oracle存储过程总结(一、基本应用)
1、创建存储过程
create or replace procedure test(var_name_1 in type,var_name_2 out type) as
--声明变量(变量名 变量类型)
begin
--存储过程的执行体
end test;
打印出输入的时间信息
E.g:
create or replace procedure test(workDate in Date) is
begin
dbms_output.putline('The input date is:'||to_date(workDate,'yyyy-mm-dd'));
end test;
2、变量赋值
变量名 := 值;
E.g:
create or replace procedure test(workDate in Date) is
x number(4,2);
begin
x := 1;
end test;
3、判断语句:
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;
4、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);
end;
end LOOP;
end test;
(2)循环遍历数组
create or replace procedure test(varArray in myPackage.TestArray) as
--(输入参数varArray 是自定义的数组类型,定义方式见标题6)
i number;
begin
i := 1; --存储过程数组是起始位置是从1开始的,与java、C、C++等语言不同。因为在Oracle中本是没有数组的概念的,数组其实就是一张
--表(Table),每个数组元素就是表中的一个记录,所以遍历数组时就相当于从表中的第一条记录开始遍历
for i in 1..varArray.count LOOP
dbms_output.putline('The No.'|| i || 'record in varArray is:'||varArray(i));
end LOOP;
end test;
5、While 循环
whi
相关文档:
在sql语句中涉及到时间类型时 若只想要日期 to_date('2007-7-8','yyyy-mm-dd')
在C#中有datetime类型,代码说明一切
DateTime dt = System.DateTime.Now;
string lsh;
lsh=string.Format("{0:yyyyMMddHHmmss}", dt);
DateTime dt = DateTime.Now;
Label1.Text = dt.To ......
What circumstances we use ALL_ROWS and what circumstances we use FIRST_ROWS optimizer mode? This article is written in oracle9i.
First_rows attempts to optimize the query to get the very first row back to the client as fast as possible. This is good for an interactive client server environment wher ......
转自:http://hi.baidu.com/dashuaiwang/blog/item/47cc680ec35055c37acbe1f8.html
打开oracle 数据库时出现了错误:
ORA-00313: 无法打开日志组 1 (线程 1) 的成员
ORA-00312: 联机日志 1 线程 1: 'D:\ORACLE\ORADATA\GOCOM\REDO01.LOG'
SQL> connect / as sysdba;
已连接。
SQL> shutdown immediate;
ORA- ......
Oracle 总帐模块的一个会计业务周期如下:
1.打开总帐会计期
2.录入手工凭证,包括:· 手工标准凭证
  ......
Oracle用户解锁
每当我们新安装了oracle后,第一次运行都会出现一个用户被锁的错误提示,此时需要我们手动进行用户解锁,下面以解锁scott用户为例: 首先在命令行窗口中输入 sqlplus sys/sys as sysdba 这里的sys是系统账号,oracle自带的,后面的sys是密码,这个密码在你安装时设置好的. as sysdba 意思就是以这个用户做为数 ......