Write a procedure to enter a student's title for a particular record when the procedure is called.
Here is my attempt but it doesn't add anything to the title column:
CREATE OR REPLACE PROCEDURE TITLE(FNAME VARCHAR2, LNAME VARCHAR2, PERTITLE VARCHAR2) AS
SET TITLE = PERTITLE
WHERE FIRST_NAME = FNAME AND LAST_NAME = LNAME;
From my understanding of the question, I believe the title gets passed along with the first and second name of the person you want to add the title to. So, if anybody has any suggestions for my problem it would be great.
well in sql server it would be something like this, oracle or another database might have a slight different syntax.
Your FNAME and LNAME variables where set to varchar(2), not sure but that is a very short last name and first name. They will never get passed correctly if you do not allow enough spaces, these should be set to the length of the field in the tables.
CREATE PROCEDURE p_new_user @FNAME VARCHAR(20), @LNAME VARCHAR(25), @PERTITLE VARCHAR(4) AS
SET TITLE = @PERTITLE
WHERE FIRST_NAME = @FNAME AND LAST_NAME = @LNAME
I believe I have corrected an error I was making. When I was executing the procedure, I was typing the names in upper case when in the table they are stored with the first letter being uppercase and the rest lower case. Sorry for wasting space on the forum!