[6.2.8 / PostgreSQL] Issue with sequences not "updated"

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
swierzbicki
Posts: 451
Joined: Wed 19 Jan 2005 09:59

[6.2.8 / PostgreSQL] Issue with sequences not "updated"

Post by swierzbicki » Wed 07 Oct 2015 07:40

Hello,

It appears that sequences aren't correctly set after using TUniLoader (moving data from database A to database B) or TUniDump (restoring tables).

I my case, sequence productions_matieres_details_id_production_matierre_detail_seq should have it's nexval set to 11 but it remains to 1

Update:it appears to works as expected, postgreSQL doesn't update the sequence when the ID is explicitly set in an Insert / Copy command.

Table :

Code: Select all

CREATE TABLE public.productions_matieres_details (
  id_production_matierre_detail SERIAL,
  position_matiere INTEGER NOT NULL,
  ligne VARCHAR(50) DEFAULT ''::character varying NOT NULL,
  date_poste DATE,
  id_matiere VARCHAR(6) DEFAULT ''::character varying,
  ordre_fabrication VARCHAR(10) DEFAULT ''::character varying,
  longueur REAL DEFAULT 0,
  longueur_deroulee REAL DEFAULT 0,
  longueur_restante REAL DEFAULT 0,
  date_entree_matiere TIMESTAMP WITHOUT TIME ZONE,
  date_sortie_matiere TIMESTAMP WITHOUT TIME ZONE,
  code_barre_matiere VARCHAR(50) DEFAULT ''::character varying,
  id_fournisseur VARCHAR(8) DEFAULT ''::character varying,
  id_lot_fournisseur VARCHAR(12) DEFAULT ''::character varying,
  compteur INTEGER DEFAULT 0,
  compteur_produit INTEGER DEFAULT 0,
  id_poste INTEGER,
  id_pilote_1 VARCHAR(10) DEFAULT ''::character varying,
  id_pilote_2 VARCHAR(10) DEFAULT ''::character varying,
  en_preparation BOOLEAN,
  reste_matiere BOOLEAN,
  CONSTRAINT productions_matieres_details_pkey PRIMARY KEY(id_production_matierre_detail)
) 
WITH (oids = false);

CREATE INDEX productions_matieres_details_date_sortie_matiere ON public.productions_matieres_details
  USING btree (date_sortie_matiere DESC);

CREATE INDEX productions_matieres_details_ligne ON public.productions_matieres_details
  USING btree (ligne COLLATE pg_catalog."default");

CREATE INDEX productions_matieres_details_matiere ON public.productions_matieres_details
  USING btree (id_matiere COLLATE pg_catalog."default");

CREATE INDEX productions_matieres_details_ordre_fabrication ON public.productions_matieres_details
  USING btree (ordre_fabrication COLLATE pg_catalog."default");

CREATE INDEX productions_matieres_details_pilote_poste_pmd ON public.productions_matieres_details
  USING btree (id_poste, id_pilote_1 COLLATE pg_catalog."default", id_pilote_2 COLLATE pg_catalog."default");

CREATE INDEX productions_matieres_details_position ON public.productions_matieres_details
  USING btree (position_matiere);

CREATE INDEX productions_matieres_details_position_en_preparation ON public.productions_matieres_details
  USING btree (en_preparation);

CREATE INDEX productions_matieres_details_position_ligne ON public.productions_matieres_details
  USING btree (position_matiere, ligne COLLATE pg_catalog."default");
Sequence :

Code: Select all

CREATE SEQUENCE public.productions_matieres_details_id_production_matierre_detail_seq
  INCREMENT 1 MINVALUE 1
  MAXVALUE 9223372036854775807 START 1
  CACHE 1;
Dump Script

Code: Select all

-- UniDAC version: 6.2.8
-- PostgreSQL server version: 9.4.4
-- PostgreSQL client version: 8.0 Direct
-- Script date 07/10/2015 09:22:39
-- ---------------------------------------------------------------------- 
-- Server: xxx.xxx.xxx.xxx
-- Database: xxxx

SET search_path = public, pg_catalog;

