2015-07-21 64 views
1

我不得不从SQL Server移植到Oracle和我有这个SPSP可以在SQL Server中执行此操作吗?

ALTER procedure ST_004_264_01_14292 
    @n1 decimal(4,2), 
    @n2 decimal(4,2), 
    @resultado decimal(4,2) output 
    as 
    select @resultado=(@[email protected])/2; 


drop procedure ST_004_264_01_14292 

    declare @variable decimal(4,2) 
    execute ST_004_264_01_14292 5,6, @variable output 
    select @variable; 
+0

看起来更像是一个标量函数对我。 – mxix

+2

大概这个'drop'实际上并不是SP的一部分? –

+0

掉落在SP内部。我需要用PL/SQL重写它,但我不知道该怎么做。 – Nikodx

回答

3

假设我明白你的问题,那么答案是肯定的。 过程有可能自行退出。 (虽然我不明白为什么会有人想要做这样的事情)

测试的SQL Server 2012上:

create procedure stp_test 
    (
     @CountBefore int output, 
     @CountAfter int output 
    ) 
AS 
begin 
    select @CountBefore = count(*) 
    from sys.procedures 
    where name = 'stp_test' 

    drop procedure stp_test 

    select @CountAfter = count(*) 
    from sys.procedures 
    where name = 'stp_test' 
end 
GO 

declare @x int, 
     @y int 

exec stp_test @x output, @y output 

select @x as [count before], @y as [count after] 

结果:

count before count after 
------------ ----------- 
1   0 
相关问题