Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

Can I insert a value null into column with a foreign key constraints in a COULMN table?

$
0
0

I have a problem when I try insert a value NULL into a column with foreign key constraints

 

Example:

 

CREATECOLUMNTABLE AZIENDA2 (

COD_AZIENDA VARCHAR(30) NOTNULL,

RAGIONE_SOCIALE VARCHAR(600) NULL,

SEDE_LEGALE VARCHAR(330) NULL,

SEDE_AMMINISTRATIVA VARCHAR(330) NULL

);

 

----PROMPT 'CREATE COLUMN TABLE AZIENDA_GERARCHIA';

 

CREATECOLUMNTABLE AZIENDA_GERARCHIA2 (

COD_AZIENDA_GERARCHIA VARCHAR(2) NOTNULL,

COD_AZIENDA_ELEGER VARCHAR(30) NOTNULL,

COD_AZIENDA_RIFERIMENTO VARCHAR(30) NULL

);

 

--'Create primary key on table AZIENDA';

 

ALTERTABLE AZIENDA2

ADDCONSTRAINT PK_AZIENDA2

    PRIMARYKEY (COD_AZIENDA);

 

--'Create primary key on table AZIENDA_GERARCHIA';

 

ALTERTABLE AZIENDA_GERARCHIA2

ADDCONSTRAINT PK_AZIENDA_GERARCHIA2

    PRIMARYKEY (COD_AZIENDA_GERARCHIA, COD_AZIENDA_ELEGER);

 

--'Create foreign key on table AZIENDA_GERARCHIA';

 

ALTERTABLE AZIENDA_GERARCHIA2

ADDCONSTRAINT FK_GENERALE2_00348

    FOREIGNKEY (COD_AZIENDA_RIFERIMENTO)

    REFERENCES AZIENDA2;

   

-- 'Standard configuration - Table AZIENDA_GERARCHIA';

INSERTINTO AZIENDA_GERARCHIA2 (

COD_AZIENDA_GERARCHIA, COD_AZIENDA_ELEGER,COD_AZIENDA_RIFERIMENTO

) VALUES ('$', '$', NULL);

 

When I try to insert into AZIENDA_GERARCHIA2, I get the following error

 

Could not execute 'INSERT INTO AZIENDA_GERARCHIA2 ( COD_AZIENDA_GERARCHIA, COD_AZIENDA_ELEGER,COD_AZIENDA_RIFERIMENTO ...' in 470 ms 710 µs .

SAP DBTech JDBC: [461]: foreign key constraint violation: 

 

This error does NOT happen if I create the table with this instruction

 

Example:

CREATETABLE AZIENDA2 (…);

 

Could you please help us with Issue? Can I insert a value null into column with a foreign key constraints in a COULMN table? (In a row table I can)


Viewing all articles
Browse latest Browse all 5653

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>