In Oracle,
We can declare an input-output parameters (not just input or output) like the following:
Create Or Replace Procedure USE
This is sample code for SQL Input & Output parameter.
CREATE PROCEDURE [dbo].[sample_Insert]
@name varchar(500),
@entryby int,
@RetVal INT = 0 OUT
AS
SET NOCOUNT ON
INSERT INTO dbo.Master
( name ,
entry_date ,
entry_by
)
VALUES ( @name , -- service_name - varchar(1000)
dbo.GetActDate() , -- entry_date - datetime
@entryby -- entry_by - int
)
IF @@ERROR = 0
BEGIN
SET @RetVal = 1 -- 1 IS FOR SUCCESSFULLY EXECUTED
End
ELSE
BEGIN
SET @RetVal = 0 -- 0 WHEN AN ERROR HAS OCCURED
End
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
If you declare a parameter as OUTPUT, it acts as Both Input and OUTPUT
CREATE PROCEDURE SimpleInOutProcedure
(
@p_InputInt INT,
@p_OutputInt INT OUTPUT
)
AS
BEGIN
SELECT
@p_OutputInt = @p_OutputInt
END
GO
DECLARE @p_OutputInt int = 4
EXEC SimpleInOutProcedure @p_InputInt = 1, @p_OutputInt = @p_OutputInt OUTPUT
SELECT @p_OutputInt