473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Help in triggers

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;
Expand|Select|Wrap|Line Numbers
  1. DELIMITER |
  2. CREATE TRIGGER testcdr BEFORE INSERT ON cdr
  3.   FOR EACH ROW 
  4.  BEGIN        
  5.     declare norows int default 0;
  6.     declare nolen int default 1;
  7.     declare numstr,numstring int default 0;
  8. if new.Flag='1' Then
  9.     set NEW.Chargable_Min=CEIL(NEW.Usage_Sec / 60);    
  10.     set numstr = SUBSTRING(NEW.Called_No,1,((LENGTH(New.Called_No))- 3));
  11.     while((norows < 1) and (nolen > 0)) do    
  12.         set numstring:=SUBSTRING(numstr,1,((LENGTH(numstr)) -1));
  13.     set NEW.Country:=select Country from ratedetails where (Code=numstring) and Card_Type=(select Account_Type from customerdetails where Uid=new.Uid);
  14.     set norows := LENGTH(numstr);
  15.     set nolen  := LENGTH(numstring);
  16.     end while;
  17.     set NEW.Country=(select Country from ratedetails where (Code=numstring) and Card_Type=(select Account_Type from customerdetails where Uid=new.Uid));
  18.     END IF;
  19. END;
  20. |
  21. DELIMITER ;
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..
Apr 5 '08 #1
1 1179
ronverdonk
4,258 Expert 4TB
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Apr 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mark Flippin | last post by:
I'm just starting to use triggers in my databases and find the support in Enterpise Manager lacking. Using Enterprise Manager and Query Analyzer you can maintain the triggers, but it's...
11
by: William Payne | last post by:
Ok, in my program I have a std::list<Document*>, where Document is one of my own classes. I need to go through this list and check each item if it's ready for deletion. If it's not, skip to...
1
by: tim.pascoe | last post by:
I'm trying to generate scrips for a database, and everything so far has worked fine, except for the triggers. When I try and script existing triggers, all I get is a blank file - no SQL script. I...
4
by: stacdab | last post by:
We have a partitioned view with 4 underlying tables. The view and each of the underlying tables are in seperate databases on the same server. Inserts and deletes on the view work fine. We then...
4
by: SUKRU | last post by:
Hello everybody. Unfortunately I am pretty new to sql-server 2000 I need some help with a Trigger I created. I created a trigger witch takes the id of the affected row and does a update on a...
1
by: nDaKota | last post by:
I am current converting PowerBuilder to C#. Now I'm having problem on triggers. I understand what a triggers does. The problem is what happens if a trigger is being triggered? Example: I execute a...
0
debasisdas
by: debasisdas | last post by:
trigger sample code Ex#10 ======================= INSTEAD OF TRIGGER ---------------------------------------- create or replace trigger mytrig instead of delete or insert or update on eview...
3
by: jenipriya | last post by:
Tables ------------ Employee (EmpID, EmpName,DeptID DateOfJoin, Sal, Addr) Finance (EmpID, Sal) Club (Clubname, EmpID, Fee, DateOfJoin) Leave (EmpID, Date) Department (DeptID, DeptName,...
0
debasisdas
by: debasisdas | last post by:
This thread contains some useful tips/sample codes regarding TRIGGERS in oracle, that the forum members may find useful. TRIGGERS: =============== Database trigger is a PL/SQL block that is...
4
by: --CELKO-- | last post by:
I need to convert a bunch of DB2 triggers to Oracle. Is there any kind of tools for this?
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.