T-SQL

Rollback ve Commit tanımlarından bahsederek başlayayım.
Para transferi gibi iki kişinin birbiri ile bağlantılı olduğu işlemlerde birinci işlem tamamlanmadan ikinci işlem yapılamaz (birbiriyle bağlantılı), birinci işlem tamamlandıktan sonra ikinci işlemin gerçekleşmemesi durumunda birinci işlemin geçersiz olması gereği ile işlemi geri çekmeye Rollback, işlemin başarılı şekilde sonuçlanmasına ise Commit denir.

SQL manager ile basit bir örnek tablo oluşturup query ile işlemleri çalıştırabilirsiniz.

bu işlemleri Rollback ya da Commit ile sonunçlandırmamanız durumunda veritabanının kilit halinde duracağını da belirteyim. Örneğin alttaki kodun sadece ilk 4 satırını çalıştırırsanız ve başka bir sorgu sayfasından aynı tabloyu kullanacak başka bir sorgu çalıştırırsanız sonuç alamazsınız bu transaction’un bitmesini bekler.

begin transaction
save transaction dene               --checkpoint oluşturdum
update dbo.Person set name='Gurhan' --değişikliğimi yaptım
select * from Person				--(1) sorgu ile değişikliğimi önizledim. (Gerçek tabloya aktarmaz)
rollback transaction dene           --2. satırdaki checkpoint'e geri yükledim
select * from Person				--(2) görmek için çağırdım
update Person set surname = 'Çelik' --başka bir değişiklik yaptım
select * from Person				--(3) önizle
rollback                            --tümünü iptal ederek sonlandırdım
select * from Person				--(4)

sonuçlar aşağıdaki gibi olacaktır. Normal kullanımının if statement içinde olduğunu çıkarabilirsiniz.

T-SQL ‘i normal SQL sorgularından farklı kılan, içinde genel programlama dili gibi koşullar, karşılaştırmalar, matematiksel işlemler, değişkenler gibi özellikler bulundurmasıdır. Veri tabanında T-SQL ile çalışmayı Stored Procedure‘de kullanabilirsiniz.

String fonksiyonları: http://www.buyukculhaci.com/sql-string-fonksiyonlari/

Matematik fonksiyonlarına örnek: http://www.buyukculhaci.com/sql-matematik-fonksiyonlari/

Tarih fonksiyonları: http://www.buyukculhaci.com/sql-tarih-fonksiyonlari/

İleri seviye fonksiyonlar: http://www.buyukculhaci.com/sql-ileri-seviye-fonksiyonlar/

Ayrıca sunucu içinde tanımlı olan bazı bilgilendirme sunucu değişkenlerinden de yararlanabilirsiniz.

Yazı oluşturuldu 40

T-SQL” üzerine 5 görüş

  1. I simply wanted to thank you very much again. I do not know the things I could possibly have handled in the absence of these pointers contributed by you directly on my industry. Certainly was a horrifying dilemma in my circumstances, however , noticing this well-written mode you solved it took me to jump with joy. I am thankful for this service and even pray you realize what an amazing job you happen to be providing educating the rest through a web site. I am certain you’ve never met any of us.

  2. I wanted to compose a remark to be able to say thanks to you for some of the remarkable advice you are sharing on this website. My time intensive internet lookup has finally been paid with really good facts to talk about with my co-workers. I ‘d repeat that most of us readers actually are undoubtedly blessed to exist in a fantastic place with many special individuals with good tips and hints. I feel pretty happy to have come across the web site and look forward to some more fabulous moments reading here. Thanks a lot again for all the details.

  3. Needed to draft you the tiny word just to thank you very much again considering the gorgeous advice you’ve contributed on this website. It is quite wonderfully generous with you to grant publicly just what many individuals might have made available as an ebook to help make some bucks for their own end, and in particular seeing that you could possibly have tried it in case you desired. The tips also acted to be the fantastic way to fully grasp that many people have the identical dream just like mine to find out more and more when considering this issue. Certainly there are several more pleasurable occasions up front for folks who take a look at your blog post.

  4. I’m just commenting to let you be aware of what a magnificent discovery my friend’s princess obtained viewing your webblog. She noticed too many things, with the inclusion of what it is like to possess an excellent teaching nature to make many others without problems learn some very confusing subject areas. You actually surpassed my expectations. Thanks for imparting such good, healthy, revealing and even fun tips on that topic to Jane.

  5. Thanks a lot for providing individuals with a very superb possiblity to read in detail from here. It’s always very sweet plus jam-packed with amusement for me personally and my office co-workers to visit your blog the equivalent of three times in 7 days to study the new stuff you have got. Of course, I’m also usually contented concerning the mind-blowing principles you serve. Some 3 areas in this article are absolutely the simplest we’ve had.

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Benzer yazılar

Aramak istediğinizi üstte yazmaya başlayın ve aramak için enter tuşuna basın. İptal için ESC tuşuna basın.

Üste dön