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

PL/SQL例子2

create or replace procedure c
(
v_deptno  in emp.deptno%type,
v_max out emp.sal%type
)
as
begin
select max(sal+nvl(comm,0)) into v_max from emp where deptno=v_deptno;
end;
create or replace procedure cc
(
v_empno  in emp.empno%type,
v_sal out emp.sal%type,
v_comm out emp.comm%type,
v_tol out emp.sal%type
)
as
begin
select sal,nvl(comm,0),(sal+nvl(comm,0)) into v_sal,v_comm,v_tol from emp where
empno=v_empno;
end;
create or replace procedure upsal
(
v_deptno in number,
v_sal in number
)
as
begin
update emp set sal=v_sal where deptno=v_deptno;
end;
create or replace procedure somsal
(
v_empno in number,
v_sal in number
)
as
begin
update emp set sal=v_sal where empno=v_empno;
end;
create or replace function maxsal
(
v_deptno in number
)
return number
is
v_maxsal number;
begin
select max(sal) into v_maxsal from emp where deptno=v_deptno;
return v_maxsal;
end;
create or replace procedure cursor
(v_cursor out mypack.mycursor
)
is
begin
open v_cursor for select * from emp ;
end ;
create or replace function selalldep
(a out number,
c in number
)
return number
as
b number;
begin
select count(empno),sum(sal+nvl(comm,0)) into a,b from emp
where deptno=c;
return b;
end;
create or replace package mypack is
type mycursor is ref cursor;
end ;
declare
i number(3):=1;
j number(3):=2;
begin
loop
insert into t_user values(i,'a'||i,'a'||i,1,to_date('2007-01-01','yyyy-mm-dd'),1,i,'sdd');
insert into t_user values(j,'a'||j,'a'||j,1,to_date('2007-01-01','yyyy-mm-dd'),2,j,'sdd');
i:=i+2;
j:=j+2;
exit when i>600 and j>600;
end loop;
end;


相关文档:

SQL核心语句

    sql核心语句(非常实用的几个技巧)插入数据
           向表中添加一个新记录,你要使用 sql INSERT 语句。这里有一个如何使用这种语句的例子:
           INSERT mytable (mycolumn ......

SQL Server 数据库

a.数据库基础
      i.概念:表及相关操作对象的集合(主数据文件mdf,二级数据文件ndf,日志ldf)
      ii.组成:系统: master(记录了所有的服务器系统信息)
,model(记录了所有临时记录,链接断开时,数据丢失)
Tempdb(数据模板库,含创建库时的缺省数据)
, ......

PL/SQL中Ref Cursor的应用

PL/SQL作为oracle对于传统SQL语法的扩展,在跨系统事务处理以及对数据库大批量数据处理方面作用显著;而当前主流的MVC框架对DAO层的封装都是一条SQL语句返回一个记录集;当数据的关系比较复杂或数据量比较大的时候,与数据库的交互过于频繁将增大内网的数据传输量与数据库的IO.针对此类复杂的数据处理,可以采用PL/SQL程序包来实 ......

精妙SQL语句整理

一、基础
1、说明:创建数据库
CREATE DATABASE database-name
2、说明:删除数据库
drop database dbname
3、说明:备份sql server
--- 创建 备份数据的 device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:mssql7backupMyNwind_1.dat'
--- 开始 备份
BACKUP DATABASE pubs TO testBack ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号