DELETE FROM productions_matieres_details;
INSERT INTO productions_matieres_details VALUES ('1', '2', 'PICPIC 1', '2015-08-28', 'T2612', '359259', '200', '199.19', '0.81', '2015-08-28 09:33:46.49', '2015-08-28 15:10:50.294', '00000EDkoIy+qlz/34410 T2612000081', '', 'EDkoIy+qlz/', '34410', '109', '2', '05', '15', 'f', 'f');
INSERT INTO productions_matieres_details VALUES ('2', '0', 'PICPIC 1', '2015-08-28', 'T2612', '359259', '200', '199.19', '0.81', '2015-08-28 09:33:28.771', '2015-08-28 15:10:51.614', '00000EDkoIy8hnVB34388 T2612000081', '', 'EDkoIy8hnVB', '34388', '109', '2', '05', '15', 'f', 'f');
INSERT INTO productions_matieres_details VALUES ('3', '2', 'PICPIC 1', '2015-08-28', 'T2612', '359259', '200', '199.16', '0.84', '2015-08-28 15:10:48.708', '2015-08-28 16:23:26.051', '11400EDkoJQ9A/i754643 T2612000083', '1140.00', 'EDkoJQ9A/i7', '54643', '237', '2', '05', '15', 'f', 't');
INSERT INTO productions_matieres_details VALUES ('4', '0', 'PICPIC 1', '2015-08-28', 'T2612', '359259', '200', '199.16', '0.84', '2015-08-28 15:10:50.956', '2015-08-28 16:23:27.409', '11400EDkoJQ7P+UC54624 T2612000083', '1140.00', 'EDkoJQ7P+UC', '54624', '237', '2', '05', '15', 'f', 't');
INSERT INTO productions_matieres_details VALUES ('5', '2', 'PICPIC 1', '2015-08-28', 'T2612', '359259', '200', '201.27', '-1.27', '2015-08-28 16:23:24.914', '2015-08-28 17:08:18.557', '03790EDkoJU6/uR/57322 T261200-127', '379.00', 'EDkoJU6/uR/', '57322', '367', '2', '05', '15', 'f', 't');
INSERT INTO productions_matieres_details VALUES ('6', '0', 'PICPIC 1', '2015-08-28', 'T2612', '359259', '200', '201.27', '-1.27', '2015-08-28 16:23:26.686', '2015-08-28 17:08:19.097', '03790FR33681943700018 T261200-127', '0379.00', '0FR336819437', '18', '367', '2', '05', '15', 'f', 'f');
INSERT INTO productions_matieres_details VALUES ('7', '0', 'PICPIC 1', '2015-08-28', 'T2612', '359259', '200', '200.4', '-0.4', '2015-08-28 17:08:19.097', '2015-08-28 18:12:36.465', '03790EDkoJZ7BV+U60697 T2612000-40', '379.00', 'EDkoJZ7BV+U', '60697', '496', '2', '05', '15', 'f', 't');
INSERT INTO productions_matieres_details VALUES ('8', '2', 'PICPIC 1', '2015-08-28', 'T2612', '359259', '200', '200.4', '-0.4', '2015-08-28 17:08:18.557', '2015-08-28 18:12:40.837', '03790EDkoJZ7ZjJc60701 T2612000-40', '379.00', 'EDkoJZ7ZjJc', '60701', '496', '2', '05', '15', 'f', 't');
INSERT INTO productions_matieres_details VALUES ('9', '0', 'PICPIC 1', '2015-08-28', 'T2612', '359269', '200', '200.72', '-0.72', '2015-08-28 18:12:36.465', '2015-08-28 18:59:39.138', '03790EDkoJhHVSUt65552 T2612000-71', '379.00', 'EDkoJhHVSUt', '65552', '24', '2', '05', '15', 'f', 't');
INSERT INTO productions_matieres_details VALUES ('10', '2', 'PICPIC 1', '2015-08-28', 'T2612', '359269', '200', '200.72', '-0.72', '2015-08-28 18:12:40.837', '2015-08-28 19:01:39.485', '03790EDkoJhHzQ1F65557 T2612000-71', '379.00', 'EDkoJhHzQ1F', '65557', '33', '2', '05', '15', 'f', 't');
How can this be done "automatically" ?


Post Reply