cancel
Showing results for 
Search instead for 
Did you mean: 

unique modifier

0 Kudos
353

i have to implement the following:
create table prac(
a varchar(20),
b varchar(20),
c varchar(20),
constraint ab unique (a,b),
constraint ac unique (a,c)
);
using items.xml. how can i do that?

0 Kudos

, please help me on this.

Accepted Solutions (1)

Accepted Solutions (1)

former_member620692
Active Contributor
0 Kudos

Hi - you can achieve this as follows:

 <itemtype generate="true" code="Prac" jaloclass="org.training.jalo.Prac" autocreate="true">
     <deployment table="prac" typecode="22222"/>
     <attributes>
         <attribute qualifier="code" type="java.lang.String">
             <persistence type="property"/>
             <modifiers unique="true"/>
         </attribute>
         <attribute qualifier="a" type="java.lang.String">
             <persistence type="property"/>
         </attribute>
         <attribute qualifier="b" type="java.lang.String">
             <persistence type="property"/>
         </attribute>
         <attribute qualifier="c" type="java.lang.String">
             <persistence type="property"/>
         </attribute>                
     </attributes>
     <indexes>
         <index name="ab" unique="true" replace="true">
             <key attribute="a"/>
             <key attribute="b"/>
         </index>
         <index name="ac" unique="true" replace="true">
             <key attribute="a"/>
             <key attribute="c"/>
         </index>
     </indexes>
 </itemtype>

Now try to import the following ImpExes:

 INSERT prac;code[unique=true];a;b;c
 ;1;a1;b1;c1
 
 INSERT prac;code[unique=true];a;b;c
 ;2;a1;b2;c2
 
 INSERT prac;code[unique=true];a;b;c
 ;3;a1;b1;c2
 
 INSERT prac;code[unique=true];a;b;c
 ;4;a1;b2;c1

The first and second of these ImpExes will pass while the third and fourth will fail.

0 Kudos

hello arvind, thanks for your support

former_member620692
Active Contributor
0 Kudos

You are most welcome.

Answers (0)