Clarify Me

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ilikesuresh
    New Member
    • Aug 2007
    • 47

    Clarify Me

    Hi
    i write a program in Pro *C to increase the salary of employees based on some constraints.
    Its works fine and if i execute the program in the first time the salaries would be increased depending on the constraints.But if i execute immediately the second time, the updated values have been treated as a old value and again the salaries are incremented.Is there any specific way to ensure this if the update happens continuously on the second time the program or oracle through errors,exceptio ns?

    Please clarify me
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by ilikesuresh
    Hi
    i write a program in Pro *C to increase the salary of employees based on some constraints.
    Its works fine and if i execute the program in the first time the salaries would be increased depending on the constraints.But if i execute immediately the second time, the updated values have been treated as a old value and again the salaries are incremented.Is there any specific way to ensure this if the update happens continuously on the second time the program or oracle through errors,exceptio ns?

    Please clarify me
    Could you please POST the table structure, Constraints that you are talking about for my reference and any other related details!!

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      If you are executing the command command 2 times it is bound to fire 2 times. If u want only once why are you executin that 2 times . The update command will fire every time you execute that and will reflect in the database table.

      Comment

      • ilikesuresh
        New Member
        • Aug 2007
        • 47

        #4
        Originally posted by amitpatel66
        Could you please POST the table structure, Constraints that you are talking about for my reference and any other related details!!
        LASTNAME Varchar2(20)
        DEPTID Number(2)
        SALARY Number
        EMPID Number(3)
        MGRID Number(3)
        HIREDATE date

        That is the table structure
        and the constraints in the sense if the salary > 10000 and < 20000
        salary = salary +1000
        if >=20000 and <30000
        salary = salry +2000

        Thats all !!!

        Comment

        • amitpatel66
          Recognized Expert Top Contributor
          • Mar 2007
          • 2358

          #5
          Originally posted by ilikesuresh
          LASTNAME Varchar2(20)
          DEPTID Number(2)
          SALARY Number
          EMPID Number(3)
          MGRID Number(3)
          HIREDATE date

          That is the table structure
          and the constraints in the sense if the salary > 10000 and < 20000
          salary = salary +1000
          if >=20000 and <30000
          salary = salry +2000

          Thats all !!!
          Every time you run the update, the salary will get incremented until it goes above 30,000. Once it reaches 30,000 the salary will not increment as per your constraints. Now if you want the update tp happen only once on each row, then you can have one more column as a flag which you can default to 'N'.

          When updating salary, check for flag value. If 'N' then update the flag to 'Y' and the salary. If flag is 'Y' then dont update anything.

          Comment

          • ilikesuresh
            New Member
            • Aug 2007
            • 47

            #6
            Originally posted by amitpatel66
            Every time you run the update, the salary will get incremented until it goes above 30,000. Once it reaches 30,000 the salary will not increment as per your constraints. Now if you want the update tp happen only once on each row, then you can have one more column as a flag which you can default to 'N'.

            When updating salary, check for flag value. If 'N' then update the flag to 'Y' and the salary. If flag is 'Y' then dont update anything.
            Thanks for Your valuable advice.But Is there any possiblities to hide the flag column from user view other than creating 'views'?

            Comment

            • debasisdas
              Recognized Expert Expert
              • Dec 2006
              • 8119

              #7
              Originally posted by ilikesuresh
              Thanks for Your valuable advice.But Is there any possiblities to hide the flag column from user view other than creating 'views'?
              No, you need to create views for that.

              Comment

              Working...