Auf Thema antworten

SQL in Schleifen ist prinzipiell und grundlegen eine falsche Idee.


[code]

edb=*# select * from boobaer ;

  id  | fullname

------+----------

 1069 | Aldi

 1070 | Lidl

 1075 | Edeka

 1076 | Kaufland

(4 rows)

edb=*# with x as (select id, row_number() over (order by id) from boobaer) update boobaer set fullname = 'Discounter ' || row_number::text from x where boobaer.id=x.id;

UPDATE 4

edb=*# select * from boobaer ;

  id  |   fullname  

------+--------------

 1069 | Discounter 1

 1070 | Discounter 2

 1075 | Discounter 3

 1076 | Discounter 4

(4 rows)


edb=*#

[/code]


Zurück
Oben