hello Everyone,
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;[code=sql]DELIMITER |
CREATE TRIGGER testcdr BEFORE INSERT ON cdr
FOR EACH ROW
BEGIN
declare norows int default 0;
declare nolen int default 1;
declare numstr,numstrin g int default 0;
if new.Flag='1' Then
set NEW.Chargable_M in=CEIL(NEW.Usa ge_Sec / 60);
set numstr = SUBSTRING(NEW.C alled_No,1,((LE NGTH(New.Called _No))- 3));
while((norows < 1) and (nolen > 0)) do
set numstring:=SUBS TRING(numstr,1, ((LENGTH(numstr )) -1));
set NEW.Country:=se lect Country from ratedetails where (Code=numstring ) and Card_Type=(sele ct Account_Type from customerdetails where Uid=new.Uid);
set norows := LENGTH(numstr);
set nolen := LENGTH(numstrin g);
end while;
set NEW.Country=(se lect Country from ratedetails where (Code=numstring ) and Card_Type=(sele ct Account_Type from customerdetails where Uid=new.Uid));
END IF;
END;
|
DELIMITER ;[/code]
Here IN this trigger which create problem in while loop .
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..
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;[code=sql]DELIMITER |
CREATE TRIGGER testcdr BEFORE INSERT ON cdr
FOR EACH ROW
BEGIN
declare norows int default 0;
declare nolen int default 1;
declare numstr,numstrin g int default 0;
if new.Flag='1' Then
set NEW.Chargable_M in=CEIL(NEW.Usa ge_Sec / 60);
set numstr = SUBSTRING(NEW.C alled_No,1,((LE NGTH(New.Called _No))- 3));
while((norows < 1) and (nolen > 0)) do
set numstring:=SUBS TRING(numstr,1, ((LENGTH(numstr )) -1));
set NEW.Country:=se lect Country from ratedetails where (Code=numstring ) and Card_Type=(sele ct Account_Type from customerdetails where Uid=new.Uid);
set norows := LENGTH(numstr);
set nolen := LENGTH(numstrin g);
end while;
set NEW.Country=(se lect Country from ratedetails where (Code=numstring ) and Card_Type=(sele ct Account_Type from customerdetails where Uid=new.Uid));
END IF;
END;
|
DELIMITER ;[/code]
Here IN this trigger which create problem in while loop .
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..
Comment