Knowee
Questions
Features
Study Tools

In a student database, there's a table named student that stores information about students, including their names and marks in different subjects (Math, English, Science, and History). Some students may initially have NULL values for their marks. Your task is to create a function named tbl_Update that takes the student's name and new marks for each subject as input parameters. The function should update the student's marks in the table based on the provided values.The following table is already created, and the records are inserted into the table.Table:student Name VARCHAR(100), Math INT, English INT, Science INT, History INTPrepopulated Records:Input format :The input records are already prepopulated, as given in the problem statement.Output format :The output should return 1 to indicate a successful update and should display the student's information with the updated result.tbl_update('Saurabh',85,69,75,82)1Name Math English Science HistoryRaman 95 89 85 81Rahul 90 87 86 81Mohit 90 85 86 81Saurabh 85 69 75 82

Question

In a student database, there's a table named student that stores information about students, including their names and marks in different subjects (Math, English, Science, and History). Some students may initially have NULL values for their marks. Your task is to create a function named tbl_Update that takes the student's name and new marks for each subject as input parameters. The function should update the student's marks in the table based on the provided values.The following table is already created, and the records are inserted into the table.Table:student Name VARCHAR(100), Math INT, English INT, Science INT, History INTPrepopulated Records:Input format :The input records are already prepopulated, as given in the problem statement.Output format :The output should return 1 to indicate a successful update and should display the student's information with the updated result.tbl_update('Saurabh',85,69,75,82)1Name Math English Science HistoryRaman 95 89 85 81Rahul 90 87 86 81Mohit 90 85 86 81Saurabh 85 69 75 82

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

To solve this problem, you can use SQL, a language designed for managing data in relational database management systems. Here's how you can create the function tbl_Update:

CREATE FUNCTION tbl_Update(@Name VARCHAR(100), @Math INT, @English INT, @Science INT, @History INT)
RETURNS INT
AS
BEGIN
    -- Update the student's marks
    UPDATE student
    SET Math = @Math, English = @English, Science = @Science, History = @History
    WHERE Name = @Name;

    -- If the update was successful, return 1
    IF @@ROWCOUNT > 0
        RETURN 1;
    ELSE
        RETURN 0;
END;

This function takes the student's name and new marks for each subject as input parameters. It then updates the student's marks in the student table based on the provided values. If the update was successful, the function returns 1; otherwise, it returns 0.

You can call this function like this:

DECLARE @result INT;
EXEC @result = tbl_Update 'Saurabh', 85, 69, 75, 82;
SELECT @result AS 'Result';

This will update the marks for the student named 'Saurabh' and return 1 if the update was successful.

This problem has been solved

Similar Questions

Problem StatementIn a university's academic department, a database table named "students" that stores information about students, including their student ID, name, enrolled course, and scores obtained in different subjects.The university administration wants to analyze the performance of students and identify those who scored above a certain threshold. To facilitate this analysis, you are tasked with creating a stored procedure named "GetHighScorers".The following table is already created, and the records are inserted into the table.TABLE: students student_id INT PRIMARY KEY, student_name VARCHAR(50), course VARCHAR(50), score INT

UPDATE `db_me`.`student_table` SET `student_name` = 'Sarah Geronimo' WHERE `student_table`.`student_id` =1;*5 pointsThere is an error in the statementStatement will execute successfullyOther:INSERT INTO `db_me`.`student_table` (`student_id` ,`student_name` ,`student_year`)VALUES (NULL , 'Sarah G', '3rd year'), (NULL , 'Moira', `3rd year`);*5 pointsThere is an error in the statementStatement will execute successfullyOther:CREATE DATABASE 'db_me' ; *5 pointsThere is an error in the statementStatement will execute successfullyOther:CREATE TABLE `db_me`.`student_table` (`student_id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,student_name VARCHAR( 255 ) NOT NULL ,`student_year` VARCHAR( 255 ) NOT NULL) *5 pointsThere is an error in the statementStatement will execute successfullyOther:BackNext

You are developing a Student Record Management System in C. The system needs to store and manage information for multiple students, including their names, roll numbers, and marks obtained in different subjects. Implement array in structures to read, write, and compute average marks and the students scoring above and below the average marks for a class of N students. INPUT/OUTPUT EXAMPLE: Enter the number of students: 3 Enter details for 3 students: Student 1: Name: A Roll Number: 1 Marks in 5 subjects: Subject 1: 12 Subject 2: 13 Subject 3: 14 Subject 4: 15 Subject 5: 16 Student 2: Name: BB Roll Number: 2 Marks in 5 subjects: Subject 1: 11 Subject 2: 13 Subject 3: 12 Subject 4: 15 Subject 5: 14 Student 3: Name: CC Roll Number: 10 Marks in 5 subjects: Subject 1: 13 Subject 2: 14 Subject 3: 16 Subject 4: 17 Subject 5: 11 Class average marks: 13.73 Students scoring above average: A (Roll Number: 1) CC (Roll Number: 10) Students scoring below average: BB (Roll Number: 2)

Create a class called "Student" with private member variables for name, roll number, and marks in three subjects. Include public member functions to set the student details, calculate the average marks, and display the student detail

2.Question 2You are the database administrator for a school. Student information is kept in a students table where students are tracked by student_id. Students have a grade point average listed for each semester in a table named grades where each student is referenced by student_id.The school is giving an award to all students who achieved a 4.0 grade point average during any semester. You need to generate a list of all the students who should get the award. You begin typing your query:What should you type in the blank space? (Please type your answer all in lower case. Example: select)1 point

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.