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;
相关文档:
1、Session有什么重大BUG,微软提出了什么方法加以解决?
答:是iis中由于有进程回收机制,系统繁忙的话Session会丢失,可以用Sate server或SQL Server数据
库的方式存储Session不过这种方式比较慢,而且无法捕获Session的END事件。
2.产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复。
C# ......
SQL自动异地备份方法
方法一:
mssql数据库远程备份的job
/*在远程机器操作系统的计算机管理里建立一个用户名为kyle的用户,密码为1234,同时在那台机器的非系统盘里建一个名为backup的共享文件夹,为了安全另外设置这个文件夹只有这个kyle用户可以访问。*/
declare @sql varchar(500)
select @sql='\\10.2. ......
在数据库查询数据时,我们经常使用一些函数,使我们的查询更加方便快捷,下面就把SQL Server中我们常用的几个函数给列举出来,供参考。
1.字符串函数用户控制返回给用户的字符串,这些功能仅用于字符型数据。
2.日期函数用于操作日期值,我们不能直接对日期运用数学函数。
3.数学函数用于对数值进行代数运算。
4.系统函 ......
ALTER procedure [dbo].[sp_lock_check]
@spid1 int = NULL,
@spid2 int = NULL
as
set nocount on
if @spid1 is not NULL
begin
select ......
sql server 时间段查询。
==========================================
select g.borrowTime from t_apartment_goodsborrow g
where g.borrowTime >= '2010-03-11 9:50:43'
2010-03-11 9:52:54
----------------------------------------------------------------------------
select g.borrowTime ......