473,581 Members | 2,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MySql 5.0 - Trigger with Bussiness Logic

40 New Member
Hai,

I would like to know if i can include bussiness logic in Trigger.

For Example:

On a insert/update on a table(primary) i want to insert values to other table(secondary ).

A insert is done on a primary table only when their are no records present w.r.t the id .If the id is present in the table an update action is performed.
I will have to check if the id is present or not.But not getting to know how to implement it in trigger.

Thank You,
Sindhu
Nov 24 '08 #1
1 2243
Atli
5,058 Recognized Expert Expert
Hi.

Triggers can not use dynamic SQL statements. You would have to use a procedure or a function to do this.

Note that you can not call procedures or functions that use dynamic SQL statements from a trigger either.

I would recommend simply adding a "AddUser" or "AddClient" procedure to your database that you would call rather than adding data using the INSERT statement.
That way you can add whatever logic you want before you insert anything.
Nov 26 '08 #2

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

Similar topics

6
2557
by: Neal | last post by:
I created a database that lets people post a job opening. I thought of manually removing each entry after 2 months, but is there some code that can do this without me having to monitor the table? Thanks.
8
8594
by: Jason | last post by:
I have a table that matches up Securities and Exchanges. Individual securities can belong on multiple exchanges. One of the columns, named PrimaryExchangeFlag, indicates if a particular exchange is the primary exchange for that symbol. Each symbol can only have one primary exchange. I am trying to write a insert/update/delete trigger that...
2
7177
by: Rigs | last post by:
Hi, I'm a SQL Server newbie, so I'd appreciate if someone would tell me if this is possible. I'm running SQL Server 2000 on Win2k Server I have one table with a large number of columns. I have two pieces of logic that I'd like to execute depending upon whether an insert or an update statement was executed on that table. I'd prefer this...
4
5852
by: Dave | last post by:
I have a MS sql 2000 db that needs to sync with a Mysql db. When a password is changed in the MS SQL table, I need to make sure that the same value is updated in the Mysql db. I dont have any control of the gui that is initiating this event. So, I was thinking a trigger might be an alternate route. I just dont know how to get the...
6
6543
by: Scott CM | last post by:
I have a multi-part question regarding trigger performance. First of all, is there performance gain from issuing the following within a trigger: SELECT PrimaryKeyColumn FROM INSERTED opposed to: SELECT * FROM INSERTED
4
3865
by: michael.kirby | last post by:
I have been reading up on triggers and I am still unclear as to the best way to accomplish the following: Each row in table A has an account number field. After insert of record 1 into table A, if the value of the acccount number exists in table B, I need to update that corresponding record in table B, otherwise I need to insert the record...
2
1432
by: James MA | last post by:
I'm going to build a project which contain the business logic only, and it should be device independent. And I'll have different program to build the UI in for different platform using the same library of business logic. I have created a solution to contain projects for different device (Windows and SmartDevice), however, I cannot cretae a...
1
28216
by: vijjibalu | last post by:
Hi all, as part of my project requirement we are migrating procedures from mssql to mysql below is the code in mssql DECLARE "@rowcnt" int select"@rowcnt" = count(*) from tg_services WHERE name ="@name" IF (@rowcnt <> 0) BEGIN -- print"@name" + ' already exists in the tg_services table'
0
4422
by: silversubey | last post by:
I am trying to convert mssql triggers to mysql. I am very new to Mysql and would like some help with my code. My queries work but there has to be a more efficient way to write them. I would greatly appreciate any help. the following is a trigger that works until I add the last update statement. thanks for the help. Mysql 5 delimiter //...
0
7882
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8312
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5683
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1410
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1145
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.