15,904,023 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Nikola Milovanovic (Top 3 by date)
Nikola Milovanovic
13-Dec-21 14:50pm
View
You helped me a lot! When I deleted Update_StavkaKataloga_GodinaKatalog trigger, all 3 solutions are working. Thank you very much
Nikola Milovanovic
13-Dec-21 13:13pm
View
Sorry for my late response:
create trigger [dbo].[Update_StavkaKataloga_GodinaKataloga]
on [dbo].[StavkaKataloga]
AFTER UPDATE
as
declare @GodinaKataloga int
select @GodinaKataloga=GodinaKataloga from inserted
if @GodinaKataloga not like (select GodinaKataloga from deleted)
begin
raiserror('Zabranjeno je direktno azuriranje GodineKataloga u StavciKataloga!', 16,1)
rollback
end
i dont want to allow the user to manualy update value in GodinaKataloga, and raise an error - Forbiden...
Nikola Milovanovic
13-Dec-21 11:28am
View
@Wendelius thanks for your reply! I tried your code and it worked, but before I saw yours I tried this one
create trigger Update_Katalog_Naziv
on Katalog
after update
as
if update (Godina)
begin
update StavkaKataloga
set GodinaKataloga=(select top 1 Godina from inserted)
from dbo.StavkaKataloga s
INNER JOIN INSERTED i ON s.IDKataloga = i.IDKataloga join Katalog k on s.IDKataloga = k.IDKataloga
where k.IDKataloga = s.IDKataloga
end
I am very thankful for your solution! The only thing that matters now is that all 3 options only work with lines disable trigger and enable trigger. I still cant find a way to make any of my solutions work without those lines. Are those lines mandatory with SQL server?