How to increment by 1 after every update from front end

  • Hi All im going to try and word this as well as i can so please bare with me,

    Im in a process of creating a rask loggin system where i work and iv run in to a issue at the moment its hard coded so its working but this isnt the correct way to do it.

    I have a table called "Lifecycles" which holds a value of 1 to 10 so it looks something like this

    Status Description

    1 Raised

    2 Authorised

    3 IT Department

    4 BA Evaluation

    5 Development

    6 Developer

    7 BA to Test

    8 Release to Live

    etc

    I have another tables called "Work" this holds all the information from a task that has been raised i.e Task number, Raiser, Raised Date, Team etc via the front end(Which is a web page) at the moment im hardcoding the next stage every stage so for example

    i Raise a call and the status of that call wil be 1 when the authoriser does his update iv hardcoded the Status ID of 2 and so forth im trying to figure out if there is a way i can make SQL go and figure out the next stage depending on what status is passed in, so 1 being the status next status will be 2 and so forth...... it just saves hardcoded and passing that in as a parameter

    can some one please help me on how i achieve this, im farely new to SQL Server so any help or snippets will be highly appreciated

  • I would prefer to let the front end code get the current status then update it and insert a new row. However, SQL can do this for you if you feel that its better to allow a stored procedure to do it.

    Pass in tasknumber as a parameter (@taskNumber), select MAX(status) FROM table WHERE tasknumber = @taskNumber, and set a variable = to that result. Then set the variable = to itself + 1. Then insert it with the other information.

    Jared

    Jared
    CE - Microsoft

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

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