Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I'm using sql server and I have to procedures as follows:

SQL
--InsertLog
CREATE PROCEDURE 
InsertLog(
	@menuName nvarchar(500),
	@buttonName nvarchar(500),
	@buttonText nvarchar(500),
	@buttonPath nvarchar(500),
	@buttonCaptionPath nvarchar(500),
	@clickDateTime DateTime,
	@UserID nvarchar(500)-- Gets 7 items
	)
AS
BEGIN
DECLARE @linage nvarchar(500)
SET @linage = 
EXEC GetLinage @menuName,@linage
INSERT INTO 
LogTable(
	GUID,
	FormName,
	Linage,
	ButtonPath,
	ButtonCaptionPath,
	ButtonName,
	ButtonText,
	ClickDateTime,
	UserID 
	)
VALUES(
	newid(),
	@menuName,
	@linage,
	@buttonPath,
	@buttonCaptionPath,
	@buttonName,
	@buttonText,
	@clickDateTime,
	@UserID 
	)-- Saves 8 Items
END
GO


SQL
--GetLinage 
CREATE PROCEDURE GetLinage (
    @formidentity nvarchar(200),
    @linage  nvarchar(200) OUTPUT
)
AS
SELECT @linage = Linage
FROM formslist
WHERE (formslist.formID = @formidentity)
GO


The value which the GetLinage SP must return (or returns) does not get assigned to the variable in the InsertLog.

I cannot find out why it doesn't work, though I'm searching and trying different ways to make it work.

What I have tried:

I'm working on it but yet I haven't found a good solution.
Posted
Updated 16-Aug-16 3:03am
v2

1 solution

Firstly, you're missing the OUTPUT modifier on the parameter when you call the procedure.

Secondly, you're then overwriting the variable with the return value of the stored procedure. Since your GetLinage procedure doesn't include any Return statements, the return value is 0.

Remove the SET @linage = part, and add the OUTPUT modifier:
SQL
DECLARE @linage nvarchar(500);
EXEC GetLinage @menuName, @linage = @linage OUTPUT;
 
Share this answer
 
Comments
m.r.m.40 17-Aug-16 0:36am    
Thanks,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900