1 Reply Latest reply: Jul 27, 2011 3:42 PM by Mark Striekwold RSS

    update loop - PL SQL

    878534
      Hi,
      First post so please let me know if I am doing anything wrong.
      The problem is this: I have a table with post codes and every post code is linked to a council through a council ID. A lot of those post codes has the council ID missing so I want to make an update that fix that
      I am kind of new with working with SQL as you can see on my first try with the update.
      update
      (
      select
      p.council_id
      from
      postcode p
      where
      (p.council_id is null)
      and (country_id = '2')
      )
      set council_id = (
      select
      DISTINCT(p1.council_id)
      from
      postcode p1
      where
      p1.id = id
      and p1.name = name
      and rownum = 1
      );
      The problem with this I of course that every council ID is set to the first row selected in the set-select. I think the way to solve this I with PL SQL but I have no clue how.

      I am very grateful for all help I can get.

      Regards,
      Jakob