Building a conditional check constraint The 2019 Stack Overflow Developer Survey Results Are InCannot drop nonexistent constraint and cannot create it eitherReusing index in constraintsCannot set MEMORY_TARGET for Oracle 11.2unique constraint violatedHow to get the second string in the ORA-02296 error to show something meaningfulCheck constraint on nullable data, how to approach?Postgres: How is SET NOT NULL “more efficient” than CHECK constraintPartially-Unique Check ConstraintsCheck all values in a set with PostgreSQLtruncate table with foreign keys

Is there any way to tell whether the shot is going to hit you or not?

Protecting Dualbooting Windows from dangerous code (like rm -rf)

Is flight data recorder erased after every flight?

What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?

Loose spokes after only a few rides

Return to UK after being refused entry years previously

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

Is a "Democratic" Feudal System Possible?

Would the motor reverse if phases swapped for this case?

Why is the maximum length of OpenWrt’s root password 8 characters?

What does ひと匙 mean in this manga and has it been used colloquially?

Why was M87 targetted for the Event Horizon Telescope instead of Sagittarius A*?

Are there incongruent pythagorean triangles with the same perimeter and same area?

What is the motivation for a law requiring 2 parties to consent for recording a conversation

Did Section 31 appear in Star Trek: The Next Generation?

How can I autofill dates in Excel excluding Sunday?

How to support a colleague who finds meetings extremely tiring?

"as much details as you can remember"

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Multiply Two Integer Polynomials

Does the shape of a die affect the probability of a number being rolled?

How to notate time signature switching consistently every measure

Am I thawing this London Broil safely?



Building a conditional check constraint



The 2019 Stack Overflow Developer Survey Results Are InCannot drop nonexistent constraint and cannot create it eitherReusing index in constraintsCannot set MEMORY_TARGET for Oracle 11.2unique constraint violatedHow to get the second string in the ORA-02296 error to show something meaningfulCheck constraint on nullable data, how to approach?Postgres: How is SET NOT NULL “more efficient” than CHECK constraintPartially-Unique Check ConstraintsCheck all values in a set with PostgreSQLtruncate table with foreign keys



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I'm trying to build a conditional check constraint for my table TBL_AFIL, which has two fields:



  • Fec_Renun DATE

  • flg_afil INTEGER

Constraint: IF flg_afil=1 THEN Fec_Renun can not be NULL.



ALTER TABLE TBL_AFIL
ADD CONSTRAINT FecRenun_Not_Null CHECK (Fec_Renun IS not NULL and flg_afil =1) ;


But it throws this error:



ORA-02293: cannot validate (FecRenun_Not_Null) - check constraint violated


But when I run this query, it returns 0 rows.



SELECT * FROM TBL_AFIL
WHERE FEC_RENUN IS NULL
AND FLG_AFIL =1;


I know that to this constraint I could add ENABLE NOVALIDATE, but I'm intrigued why can't build this constraint.










