trigger help pls....!!!!

Reply

Join Date: Mar 2009
Posts: 27
Reputation: john_beginner is an unknown quantity at this point 
Solved Threads: 0
john_beginner john_beginner is offline Offline
Light Poster

trigger help pls....!!!!

 
0
  #1
Oct 13th, 2009
hello ,

(begginer of SQL)
i have to make one pro. in which

i have to use trigger which will fire before inserting into table

and convert the name into upper case but i don't what is the prob.

with the code pls provide ur suggetion

my table attributes are
stu (sno number(6),sname varchar(12),class varchar(12) );

  1. CREATE OR REPLACE TRIGGER trg27
  2.  
  3. before INSERT ON stu
  4.  
  5. FOR each ROW
  6.  
  7. DECLARE
  8.  
  9. sname1 stu.sname%TYPE;
  10. sno1 stu.sno%TYPE;
  11. class1 stu.class%TYPE;
  12.  
  13.  
  14. BEGIN
  15.  
  16. sno1:=:NEW.sno;
  17. sname1:=:NEW.sname;
  18. sname1:=UPPER(sname1);
  19. class1:=:NEW.class;
  20.  
  21.  
  22. EXCEPTION
  23.  
  24. WHEN OTHERS THEN
  25.  
  26. dbms_output.put_line('Error is occured..!!');
  27.  
  28.  
  29.  
  30. INSERT INTO stu VALUES(sno1,sname1,class1);
  31.  
  32.  
  33. END;
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 119
Reputation: cgyrob is on a distinguished road 
Solved Threads: 18
cgyrob's Avatar
cgyrob cgyrob is offline Offline
Junior Poster
 
0
  #2
Oct 13th, 2009
Try using select into

  1. SELECT :NEW.sno, UPPER(:NEW.sname), :NEW.class
  2. INTO sno1, sname1, class1 FROM dual;
Last edited by cgyrob; Oct 13th, 2009 at 6:39 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 27
Reputation: john_beginner is an unknown quantity at this point 
Solved Threads: 0
john_beginner john_beginner is offline Offline
Light Poster
 
0
  #3
Oct 14th, 2009
Originally Posted by cgyrob View Post
Try using select into

  1. SELECT :NEW.sno, UPPER(:NEW.sname), :NEW.class
  2. INTO sno1, sname1, class1 FROM dual;

my query is , it's not convert the lower case into upper case

i have tried this code also but still the result is same !!!
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 119
Reputation: cgyrob is on a distinguished road 
Solved Threads: 18
cgyrob's Avatar
cgyrob cgyrob is offline Offline
Junior Poster
 
0
  #4
Oct 14th, 2009
Really not sure why upper() is not working for you.

Maybe trying using the upper() function on the insert.

  1. INSERT INTO stu VALUES(sno1,UPPER(sname1),class1);
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 27
Reputation: john_beginner is an unknown quantity at this point 
Solved Threads: 0
john_beginner john_beginner is offline Offline
Light Poster
 
0
  #5
Oct 14th, 2009
i have try this code also but i don't know y it's not working

( i am using oracle 8i )
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 119
Reputation: cgyrob is on a distinguished road 
Solved Threads: 18
cgyrob's Avatar
cgyrob cgyrob is offline Offline
Junior Poster
 
0
  #6
Oct 14th, 2009
try assigning to a variable then select into

  1. sname1 stu.sname%TYPE;
  2.  
  3. sname1:= :new.sname
  4.  
  5. SELECT :NEW.sno, UPPER('sname1'), :NEW.class
  6. INTO sno1, sname1, class1 FROM dual;
Last edited by cgyrob; Oct 14th, 2009 at 11:06 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 27
Reputation: john_beginner is an unknown quantity at this point 
Solved Threads: 0
john_beginner john_beginner is offline Offline
Light Poster
 
0
  #7
Oct 15th, 2009
i have tried above code also but still the result is same, anyways

thanx for u r help bt i have tried some other code

n my query is solved nw !!!
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the Oracle Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC