SQLite foreign key mismatch error -


why getting sqlite "foreign key mismatch" error when executing script below?

delete  rlsconfig  importer_config_id=2 ,  program_mode_config_id=1 

here main table definition:

 create table [rlsconfig] (         "rlsconfig_id"      integer primary key autoincrement not null,         "importer_config_id"        integer not null,         "program_mode_config_id"        integer not null,         "l2_channel_config_id"      integer not null,         "rls_fixed_width"       integer not null     ,         foreign key ([importer_config_id])             references [importerconfig]([importer_config_id]),         foreign key ([program_mode_config_id])             references [importerconfig]([importer_config_id]),         foreign key ([importer_config_id])             references [importerconfig]([program_mode_config_id]),         foreign key ([program_mode_config_id])             references [importerconfig]([program_mode_config_id])     ) 

and referenced table:

    create table [importerconfig] (         "importer_config_id"        integer not null,         "program_mode_config_id"        integer not null,         "selected"      integer not null default 0,         "combined_config_id"        integer not null,         "description"       varchar(50) not null collate nocase,         "date_created"      datetime not null default (current_timestamp),         primary key ([program_mode_config_id], [importer_config_id])     ,         foreign key ([program_mode_config_id])             references [programmodeconfig]([program_mode_config_id])     ) 

when use foreign key on table has composite primary key must use composite foreign key fields in primary key of referenced table.

example:

create table if not exists parents (     key1 integer not null,     key2 integer not null,     not_key integer default 0,      primary key ( key1, key2 ) );   create table if not exists childs (     child_key integer not null,     parentkey1 integer not null,     parentkey2 integer not null,     some_data integer,      primary key ( child_key ),     foreign key ( parentkey1, parentkey2 ) references parents( key1, key2 ) ); 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -