Recursively update data on a row

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Recursively update data on a row

    Hi all.

    If my table looks like the following

    EMPLID NAME BU SAL ELIG_CONFIG1
    1001 Tom 10 50000
    1002 Sarah 10 49000
    1003 John 20 45000
    1005 Jane 10 67000

    Now I would like to populate ELIOG_CONFIG with the value that is in
    BU. How is this done recursively so that Tom's ELIG-CONFIG1 = 10 and
    John's ELIG_CONFIG1 = 20 etc.

    EMPLID NAME BU SAL ELIG_CONFIG1
    1001 Tom 10 50000 10
    1002 Sarah 10 49000 10
    1003 John 20 45000 20
    1005 Jane 10 67000 10

    update PS_JOB set ELIG_CONFIG1 = (select BU from PS_JOB where
    .........)

    How is this done recursively thorugh the whole table?

    Does this make sense. Assume for example that EMPLID is KEY.

    John
  • Anith Sen

    #2
    Re: Recursively update data on a row

    John,

    In relational databases, all data manipulation operations are based on a set
    of rows. So in this case, all you need is a single UPDATE statement like:

    UPDATE tbl
    SET elig_config1 = bu ;

    --
    - Anith
    ( Please reply to newsgroups only )


    Comment

    • Simon Hayes

      #3
      Re: Recursively update data on a row

      oknude@yahoo.co m (John) wrote in message news:<efedb1f7. 0402101534.3b25 f856@posting.go ogle.com>...[color=blue]
      > Hi all.
      >
      > If my table looks like the following
      >
      > EMPLID NAME BU SAL ELIG_CONFIG1
      > 1001 Tom 10 50000
      > 1002 Sarah 10 49000
      > 1003 John 20 45000
      > 1005 Jane 10 67000
      >
      > Now I would like to populate ELIOG_CONFIG with the value that is in
      > BU. How is this done recursively so that Tom's ELIG-CONFIG1 = 10 and
      > John's ELIG_CONFIG1 = 20 etc.
      >
      > EMPLID NAME BU SAL ELIG_CONFIG1
      > 1001 Tom 10 50000 10
      > 1002 Sarah 10 49000 10
      > 1003 John 20 45000 20
      > 1005 Jane 10 67000 10
      >
      > update PS_JOB set ELIG_CONFIG1 = (select BU from PS_JOB where
      > ........)
      >
      > How is this done recursively thorugh the whole table?
      >
      > Does this make sense. Assume for example that EMPLID is KEY.
      >
      > John[/color]

      Given your sample data, shouldn't this work?

      update dbo.PS_JOB
      set ELIG_CONFIG1 = BU

      Simon

      Comment

      Working...