MySQL
Skapa proceduren:
DELIMITER $$
DROP PROCEDURE IF EXISTS PCount $$
CREATE PROCEDURE PCount (IN a_param1 INT, INOUT a_param2 INT, OUT a_param3 INT)
BEGIN
SET a_param2 = a_param2 + a_param2;
SET a_param3 = a_param1 + a_param2;
END $$
DELIMITER ;
Använd den:
SET @p2 = 1;
CALL PCount(1, @p2, @p3);
SELECT @p2, @p3;
CALL PCount(1, @p2, @p3);
SELECT @p2, @p3;
Exempel:
MS SQL Server
Skapa proceduren:
DROP PROCEDURE PCount;
GO
CREATE PROCEDURE PCount
@a_param1 INT,
@a_param2 INT OUT,
@a_param3 INT OUT
AS
BEGIN
SET @a_param2 = @a_param2 + @a_param2;
SET @a_param3 = @a_param1 + @a_param2;
END;
GO
Använd den:
DECLARE @p2 INT;
DECLARE @p3 INT;
SET @p2 = 1;
SET @p3 = 0;
EXEC PCount 1, @p2 OUT, @p3 OUT;
SELECT @p2, @p3;
Exempel:
Lycka till!
Inga kommentarer:
Skicka en kommentar