sql - How to insert into a table from another table when both have two primary keys in Oracle? -


i have identical table of applies on 2 databases. have link in 1 of databases one. have filled of data, except applies table (so there no error insertion or connection):

the command run is:

create synonym app applies@"db.data-pc10"; insert applies select *  app app.a# in  ( select a# applicant) , app.p# in  ( select p# position); 

the error receive is:

error @ line 1: ora-01502: index 'bkg988.applicant_pkey' or partition of such index in unusable state 

i tried disable pk temporary on both sides:

 alter table applies disable constraint applies_pkey;  table altered. 

but still same error. appreciate if give me solution:

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */  create table applies( a#      number(6)   not null, /* applicant number       */ p#      number(8)   not null, /* position number        */ appdate     date        not null, /* application date       */     constraint applies_pkey primary key ( a#, p# ),      constraint applies_fkey1 foreign key ( a# )                 references applicant ( a# )                 on delete cascade,     constraint applies_fkey2 foreign key ( p# )                 references position ( p# )                  on delete cascade); 

and table of position:

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */  create table position( p#              number(8)       not null, /* position number            */ ptitle          varchar(30)     not null, /* position title             */ employer    varchar(100)    not null, /* institution name           */ salary      number(9,2) not null, /* salary         */ extras      varchar(50)     , /* extras         */ specification   long                , /* specification      */     constraint position_pkey primary key ( p# ),     constraint position_fkey1 foreign key ( ptitle )                 references lptitle ( title ) ); 

and here table of applicant:

create table applicant( a#              number(6)       not null, /* staff number               */ fname           varchar(20)     not null, /* first name                 */ lname       varchar(30) not null, /* last name          */ address         varchar(50)     not null, /* street, home number, etc.  */ city        varchar(30) not null, /* city           */ state       varchar(20) not null, /* state          */ phone#      number(10)  not null, /* phone number       */ fax#        number(10)      , /* fax number         */ email       varchar(50)     , /* e-mail address     */ acomment    long            ,  /* interesting comments interviews */     constraint applicant_pkey primary key ( a# ),     constraint applicant_fkey1 foreign key ( state )                 references lstate ( state ) ); 

so far have found 1 solution is:

/* other option define table deferrable  accrding q/a tom in https://asktom.oracle.com/pls/asktom/f?p=100:11:0%3a%3a%3a%3ap11_question_id:8806498660292*/ alter table applies disable constraint applies_pkey; alter table applies disable constraint applies_fkey1; alter table applies disable constraint applies_fkey2;  create synonym app applies@"db.data-pc10"; insert applies select *  app app.a# in  ( select a# applicant) , app.p# in  ( select p# position);   alter table applies enable constraint applies_pkey; alter table applies enable constraint applies_fkey1; alter table applies enable constraint applies_fkey2; 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -