Question

In: Computer Science

Create a stored procedure using the STUDENT database called ap_CalcGrade that does the following: Accepts as...

Create a stored procedure using the STUDENT database called ap_CalcGrade that does the following: Accepts as input STUDENT_ID, SECTION_ID, GRADE_TYPE_CODE, and GRADE_CODE_OCCURRENCE Outputs the numeric grade and the letter grade back to the user If the numeric grade is found, return 0, otherwise return 1 You muse use a cursor to loop through the GRADE_CONVERSION table to find the letter grade

Solutions

Expert Solution

create PROCEDURE [dbo].[ap_CalcGrade]
-- Add the parameters for the stored procedure here
@studId int,
@secId int,
@grdTyCd char(2),
@grdCdOcc int,
@Numeric int output,
@LetterVal char(2) output
AS

SET NOCOUNT ON;

SELECT @Numeric = Numeric_Grade from [Student].dbo.Grade
where STUDENT_ID = @studId AND
SECTION_ID = @secId AND
GRADE_TYPE_CODE = @grdTyCd AND
GRADE_CODE_OCCURRENCE = @grdCdOcc;

IF @@ROWCOUNT = 0 -- wrong parameters passed
RETURN 1; -- not found

Declare @CrsrVar Cursor LOCAL STATIC FAST_FORWARD

For
SELECT LETTER_GRADE
FROM GRADE_CONVERSION
WHERE
MAX_GRADE >= @Numeric AND MIN_GRADE <= @Numeric -- should return a single row cursor, but may return a few rows in case we have overlapping ranges

Open @CrsrVar

Fetch Next From @CrsrVar
Into @LetterVal

While (@@FETCH_STATUS = 0)
BEGIN


Fetch Next From @CrsrVar
Into @LetterVal -- will return the latest grade from that cursor

END

Close @CrsrVar
Deallocate @CrsrVar

IF @LetterVal IS NOT NULL
RETURN 0;-- found some data
ELSE
RETURN 1; -- not found letter grade in the GradeConversion
GO


Related Solutions

Create a stored procedure that can be used to add a student to the school and...
Create a stored procedure that can be used to add a student to the school and a section of a course. 1. If the student already exists, then just add him to the section (do not update information like address). 2. The procedure will require the following arguments (see table definition for types): A. Salutation B. First Name C. Last Name D. Street Address (including City) E. ZIP Code F. Phone Number G. Employer Name (if any) H. Course Number...
Using SQL create a new database called school_app. Create a student table with fields id (auto...
Using SQL create a new database called school_app. Create a student table with fields id (auto increment), first_name, last_name. Create a course table with fields id (auto increment), course code (such as ITC or MTH), and course number (such as 100 or 295). Note that the relationship between student and course is many-to-many (n:m). Create a join table called student_course that implements the n:m relationship with fields id (auto increment), student_id, course_id, and grade (which has values 0, 1, 2,...
Oracle - Create a procedure that accepts product ID as a parameter and returns the name...
Oracle - Create a procedure that accepts product ID as a parameter and returns the name of the product from ProductTable table. Add exception handling to catch if product ID is not in the table. Table to use: CREATE TABLE ProductTable(     ProductID INTEGER NOT NULL primary key,     ProductName VARCHAR(50) NOT NULL,     ListPrice NUMBER(10,2),     Category INTEGER NOT NULL ); / INSERT INTO ProductTable VALUES(299,'Chest',99.99,10); INSERT INTO ProductTable VALUES(300,'Wave Cruiser',49.99,11); INSERT INTO ProductTable VALUES(301,'Megaland Play Tent',59.99,11); INSERT INTO...
Instructions Using the installed software for this course create a generic class called VehicleRental which accepts...
Instructions Using the installed software for this course create a generic class called VehicleRental which accepts any generic type of Vehicle ( create an instance of Car, Van and MotorCycle classes) Each type of Vehicle object has methods called drive, start and stop ( add simple print statement) The VehicleRental class has a method called rent which accept a generic type of Vehicle object, this method will call drive method of passed Vehicle object The solution will produce the following:...
Your code needs to do the following: Create a function called pigLatin that accepts a string...
Your code needs to do the following: Create a function called pigLatin that accepts a string of English words in the parameter sentence and returns a string of those words translated into Pig Latin. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. For example the sentence “The quick brown fox” becomes “hetay uickqay rownbay oxfay”. You may assume the words in the parameter...
Database exercise: inpatient cases Create database using name RUMKIT Create tables below in that database patient(idPatient,...
Database exercise: inpatient cases Create database using name RUMKIT Create tables below in that database patient(idPatient, fullName, biologicalMother, birthdate, address) doctor(idDr, fullName, specialization, consulRates) inpatient(idPatient, entryTime, outTime, idDr, idRoom). Please make entryTime as column that is going to be filled automatically when care record is being add room(idRoom, roomName, cost) fill the data above to each table Create sql query and relational algebra expressions for the query Please give me detailed answer so I could learn from it. Thank you...
Create a class called Student which stores • the name of the student • the grade...
Create a class called Student which stores • the name of the student • the grade of the student • Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into the grade field. • Calculate the...
Language C++ Student-Report Card Generator: create a class called student and class called course. student class...
Language C++ Student-Report Card Generator: create a class called student and class called course. student class this class should contain the following private data types: - name (string) - id number (string) - email (s) - phone number (string) - number of courses (int) - a dynamic array of course objects. the user will specify how many courses are there in the array. the following are public members of the student class: - default constructor (in this constructor, prompt the...
Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft...
Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft Access, Oracle, or MySQL) as indicated by your professor. After creating the database – populate it with some data (could be made up). SQL syntax and the DB application will be discussed and taught in class. This is the final deliverable of the group project. Assignment is due by the due date as indicated by your professor. *Make sure to submit the completed database...
A student collected the following data while using the procedure described in this module: 27.13 mL...
A student collected the following data while using the procedure described in this module: 27.13 mL of 1.00 x 10^-2M EDTA soltuion was required to reach the ErioT end point for titration of 25.00 mL of the sample water. After boiling and filtering 100.00 mL of the water, the student diluted the filtrate to 100.0 mL with distilled water. To titrate 25.00 mL of the diluted filtrate, 26.40 mL of 2.00 x 10^-1 M EDTA solution was required. The studetn...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT