SP可以在SQL Server中执行此操作吗?

时间:2015-07-21 14:09:30

标签: sql-server oracle stored-procedures

我必须从SQL Server迁移到Oracle,我有这个SP

ALTER procedure ST_004_264_01_14292
  @n1 decimal(4,2),
  @n2 decimal(4,2),
  @resultado decimal(4,2) output
  as 
   select @resultado=(@n1+@n2)/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;

1 个答案:

答案 0 :(得分: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