Transactions In Stored Procedure

  • Hi Friends,

    I've three tables viz : Classes, Students, Logs.

    Classes - Store records of one single class, no. of students present/absent etc.

    Students - Store records of multiple students with ClassId of above table.

    Logs - Store records of edited students field.

    The Stored procedure itself is understable.

    I want to add Transaction to the following procedure.

    ie add SavePoint, Begin transaction, RollBack Transaction, Trap Error, Goto statement etc.

    As I'm lil bit new to add transactions. So, I need some suggestions regarding from where to start

    transaction, rollback and commit transaction.

    CREATE PROCEDURE ClassLogs

    (

    .

    .

    .

    )

    Select @ClassCount = "Select Count(*) From Classes Table....."

    IF (@ClassCount = 0)

    EXEC @sQry = Classes_Insert "Insert into Classes Table..."

    EXEC @sQry = Students_Insert "Insert 1 Record into Students Table..."

    ELSE IF (@ClassCount > 0)

    SELECT @ClassId= "Select ClassId From Classes Table..."

    SELECT @StudentCount = "Select Count(*) From Students Table..."

    IF (@StudentCount = 0)

    EXEC @sQry = Students_Insert "Insert Remaining Records into Students Table..."

    ELSE IF (@StudentCount > 0)

    SELECT @StudentsId = "...."

    SELECT @status = "...."

    EXEC @sQry = Logs_Insert

    EXEC @sQry = Students_Update

    EXEC @sQry = Classes_Update

    Thanks In Adv.

  • duplicate post. no replies please.

    Discussion already started here



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply