Re: Problem in checking conditions

From: Robert Klemme <shortcutter_at_googlemail.com>
Date: Sun, 09 Feb 2014 12:41:54 +0100
Message-ID: <blp7s3F5rl1U1_at_mid.individual.net>


On 09.02.2014 10:54, Karthick Ravi wrote:

> But when i use sum(loan)!>sum(deposit) it throws an error that
> functions are not allowed in CHECK CONSTRAIN . I this case what
> should i do? Is there any alternate way to check the sum(loan) should
> be less than the sum(deposit) in a table.

CHECK constraints are per row so they cannot apply to the whole table. You'll want to read the "Concepts" document. One straight forward approach is to create another table with the sums and have them updated via trigger. Then create constraint on that table. Of course this has implications (performance etc.).

Cheers

        robert Received on Sun Feb 09 2014 - 12:41:54 CET

Original text of this message