If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Newbie procedure problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-29-03, 14:13
donnie_darko donnie_darko is offline
Registered User
 
Join Date: Oct 2003
Location: England
Posts: 15
Newbie procedure problem

I have the following table (Student):

Student_id First_name Last_name Sex Title

and I have a procedure problem:

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
BEGIN
UPDATE STUDENT
SET TITLE = PERTITLE
WHERE FIRST_NAME = FNAME AND LAST_NAME = LNAME;
END;

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.
James
Reply With Quote
  #2 (permalink)  
Old 10-29-03, 14:25
mkkmg mkkmg is offline
Registered User
 
Join Date: Oct 2003
Location: Dallas
Posts: 76
....

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

UPDATE STUDENT
SET TITLE = @PERTITLE
WHERE FIRST_NAME = @FNAME AND LAST_NAME = @LNAME
GO
Reply With Quote
  #3 (permalink)  
Old 10-29-03, 14:32
donnie_darko donnie_darko is offline
Registered User
 
Join Date: Oct 2003
Location: England
Posts: 15
I forgot to say I am using Oracle 9i.
Reply With Quote
  #4 (permalink)  
Old 10-29-03, 15:05
donnie_darko donnie_darko is offline
Registered User
 
Join Date: Oct 2003
Location: England
Posts: 15
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!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On