473,403 Members | 2,222 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,403 software developers and data experts.

MySql 5.0 - Trigger with Bussiness Logic

40
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 2234
Atli
5,058 Expert 4TB
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
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?...
8
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...
2
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...
4
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...
6
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...
4
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,...
2
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...
1
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.