6 Replies Latest reply: Jun 1, 2013 1:16 PM by 864103 RSS

    constraints

    864103
      HI Expert ,
      i have the below requirement can you please advise
      ahmed    true        database response yes 
      ahmed     true       database response NO 
      ahmed     false      database response yes
      ahmed     false      database response yes
      ahmed     false    database response yes 
      let's see the above is example i need to reject the value when duplicate values inserted
      but just for true but for false yes accepted ,

      thanks
      so when i create constraint for ahmed
        • 1. Re: constraints
          CraigB
          First, how does your question pertain to the Oracle Forms product? It sounds like you need a "Unique Constraint" on a table to prevent duplicate names. If this is the case, are you asking for how to create the unique constraint?

          What have you tried and what was the result?

          Did you try searching the PL/SQL forum? Did you try an Internet search?

          Craig...
          • 2. Re: constraints
            864103
            thanks sir ,

            my question is how to create unique constraint per values i mean u have table with 2 columns
            first col is name and second one is state,
            des test
            name
            state
            select * from test;
            no rows selected
            
            insert into test values('ahmed','true');
            1 row inserted;
            insert into test values('ahmed','true');
            error 
            insert into test values('ahmed','false');
            1 rows inserted;
            insert into test values('ahmed','false');
            1 rows inserted;
            insert into test values('ahmed','false');
            1 rows inserted ;
            please advice
            • 3. Re: constraints
              Archana.D
              Expecting something like this,

              http://stackoverflow.com/questions/9310949/unique-constraint-on-one-column-with-excluding-row-with-same-values-in-other
              • 4. Re: constraints
                864103
                no it not same ?
                • 5. Re: constraints
                  Archana.D
                  CREATE UNIQUE INDEX INDEX_T
                      ON T( CASE WHEN NAME = 'ahmed' AND STATE='true'
                                              THEN 1
                                        WHEN NAME='ahmed' AND STATE='false'
                                              THEN NULL
                                          END );
                  Try this...
                  • 6. Re: constraints
                    864103
                    it's working thanks man.