Description

During an analysis, the following error seen in the synchronization log :

SQL Error: ERROR: could not create unique index "idx_cat".

SQL Error: DETAIL: Key (idcat)=(139512) is duplicated. (Severity 1, Msg No 1).

Observed in CAST AIP
Release
Yes/No
8.3.x(tick)
8.2.x(tick)
8.1.x(tick)
8.0.x(tick)
7.3.x(tick)
7.2.x(tick)
7.0.x(tick)
Observed on RDBMS
RDBMS
Yes/No
Oracle Server(tick)
Microsoft SQL Server(tick)
CSS3(tick)
CSS2(tick)
CSS1(tick)
Step by Step Scenario
  1. Package the source code
  2. Run the analysis, analysis stops with errors in the log.
Action Plan

This issue occurs due to duplicates in the following tables in the local database:

  • cat
  • catattr
  • catcat

We need to remove the duplicates from the above tables.

  1. For this First create a temporary table
  2. Insert distinct values from the table to this temporary table.
  3. Truncate the table and insert the values from the temporary table to this table,
  4. Drop the temporary table.
  5. Then run the analysis.

Below are the queries to remove the duplicate values from the tables.

CREATE TABLE tmp_cat
(
  idcat integer NOT NULL,
  catnam character varying(255) NOT NULL,
  catdsc character varying(255) NOT NULL,
  status character(10) NOT NULL
)
WITH (
  OIDS=FALSE
);

ALTER TABLE tmp_cat OWNER TO operator;

Insert into tmp_cat select distinct * from cat;
truncate table cat;
insert into cat select * from tmp_cat;
drop table tmp_cat;

create unique index idx_cat on cat using btree (idcat);
 

CREATE TABLE tmp_catattr
(
  idcat integer NOT NULL,
  attrnam character varying(255),
  attrtyp integer NOT NULL,
  intval integer,
  strval character varying(255),
  status character(10) NOT NULL
)
WITH (
  OIDS=FALSE
);

ALTER TABLE tmp_catattr OWNER TO operator;

insert into tmp_catattr select a.* from catattr a, catattr b where a.idcat = b.idcat and a.attrnam = b.attrnam and a.ctid < b.ctid;
truncate table catattr;
insert into catattr select * from tmp_catattr;
drop table tmp_catattr;

CREATE TABLE tmp_catcat
(
  idcat integer NOT NULL,
  idcatparent integer NOT NULL,
  status character(10) NOT NULL
)
WITH (
  OIDS=FALSE
);

ALTER TABLE tmp_catcat OWNER TO operator;

insert into tmp_catcat select a.* from catcat a, catcat b where a.idcat = b.idcat and a.idcatparent = b.idcatparent and a.ctid < b.ctid;
truncate table catcat;
insert into catcat select * from tmp_catcat;
drop table tmp_catcat;
Impact on Analysis Results and Dashboard

 

Notes/comments

Ticket # 4021

Related Pages