Constraint in a specific field

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Thu, 08 Sep 2005 11:58 am

Speak personally, I need to create a constraint on a field called dat_mes_base, despite the name it holds day/month/year (orders for it to be this way ... lol) the day is always the day 01 all the work is done on top of month/year, and this field is part of the PK of the table, that's my problem ...
I want to restrict for that no \"unsuspecting\" create a new key with same month/year but on different days.

Example: dat_mes_base cod_filial 1/1/05 1/2/05 1 1----> This can not happen can someone give me a light on how do I create a constraint with these characteristics?

Since already thank you guys ...:-

[] 's Rafael.
Rpizao
Location: RJ

Poston Mon, 12 Sep 2005 1:18 pm

Guys ....
Thank you very much...
I found a way to make .... If anyone going through the same problem, stay registered.

Code: Select all
ALTER TABLE FILIAIS ADD CONSTRAINT FILIAIS_CHK
CHECK( to_char(dat_mes_base, 'DD') = '01' );
staff Hugs ... and thanks!
Rafael.
Rpizao
Location: RJ



Return to SQL

Who is online

Users browsing this forum: No registered users and 4 guests