944,183 Members | Top Members by Rank

Ad:
  • Oracle Discussion Thread
  • Unsolved
  • Views: 1327
  • Oracle RSS
Oct 13th, 2009
0

trigger help pls....!!!!

Expand Post »
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) );

Oracle Syntax (Toggle Plain Text)
  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;
Similar Threads
Reputation Points: 9
Solved Threads: 0
Light Poster
john_beginner is offline Offline
42 posts
since Mar 2009
Oct 13th, 2009
0
Re: trigger help pls....!!!!
Try using select into

sql Syntax (Toggle Plain Text)
  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.
Reputation Points: 91
Solved Threads: 18
Junior Poster
cgyrob is offline Offline
125 posts
since Sep 2008
Oct 14th, 2009
0
Re: trigger help pls....!!!!
Click to Expand / Collapse  Quote originally posted by cgyrob ...
Try using select into

sql Syntax (Toggle Plain Text)
  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 !!!
Reputation Points: 9
Solved Threads: 0
Light Poster
john_beginner is offline Offline
42 posts
since Mar 2009
Oct 14th, 2009
0
Re: trigger help pls....!!!!
Really not sure why upper() is not working for you.

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

sql Syntax (Toggle Plain Text)
  1. INSERT INTO stu VALUES(sno1,UPPER(sname1),class1);
Reputation Points: 91
Solved Threads: 18
Junior Poster
cgyrob is offline Offline
125 posts
since Sep 2008
Oct 14th, 2009
0
Re: trigger help pls....!!!!
i have try this code also but i don't know y it's not working

( i am using oracle 8i )
Reputation Points: 9
Solved Threads: 0
Light Poster
john_beginner is offline Offline
42 posts
since Mar 2009
Oct 14th, 2009
0
Re: trigger help pls....!!!!
try assigning to a variable then select into

sql Syntax (Toggle Plain Text)
  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.
Reputation Points: 91
Solved Threads: 18
Junior Poster
cgyrob is offline Offline
125 posts
since Sep 2008
Oct 15th, 2009
0
Re: trigger help pls....!!!!
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 !!!
Reputation Points: 9
Solved Threads: 0
Light Poster
john_beginner is offline Offline
42 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Oracle Forum Timeline: subtract 2 column value
Next Thread in Oracle Forum Timeline: INSERT sql statement for DateTime





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC