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 7573151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:06:33+00:00 2026-05-30T16:06:33+00:00

How do I write a query to update my rows ‘S’. I would like

  • 0

How do I write a query to update my rows ‘S’. I would like to update the current Primary key to change the number of it. I am not sure if I need a sub-query.
Would updating score, use the same method to update “S”?
“S” indicates student number, “C” indicates course number.

My tried but failed query is

update grades set s = 114 where s = 100; 

The ‘set s’ is what I want to update into and the ‘where s’ is looking for the row with that set ‘s’ number. Right?

Here is my query, trigger, and select * from grades looks like.

create table grades (
S varchar2(12),
C varchar2(10),
Score number(3,0),
Letter_Grade char(1),
Constraint pk_grades primary key (S),
Constraint CK_grades check (score between 0 and 100)
constraint lg_grades check (letter_grade  in ('A','B','C','D','F'))
);

SET SERVEROUTPUT ON
CREATE OR REPLACE TRIGGER MARK_BU
BEFORE UPDATE OF score ON grades
FOR EACH ROW
DECLARE
BEGIN
:NEW.letter_grade :=
 CASE 
    WHEN :NEW.score >= 80 THEN 'A'
    WHEN :NEW.score >= 70 THEN 'B'
    WHEN :NEW.score >= 60 THEN 'C'
    WHEN :NEW.score >= 50 THEN 'D'
   ELSE 'F'
END ;
DBMS_OUTPUT.PUT_LINE ('Numeric_grade was updated to:    ' || :NEW.score);
DBMS_OUTPUT.PUT_LINE ('Letter_grade was calculated to be:' || :NEW.letter_grade);
END;

S            C               SCORE L
------------ ---------- ---------- -
100          CST8255            49 F
101          CST8255            59 D
102          CST8255            69 C
103          CST8255            79 B
104          CST8255            89 A
  • 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-05-30T16:06:34+00:00Added an answer on May 30, 2026 at 4:06 pm
    update grades set s = 114 where s = 100; 
    

    Is correct it will work.

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

Sidebar

Related Questions

How can I write single UPDATE query to change value of COL1 to ‘X’
Is there a way to write a query like: select * from <some number
I would like to get the number of rows that satisfies the condition. mysql_query(SELECT
I'm trying to write a query that updates rows in a table if a
how can i write the query, to update the table videos , and set
I want to write a query like this: SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order
How do I write a query that outputs the row number as a column?
I need to write a query that will group a large number of records
I need write an update statement that used multiple tables to determine which rows
We'd like to write this query: select * from table where col1 != 'blah'

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.