2 -- @description: Spalten für Dialogbuchen zum Speichern, ob diese Buchung storniert wurde bzw. für welche andere Buchung diese eine Stornobuchung ist
 
   3 -- @depends: release_2_4_2
 
   4 ALTER TABLE gl ADD COLUMN storno boolean;
 
   5 ALTER TABLE gl ALTER COLUMN storno SET DEFAULT 'f';
 
   7 ALTER TABLE gl ADD COLUMN storno_id integer;
 
   8 ALTER TABLE gl ADD FOREIGN KEY (storno_id) REFERENCES gl (id);
 
  10 UPDATE gl SET storno = 'f';
 
  12 UPDATE gl SET storno = 't'
 
  13   WHERE (reference  LIKE 'Storno-%')
 
  14    AND (description LIKE 'Storno-%')
 
  18       WHERE ('Storno-' || gl2.reference   = gl.reference)
 
  19         AND ('Storno-' || gl2.description = gl.description)
 
  20         AND (gl2.id < gl.id));
 
  22 UPDATE gl SET storno = 't'
 
  23   WHERE (reference   NOT LIKE 'Storno-%')
 
  24     AND (description NOT LIKE 'Storno-%')
 
  28      WHERE ('Storno-' || gl.reference   = gl2.reference)
 
  29        AND ('Storno-' || gl.description = gl2.description)
 
  30        AND (gl2.id > gl.id));
 
  32 UPDATE gl SET storno_id =
 
  35    WHERE ('Storno-' || gl2.reference   = gl.reference)
 
  36      AND ('Storno-' || gl2.description = gl.description)
 
  41     AND (reference   LIKE 'Storno-%')
 
  42     AND (description LIKE 'Storno-%');