易截截图软件、单文件、免安装、纯绿色、仅160KB

PL/SQL学习笔记六


1.创建过程
create or replace procedure 过程名 as
   声明语句段;
begin
   执行语句段;
exception
   异常处理语句段;
end;
2. 带参数的过程
参数类型3种
in参数:读入参数,主程序向过程传递参数值
out参数:输出参数,过程向主程序传递参数值
in out参数:双向参数
定义带参数的过程示例:
Set  serveroutput on
create or replace procedure scott.tempprocedure(
   tempdeptno in scott.dept.deptno%type, --输入参数
   tempdname out scott.dept.dname%type, --输出参数
   temploc in out scott.dept.loc%type) as -- 双向参数
   loc1   scott.dept.loc%type;
   dname1 scott.dept.dname%type;
begin
   select loc  into loc1
   from  scott.dept
   where  deptno=tempdeptno;
   select dname  into dname1
   from  scott.dept
   where  deptno=tempdeptno;
   temploc:='地址:'||loc1;
   tempdname:='姓名'||dname1;
end;
使用带参数的过程示例:
set serveroutput on
declare 
   myno  scott.dept.deptno%type;
   mydname  scott.dept.dname%type;
   myloc  scott.dept.loc%type;
begin
   myno:=10;
   mydname:='';
   myloc:='';
   scott.tempprocedure(myno,mydname,myloc);
   dbms_output.put_line(myno);
   dbms_output.put_line(mydname);
   dbms_output.put_line(myloc);
end;


相关文档:

SQL语句的优化以及索引的应用范围

SQL优化的原则是:将一次操作需要读取的BLOCK数减到最低。
调整不良SQL通常可以从以下几点切入:
检查不良的SQL,考虑其写法是否还有可优化内容;
检查子查询考虑SQL子查询是否可以用简单连接的方式进行重新书写;
检查优化索引的使用;
考虑数据库的优化器;
查询的一般规则
Ø      ......

sql日期模糊查询 SQL时间转换格式

Select * from t_user_profile where convert ( varchar ( 21 ),regDate, 120 ) like ' 2008-05-07% ' 表名称:t_user_profile 日期字段名称:regDate
Select   *   from t_user_profile  where  convert(varchar(21),regDate,120) like '2008-05-07%'< ......

超级SQL——在SQL中累加

此为转贴,但是从连个帖子中收集而来
下面来一起看看论坛里的一个oracle方面的问题:
====================Question
=========================
  jmbdat         dayt           y           &n ......

PL/SQL学习笔记三


1.条件控制
1.1 if .. then .. end if
if 条件 then
    语句段;
end if;
1.2 if .. then .. else .. end if
if 条件 then
    语句段;
else 
    语句段;
end if;
1.3 if嵌套
2.循环控制
2.1 loop .. exit .. end loop
loop  
   & ......

PL/SQL学习笔记四


事务是Oracle9i中进行数据库操作的基本单位,在PL/SQL程序中,可以使用3个事务处理控制命令。
1. commit命令
commit是事务提交命令。Oracle9i数据库中,为保证数据一致性,在内存中为每个客户机建立工作区,客户机对数据库进行操作的事务都在工作区完成,只有执行commit命令后,工作区内的修改内容才写入到数据库上,称 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号