plsql - ORACLE trigger check if each value of a row is different to each other -


ist possible compare on insert , update if values different each other (except null)? have 10 columns numbers , doesnt want write each possibility if statement.

example:

column_1 | column_2 | column_3 --------------------------------    5           2          4        <- allowed insert    1           2          1        <- forbidden insert/update, because there 2 '1' in row 

i think you're going need have explicit comparisons. can use check constraint make comparisons, in

create table some_table   (col1   number,    col2   number,    col3   number,    col4   number,    col5   number,    col6   number,    col7   number,    col8   number,    col9   number,    col10  number,    constraint some_table_ck1      check(col1  not in (col2, col3, col4, col5, col6, col7, col8, col9, col10) ,            col2  not in (col3, col4, col5, col6, col7, col8, col9, col10) ,            col3  not in (col4, col5, col6, col7, col8, col9, col10) ,            col4  not in (col5, col6, col7, col8, col9, col10) ,            col5  not in (col6, col7, col8, col9, col10) ,            col6  not in (col7, col8, col9, col10) ,            col7  not in (col8, col9, col10) ,            col8  not in (col9, col10) ,            col9  not in (col10))); 

share , enjoy.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -