• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Check constraints

 
Aravind Kumar
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello evybdy,
I have 2 questions.
1.I need to create check constraints at the table level which could be shared by some columns of the table.Is it possible to have same set of constraints for some columns?(As we have many fields which share the same constraints)and its MS Sql Server.
2.I need to produce these constraints at the dropdown menu.how do i do it?Say if the field has constraints('EUR','USD','INR')
any reply to this message will be gratefully appreciated
Aravind
 
Mathias Nilsson
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I'm not sure exactly what you mean! But yes, you can make an checked
constraint that checks multiple columns in the same table.
When you say in the drop down I assume you mean in the enterprise manager?
  • right click the table and choose design table
  • right click a column and choose check constraints
  • click new and start typing your expression


  • now lets say you have a column named "Categories" and one named "Name"!
    The checked constraint could look like this

    Hope this helps. If it doesn't then please describe your problem more specific.
    // Mathias
    [ November 03, 2003: Message edited by: Mathias Nilsson ]
     
    shankar vembu
    Ranch Hand
    Posts: 309
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Mathias Nilsson:
    Hi!
    I'm not sure exactly what you mean! But yes, you can make an checked
    constraint that checks multiple columns in the same table.
    [ November 03, 2003: Message edited by: Mathias Nilsson ]

    Hello Mathias,
    Could u pls. let me know how it is possible to have a checked constraint for multiple columns. I know we can have a table level check constraint which can refer multiple cols for ex: check (checkin_date < checkout_date). But I think the original poster is trying to "re-use" check constraints. Meaning say u have 30 date fields in your table. And u need to have a check constraint say date < somedate: Then u will set this constraint for each of the 30 date fields. Is there any way where u can globally declare this constraint so that u can reuse this check constraint for whichever column u wanna apply to ???
    Shankar
     
    Aravind Kumar
    Ranch Hand
    Posts: 39
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hello Mathias,
    Thanx for ur help.
    I was trying to say wht shankar was saying.
    As far as I studied,we cant do that with check constraints.But we can do that with Rules where we can set a variable for the column name,say for example "@currency in ('EUR','USD',..)" and bind this rule to as may fields(columns) as we want.
    Do you knw where the details of rule is stored?For example details of check_constraint can be found at the table informatio_schema.check_constraints where i can retrieve the check constraints with the check_constraint name.
    i need this because i may need to retrieve the rule for a particular field and study the rule at the Blogic layer.

    Aravind
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic