adam4 Posted June 1, 2016 Share Posted June 1, 2016 Arkadaşlar şimdi benim bi tablom var. Tablo adı : yonetim tablado ad,konum,bolum ve maas kolonları var. Konumu "yönetici" olanların bolumlerini update etmemi engelleyecek ve bir hata mesajı verecek bir trigger yazmak istiyorum. Ama sadece bolumlerini engellecek. Maas kolonunda oynama yapabilmem gerekiyor. Bu konuda bana yardımcı olursanız çok sevinirim. şimdiden teşekkür ederim. Quote Link to comment Share on other sites More sharing options...
syntax_error Posted June 1, 2016 Share Posted June 1, 2016 alter trigger trg_yonetim on yonetim for update as if (update(bolum)) begin if (SELECT konum FROM INSERTED) ='yonetici' RAISERROR (N'yöneticinin konumunu değişiremezsiniz',16,1) end 2 Quote Link to comment Share on other sites More sharing options...
adam4 Posted June 1, 2016 Author Share Posted June 1, 2016 2 saat önce, syntax_error yazdı: alter trigger trg_yonetim on yonetim for update as if (update(bolum)) begin if (SELECT konum FROM INSERTED) ='yonetici' RAISERROR (N'yöneticinin konumunu değişiremezsiniz',16,1) end çok sağolun hocam teşekkür ederim. Birde gözünüzden kaçmış sanırım geri alması için rollback eklememiz gerekiyor. Quote Link to comment Share on other sites More sharing options...
adam4 Posted June 1, 2016 Author Share Posted June 1, 2016 Alıntı alter proc teslim (@ilce nvarchar(20)) as if @ilce != ilce begin print 'böyle kayıtlı ilce yok' end else begin SELECT ilce,nerede from kargo Where ilce = @ilce and nerede = 'TESLİM EDİLDİ' end Birde arkadaşlar böyle bir prosedür yazıyorum. benim if - else'te koşul koyarken mesela yazdıgım ilce orda yoksa bana mesaj vermesini istiyorum. koşul olarak eşit değil ifadesi bana mantıklı geliyo ama demekki sql'in dilinde mantıksız. Bu koşulu nasıl sağlamam gerekiyor. Bu arada tablo adı kargo. Kolonlar id , ilce , nerede Quote Link to comment Share on other sites More sharing options...
SimpsoN_Bart Posted June 1, 2016 Share Posted June 1, 2016 (edited) alter proc teslim (@ilce nvarchar(20)) as if ISNULL( ilce,0) begin print 'böyle kayıtlı ilce yok' end else begin SELECT ilce,nerede from kargo Where ilce = @ilce and nerede = 'TESLİM EDİLDİ' end Aslında ISNULL ile yapılabilir bu işler için onu kullanır ama into ya atıp ordan da sorgulayabilirsin iş yerinde oracle kullandığım için syntax hatalı olabilir. ALTER PROC TESLIM(@ILCE NVARCHAR(20)) SELECT COUNT(ilce) INTO ILCEVARMI FROM KARGO IF ILCEVARMI < 0 BEGIN PRINT 'BOYLE BIR KAYITLI ILCE YOK' END ELSE BEGIN SELECT ilce,nerede from kargo Where ilce = @ilce and nerede = 'TESLİM EDİLDİ' END Edited June 1, 2016 by SimpsoN_Bart 2 Quote Link to comment Share on other sites More sharing options...
adam4 Posted June 1, 2016 Author Share Posted June 1, 2016 Alıntı Msg 4145, Level 15, State 1, Procedure but, Line 4 An expression of non-boolean type specified in a context where a condition is expected, near 'begin'. Msg 156, Level 15, State 1, Procedure but, Line 7 Incorrect syntax near the keyword 'else'. Hocam bu hatayı aldım ISNULL ile. İf'e başka bir koşul koyunca @ilce=5 gibi çalışıyor kodlar. Sorun ne olabilir sizce? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.