From a9fb26e58d425dd871446cef91f8ca1c496f9f7e Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 26 Aug 2019 17:53:48 +0200 Subject: [PATCH] IDEMPIERE-730 03_update_sequences.sql for native sequence / improve performance --- .../postgresql/03_update_sequences.sql | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/migration/processes_post_migration/postgresql/03_update_sequences.sql b/migration/processes_post_migration/postgresql/03_update_sequences.sql index af595be0aa..1f48e4b84f 100644 --- a/migration/processes_post_migration/postgresql/03_update_sequences.sql +++ b/migration/processes_post_migration/postgresql/03_update_sequences.sql @@ -111,13 +111,16 @@ BEGIN || ' where name=''' || r.tablename || ''' and istableid=''Y'''; - EXECUTE cmdupd; END IF; IF currentseq < currentnext AND isnativeseqon ='Y' THEN - WHILE NOT currentseq >= (currentnext-1) LOOP - EXECUTE 'SELECT nextval('''||trim(r.tablename)||'_sq'''||')' INTO currentseq; - END LOOP; + cmdupd := + 'SELECT setval(''' + || trim(r.tablename) + || '_sq'',' + || currentnext + || ')'; + EXECUTE cmdupd; END IF; END IF; END LOOP;