File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Oracle/OAS and the fly likes trigger for removing prepended zeros Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Reply Bookmark "trigger for removing prepended zeros" Watch "trigger for removing prepended zeros" New topic
Author

trigger for removing prepended zeros

Chhaya Dhanani
Ranch Hand

Joined: Apr 11, 2001
Posts: 70
hi al,
i need to write a trigger whicj will remove prepnding zeros froma values before insert or update
i need this on urgent basis
eg. 000123 should be entered as 123 in the amount colmun of payments table on insert as well as update
Can anyone help me with the trigger.
THIS IS AN SOS!!
thanx in advance
Chhaya
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16624

What about just using to_number() function. Can any of your values have Alpha characters?
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Beksy Kurian
Ranch Hand

Joined: Jul 11, 2001
Posts: 254
The NUMBER data type will ignore all leading zero. If you really have to use varchar, then you can(another solution is to use 'round' function) use 'fm' in the format mask to remove the leading zeros or spaces
For eg:
zerotest table with two columns (Name varchar2(10),amount varchar2(5))
insert into zerotest values('chhaya',to_char('00234','fm99999'));

Regards
Beksy
[ August 21, 2002: Message edited by: Beksy Kurian ]
Chhaya Dhanani
Ranch Hand

Joined: Apr 11, 2001
Posts: 70
Thanx both of you..
Chhaya
 
 
subject: trigger for removing prepended zeros
 
Threads others viewed
How to call trigger from java?
Informix database
After insert statement, how do I get column value populated by DB trigger
modifing data when Trigger fires
inserting data into two tables simultaniously
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture