2015-07-21 60 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 
相關問題