Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 10th, 2005, 11:05 AM
stevensys stevensys is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 12 stevensys User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 35 m 36 sec
Reputation Power: 0
Execute procedure

hi guys,

i have some problem here, below is my procedure and some how it won't insert when ever i run it. i can't find any problems with the coding, so hopefully you guys would help me out.

Code:
create or replace procedure insertinstructor(v_salary number, date_hired varchar2, v_insructid number, v_instrucname varchar2, v_commission number, v_mentorid number) is


  v_mentor_id instructor.mentor_id%TYPE;
  mentee_count pls_integer := 0;
  mentor_salary instructor.salary%TYPE;
  mentor_hired_date date;  
begin
if (v_mentor_id is not null ) then
      select count(*) into mentee_count from instructor where mentor_id = v_mentor_id;
if (mentee_count != 0 ) then
       select salary, date_hired into mentor_salary, mentor_hired_date from instructor where instructor_id = v_mentor_id;
  if mentor_salary <= 3500 AND MONTHS_BETWEEN(SYSDATE, to_date(mentor_hired_date,'dd-mon-yyyy') ) / 12 <= 21
  THEN
    RAISE_APPLICATION_ERROR (-20501, 'Inserting Record Failure,Only instructor that work more than 21 years or salary more than 3500 can act as mentor');
  else
    insert into INSTRUCTOR (salary, DATE_HIRED,INSTRUCTOR_ID,INSTRUCTOR_NAME, COMMISSION, MENTOR_ID)
    values(v_salary,to_date(date_hired,'dd-mon-yyyy'),v_insructid, v_instrucname, v_commission, v_mentorid);
    commit;
  end if;
end if;
end if;
end;
/


i'm using this to execute the procedure

Code:
exec insertinstructor (1000,'24-Jun-1999',991,'MEN',200,453);


the procedure should raise an error message when i insert this value, but it just come out this message when i execute it.

Code:
SQL> @execinsert

PL/SQL procedure successfully completed.

Reply With Quote
  #2  
Old April 10th, 2005, 09:43 PM
wubandit99 wubandit99 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 30 wubandit99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 4
in one of your selects from instructor you are matching v_mentor_id to mentor_id. In the next you are matching v_mentor_id to instructor_id.... Is that your problem?

Reply With Quote
  #3  
Old April 10th, 2005, 10:21 PM
stevensys stevensys is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 12 stevensys User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 35 m 36 sec
Reputation Power: 0
i dont get what u mean there,

and yes i'm matching v_mentor_id to mentor_id and
v_mentor_id to instructor_id

Reply With Quote
  #4  
Old April 12th, 2005, 08:46 AM
wubandit99 wubandit99 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 30 wubandit99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 4
sorry about that... I see what you are doing now... It looks like the real issue is that the variable v_mentor_id is never getting set, so the procedure fails on the first if statement. The variable that is getting set when you call the procedure is v_mentorid (note the missing "_"). So you either need to remove your current v_mentor_id declaration and change v_mentorid parameter to v_mentor_id, or update your v_mentor_id declaration to be v_mentor_id instructor.mentor_id%TYPE := v_mentorid;, so v_mentor_id will have a value when your code gets to the first if statement.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Execute procedure


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT