这是标题所要求的,如果您需要查看代码,请告诉我。
ALTER FUNCTION dbo.Intrest
(@loan MONEY, @interest MONEY)
RETURNS INT
AS
BEGIN
DECLARE @returnValue INT
SET @returnValue = (@loan) * (@interest)
INSERT INTO Loan (Loan_amount, Interest_rate)
VALUES (@loan, @interest)
RETURN @returnValue
END
GO
ALTER PROCEDURE Getoutput
(@loanamount MONEY, @interestrate MONEY)
AS
BEGIN
DECLARE @loansID INT
SELECT @loansID = Loan_id
FROM Loan
WHERE Loan_amount = @loanamount
SELECT dbo.Intrest (@loanamount, @interestrate)
INSERT INTO Loan (Outputs, Loan_amount, Interest_rate)
VALUES (@loansID, @loanamount, @interestrate)
RETURN @@identity
END
答案 0 :(得分:0)
函数无法在表上执行任何DML操作。我已删除generated.schema
声明
INSERT
变量不是必需的。您的ALTER FUNCTION dbo.Intrest
(@loan MONEY, @interest MONEY)
RETURNS INT
AS
BEGIN
DECLARE @returnValue INT
SET @returnValue = (@loan) * (@interest)
RETURN @returnValue
END
GO
可以简化为
Stored Procedure