TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anil Sharma
NA
29
14.9k
Msg 443, Level 16, State 15, Invalid use of a side-effecting
Feb 22 2020 1:52 AM
hi
i m try write a function in sql server there is a error but not under stand. error is
Msg 443, Level 16, State 15, Procedure get_advice_no, Line 21
Invalid use of a side-effecting operator 'UPDATE' within a function.
Msg 443, Level 16, State 15, Procedure get_advice_no, Line 34
Invalid use of a side-effecting operator 'INSERT' within a function.
my function code is
ALTER
FUNCTION
[dbo].[get_advice_no](@vcounter_type nvarchar(5) )
RETURNS
int
AS
BEGIN
-- Declare the return variable here
DECLARE
@vadvice_no
int
;
-- Add the T-SQL statements to compute the return value here
select
@vadvice_no = (
SELECT
(
isnull
(CONSTANT_NO,0) + 1)
FROM
CA_CONSTANT
WHERE
CONSTANT_TYPE = @vcounter_type);
if @vadvice_no > 0
begin
---if exits(SELECT CONSTANT_NO FROM CA_CONSTANT WHERE CONSTANT_TYPE = @vcounter_type)
--begin
update
ca_constant
set
constant_no = @vadvice_no
where
CONSTANT_TYPE = @vcounter_type;
-- end
end
else
begin
set
@vadvice_no = 1;
IF (@vcounter_type =
'ADV_2'
)
begin
set
@vadvice_no = 75001;
end
INSERT
INTO
CA_CONSTANT(CONSTANT_TYPE,CONSTANT_NO)
VALUES
(@vcounter_type,@vadvice_no);
end
RETURN
(@vadvice_no);
-- Return the result of the function
END
pls tell me what is wrong
Reply
Answers (
2
)
need help in update query.
Upload multiple Images but store in Database only one!