insert into EMP (SAL,salname,salary) values(1,'张三',2800);
insert into EMP (SAL,salname,salary) values(2,'李四',1900);
insert into EMP (SAL,salname,salary) values(3,'王五',5400);
insert into EMP (SAL,salname,salary) values(4,'ABC',3400);
CREATE OR REPLACE PROCEDURE gettest(eNo NUMBER) AUTHID CURRENT_USER --参数的数据类型不能指定长度
AS
salary emp.sal%TYPE;
BEGIN
SELECT salary INTO salary FROM EMP WHERE SAL=eNo;
DBMS_OUTPUT.PUT_LINE(eNo||'号员工的工资为'||salary);
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('没有找到该编号的员工');
END;
--当过程中含有输出参数时,调用时必须通过BEGIN END块,不能通过EXEC或CALL调用。如:
BEGIN
scott.gettest(3);
END;
--开启xp_cmdshell
--SQL Server blocked access to procedure 'xp_cmdshell'
sp_configure 'show advanced options', 1
go
reconfigure
go
sp_configure 'xp_cmdshell', 1
go
reconfigure
go
--开启sp_OACreate
--SQL Server blocked access to procedure 'sys.sp_OACreate'
sp_configure 'show advanced options', 1;
go
reconfigure;
go
sp_configure 'ole automation procedures', 1;
go
reconfigure;
go
sp_configure 'Ad Hoc Distributed Queries',1;
go
reconfigure
go
创建读取HIS数据并写入的临时表
if OBJECT_ID('tempdb.dbo.#temp') is not null
drop table #temp
create table #temp (no varchar(50))
--把HIS取得的摆药数据插入到临时表中
set xact_abort ON
declare @ssqlA varchar(3000)
set @ssqlA='exec (''
DECLARE
salarytwo varchar2(50);salnametwo varchar2(50);
BEGIN
gettesttwo(1,salarytwo,salnametwo);
DBMS_OUTPUT.PUT_LINE(salarytwo);
DBMS_OUTPUT.PUT_LINE(salnametwo);
END;'') AT testtwo;'