Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9234017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:41:26+00:00 2026-06-18T06:41:26+00:00

I have a table ‘Student’, and several attributes – two of which are important

  • 0

I have a table ‘Student’, and several attributes – two of which are important in this particular problem. I need to make sure that any student with the classification (grade level) of ‘junior’ has between exactly 55 and 84 hours (credits).

Here’s what I have have so far declaration-wise in Oracle (deleted unnecessary code):

CREATE TABLE Students (  
id INTEGER,  
name CHAR(10) NOT NULL,  
classification CHAR(10) NOT NULL,  
hours INTEGER,  
gpa NUMBER(3,2) NOT NULL,  
mentor INTEGER,  
-- IC4:  
-- To be classified as a 'junior', a student must have  
-- completed between 55 and 84 hours (inclusive).  
CONSTRAINT IC4 CHECK (classification != 'junior' AND (hours < 55 AND hours > 84))),  
);

Oracle throws the error:

ERROR at line 23:  
ORA-00922: missing or invalid option  

I am certain that I haven’t formatted the constraint correctly, but my professor spent about 3 seconds on declarations and told us to figure it out for ourselves. I know 1-attribute constraints, but I don’t know how to mix and match 2 attributes at the same time. Can someone help me out?

*Essentially in any other code it would look like nested if-statements:

if (classification == "junior") {  
    if (hours < 55 && hours > 84)  
        throwSomeError("Foolish!");  
}

I just can’t seem to translate that into SQL. My apologies if the spacing in this darn thing is bizarre, I can’t get it to format to save my life.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:41:28+00:00Added an answer on June 18, 2026 at 6:41 am

    You have a trailing comma right at the end, and one too many closing brackets:

    ...84))),);
    

    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:

    ...84)));
    

    But the condition is wrong anyway, as others have pointed out. One way of getting the result I think you want is:

    ...
    CONSTRAINT IC4 CHECK (classification != 'junior' OR hours BETWEEN 55 AND 84)
    );
    

    The OR means that the hours check is only applied when the classification is 'junior', and any other classification is not restricted. (If you need different rules for different classifications, have a look at the very similar question Chris Saxon linked to in comments).

    With some test data:

    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 
    

    BETWEEN is inclusive, so this is the same as:

    CONSTRAINT IC4 CHECK (classification != 'junior' OR (hours >= 55 AND hours <= 84))
    

    You might also want a check constraint on classification, particularly as this constraint is case-sensitive as it stands; or preferably have a separate classification table and have a foreign key constraint on the column in this table. But that’s probably out of your control for this assignment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table with two columns (varchar from, varchar to). This table represents connections
I have table with two SelectOneMenu in row. I need populate data in second
I have table with a XML column (called MetaData) which looks like this: <props>
I have table consist of column(file as pdf) which stores the bills. my problem
I have table in which I am inserting rows for employee but next time
I have table and this table contain result column with some entries. I just
I have table with 300 000 records (MyISAM). I get record from this table
I have table with structure like this: -------------------------------------------- | id | tid | uid
i have table that looks like this: <table class=content> <tbody> <tr class=fc-first> <td class=fc-widget-content
I have table like this id | serial_num | version | ..... 1 |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.