My problem is for triggers in mysql
i will give u an example of that:, what i have made & problem is occured my trigger is like this;
Expand|Select|Wrap|Line Numbers
- DELIMITER |
- CREATE TRIGGER testcdr BEFORE INSERT ON cdr
- FOR EACH ROW
- BEGIN
- declare norows int default 0;
- declare nolen int default 1;
- declare numstr,numstring int default 0;
- if new.Flag='1' Then
- set NEW.Chargable_Min=CEIL(NEW.Usage_Sec / 60);
- set numstr = SUBSTRING(NEW.Called_No,1,((LENGTH(New.Called_No))- 3));
- while((norows < 1) and (nolen > 0)) do
- set numstring:=SUBSTRING(numstr,1,((LENGTH(numstr)) -1));
- set NEW.Country:=select Country from ratedetails where (Code=numstring) and Card_Type=(select Account_Type from customerdetails where Uid=new.Uid);
- set norows := LENGTH(numstr);
- set nolen := LENGTH(numstring);
- end while;
- set NEW.Country=(select Country from ratedetails where (Code=numstring) and Card_Type=(select Account_Type from customerdetails where Uid=new.Uid));
- END IF;
- END;
- |
- DELIMITER ;
i want that in cdr table i have a one field like Called_No ,
ex: 1452668989 now i have to do remove last 3 digit ok that i have done
means now no will be :1452668 - up to this ok
Now in Ratedetails table , fiels are like Country,Code etc. ok
now in code which has no of code likes 1,14,1452 ok which i have to match with 1452668 ok if max length of match is find then norows set 1 & then new.Country is Execute . after result comes..
So please as soon as possible give reply..