share|improve this question




























    2















    I'm trying to build a conditional check constraint for my table TBL_AFIL, which has two fields:



    • Fec_Renun DATE

    • flg_afil INTEGER

    Constraint: IF flg_afil=1 THEN Fec_Renun can not be NULL.



    ALTER TABLE TBL_AFIL
    ADD CONSTRAINT FecRenun_Not_Null CHECK (Fec_Renun IS not NULL and flg_afil =1) ;


    But it throws this error:



    ORA-02293: cannot validate (FecRenun_Not_Null) - check constraint violated


    But when I run this query, it returns 0 rows.



    SELECT * FROM TBL_AFIL
    WHERE FEC_RENUN IS NULL
    AND FLG_AFIL =1;


    I know that to this constraint I could add ENABLE NOVALIDATE, but I'm intrigued why can't build this constraint.










    share|improve this question
























      2












      2








      2








      I'm trying to build a conditional check constraint for my table TBL_AFIL, which has two fields:



      • Fec_Renun DATE

      • flg_afil INTEGER

      Constraint: IF flg_afil=1 THEN Fec_Renun can not be NULL.



      ALTER TABLE TBL_AFIL
      ADD CONSTRAINT FecRenun_Not_Null CHECK (Fec_Renun IS not NULL and flg_afil =1) ;


      But it throws this error:



      ORA-02293: cannot validate (FecRenun_Not_Null) - check constraint violated


      But when I run this query, it returns 0 rows.



      SELECT * FROM TBL_AFIL
      WHERE FEC_RENUN IS NULL
      AND FLG_AFIL =1;


      I know that to this constraint I could add ENABLE NOVALIDATE, but I'm intrigued why can't build this constraint.










      share|improve this question














      I'm trying to build a conditional check constraint for my table TBL_AFIL, which has two fields:



      • Fec_Renun DATE

      • flg_afil INTEGER

      Constraint: IF flg_afil=1 THEN Fec_Renun can not be NULL.



      ALTER TABLE TBL_AFIL
      ADD CONSTRAINT FecRenun_Not_Null CHECK (Fec_Renun IS not NULL and flg_afil =1) ;


      But it throws this error:



      ORA-02293: cannot validate (FecRenun_Not_Null) - check constraint violated


      But when I run this query, it returns 0 rows.



      SELECT * FROM TBL_AFIL
      WHERE FEC_RENUN IS NULL
      AND FLG_AFIL =1;


      I know that to this constraint I could add ENABLE NOVALIDATE, but I'm intrigued why can't build this constraint.







      oracle check-constraints






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 6 hours ago









      DelmonteDelmonte

      3894819




      3894819




















          1 Answer
          1






          active

          oldest

          votes


















          6














          CHECK (NOT (flag_afil = 1 AND fec_renum IS NULL)) 





          share|improve this answer























          • Awesome. Thanks.

            – Delmonte
            4 hours ago











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "182"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234472%2fbuilding-a-conditional-check-constraint%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          6














          CHECK (NOT (flag_afil = 1 AND fec_renum IS NULL)) 





          share|improve this answer























          • Awesome. Thanks.

            – Delmonte
            4 hours ago















          6














          CHECK (NOT (flag_afil = 1 AND fec_renum IS NULL)) 





          share|improve this answer























          • Awesome. Thanks.

            – Delmonte
            4 hours ago













          6












          6








          6







          CHECK (NOT (flag_afil = 1 AND fec_renum IS NULL)) 





          share|improve this answer













          CHECK (NOT (flag_afil = 1 AND fec_renum IS NULL)) 






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 5 hours ago









          ypercubeᵀᴹypercubeᵀᴹ

          78.4k11137221




          78.4k11137221












          • Awesome. Thanks.

            – Delmonte
            4 hours ago

















          • Awesome. Thanks.

            – Delmonte
            4 hours ago
















          Awesome. Thanks.

          – Delmonte
          4 hours ago





          Awesome. Thanks.

          – Delmonte
          4 hours ago

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234472%2fbuilding-a-conditional-check-constraint%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Era Viking Índice Início da Era Viquingue | Cotidiano | Sociedade | Língua | Religião | A arte | As primeiras cidades | As viagens dos viquingues | Viquingues do Oeste e Leste | Fim da Era Viquingue | Fontes históricas | Referências Bibliografia | Ligações externas | Menu de navegação«Sverige då!»«Handel I vikingetid»«O que é Nórdico Antigo»Mito, magia e religião na volsunga saga Um olhar sobre a trajetória mítica do herói sigurd«Bonden var den verklige vikingen»«Vikingatiden»«Vikingatiden»«Vinland»«Guerreiras de Óðinn: As Valkyrjor na Mitologia Viking»1519-9053«Esculpindo símbolos e seres: A arte viking em pedras rúnicas»1679-9313Historia - Tema: VikingarnaAventura e Magia no Mundo das Sagas IslandesasEra Vikinge

          What's the metal clinking sound at the end of credits in Avengers: Endgame?What makes Thanos so strong in Avengers: Endgame?Who is the character that appears at the end of Endgame?What happens to Mjolnir (Thor's hammer) at the end of Endgame?The People's Ages in Avengers: EndgameWhat did Nebula do in Avengers: Endgame?Messing with time in the Avengers: Endgame climaxAvengers: Endgame timelineWhat are the time-travel rules in Avengers Endgame?Why use this song in Avengers: Endgame Opening Logo Sequence?Peggy's age in Avengers Endgame

          Are there legal definitions of ethnicities/races? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Legal definitions in the United StatesAre there truly legal limits on US interest rates?Are gender identity and sexual orientation federally protected?Why is there an apparent legal bias against digital services?What limits are there to the powers of individual judges in the United States legal system?Are women only scholarships legal under Irish / EU law?Is the term “race” defined by Public Law enacted by Congress of the United StatesIs there a legal definition of race in the US?Neighbors are spying for landlord on Renters is it legal?Are Protected Classes Bi-directional?