Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have a trailing comma right at the end, and one too many closing brackets:</p> <pre><code>...84))),); </code></pre> <p>Unless you've cut something out before posting, which may be the case as the error references line 23 (but hopefully not as it's tricky to see a problem in code you can't see at all). What you have compiles if that becomes:</p> <pre><code>...84))); </code></pre> <p>But the condition is wrong anyway, as others have pointed out. One way of getting the result I think you want is:</p> <pre><code>... CONSTRAINT IC4 CHECK (classification != 'junior' OR hours BETWEEN 55 AND 84) ); </code></pre> <p>The <code>OR</code> means that the <code>hours</code> check is only applied when the <code>classification</code> is <code>'junior'</code>, and any other <code>classification</code> is not restricted. (If you need different rules for different classifications, have a look at <a href="https://stackoverflow.com/a/14669589/266304">the very similar question</a> Chris Saxon linked to in comments).</p> <p>With some test data:</p> <pre><code>insert into students values (1, 'A', 'junior', 54, 1, 1); -- ORA-02290 insert into students values (2, 'B', 'junior', 55, 1, 1); -- OK insert into students values (3, 'C', 'junior', 84, 1, 1); -- OK insert into students values (4, 'D', 'junior', 85, 1, 1); -- ORA-02290 insert into students values (5, 'E', 'senior', 54, 1, 1); -- OK insert into students values (6, 'F', 'senior', 55, 1, 1); -- OK insert into students values (7, 'G', 'senior', 84, 1, 1); -- OK insert into students values (8, 'H', 'senior', 85, 1, 1); -- OK select * from students order by id; ID NAME CLASSIFICATION HOURS GPA MENTOR ---- ---------- -------------- ----- --- ------ 2 B junior 55 1.00 1 3 C junior 84 1.00 1 5 E senior 54 1.00 1 6 F senior 55 1.00 1 7 G senior 84 1.00 1 8 H senior 85 1.00 1 6 rows selected </code></pre> <p><code>BETWEEN</code> is inclusive, so this is the same as:</p> <pre><code>CONSTRAINT IC4 CHECK (classification != 'junior' OR (hours &gt;= 55 AND hours &lt;= 84)) </code></pre> <p>You might also want a check constraint on <code>classification</code>, particularly as this constraint is case-sensitive as it stands; or preferably have a separate <code>classification</code> table and have a foreign key constraint on the column in this table. But that's probably out of your control for this assignment.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload