triggers

Help with SQL Server Trigger to truncate bad data before insert

大憨熊 提交于 2019-12-23 19:31:48
问题 We consume a web service that decided to alter the max length of a field from 255. We have a legacy vendor table on our end that is still capped at 255. We are hoping to use a trigger to address this issue temporarily until we can implement a more business-friendly solution in our next iteration. Here's what I started with: CREATE TRIGGER [mySchema].[TruncDescription] ON [mySchema].[myTable] INSTEAD OF INSERT AS BEGIN SET NOCOUNT ON; INSERT INTO [mySchema].[myTable] SELECT SubType, type,

SQL Server: Can I use EXEC to run an external Application?

a 夏天 提交于 2019-12-23 19:27:00
问题 Hello and thank you for your time, I have been searching everywhere online for an example, where a SQL trigger will run an external application, but I have had no luck. All I am seeing is that the EXEC will execute a SQL procedure. The reason I need this is, I have a SQL Server 2010 with many tables and when an update or insert occurs on certain tables I need my Talend job to run and update the Salesforce tables. Currently the Talend jobs are running through A task scheduler but the company

Jquery - Simulating click button doesn't trigger function

大城市里の小女人 提交于 2019-12-23 19:24:30
问题 Ok, So I have been using firebug and also some extensions I wrote to create shortcuts on website I use often. There's on thing that I don't understand why it doesn't work or why it's not possible: Example code: <input type="button" onclick="addNewRow()" id="addRow"/> //This will add a new row to the current table. //The function is defined by the website (not my function) When using firebug: jQuery("#addRow").click(); //This will simulate the button click, and will automatically add the new

How do I exit a series of If / else conditions in a mysql trigger?

雨燕双飞 提交于 2019-12-23 19:22:49
问题 I have a trigger that checks to see if certain fields changed during the update. If any of these fields changed I update another table. I'd like to "break" out of the if conditions as soon as I know that something changed. Is there a way to do this within a MySQL Trigger? What I have works, but It seems inefficient. CREATE TRIGGER profile_trigger BEFORE UPDATE ON profile FOR EACH ROW BEGIN DECLARE changed INTEGER; SET changed = 0; IF STRCMP(NEW.first_name, OLD.first_name) <> 0 THEN SET

MySQL `BEFORE INSERT TRIGGER` how can I skip data insertion under condition? [duplicate]

陌路散爱 提交于 2019-12-23 19:22:16
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: MySQL Trigger to prevent INSERT under certain conditions In MySQL BEFORE INSERT TRIGGER how can I skip data insertion under condition? delimiter // drop trigger if exists test_trigger // create trigger test_trigger before insert on t for each row begin set @found := false; #Some code if @found then #How to skip the data insertion under condition? end if; end // delimiter ; 回答1: Two solutions, both raise an error

Can I have an MySQL database auto-assign a value to a column after an insert statement?

人走茶凉 提交于 2019-12-23 18:31:42
问题 Given a table employee with columns ID(pk) and name ID|name --+----- 1 |John 2 |James 3 |Tom Can I do INSERT INTO employee (name) VALUES (Jack); and somehow have the database auto assign the next available ID? Can a trigger do it? If so, how? 回答1: Create your table with an identity autoincrement column: CREATE TABLE table_name ( id INTEGER AUTO_INCREMENT PRIMARY KEY, -- other columns to follow ) 回答2: You want auto increment column. You can refer to the documentation here: http://dev.mysql.com

employee id automatic generate with prefix

╄→尐↘猪︶ㄣ 提交于 2019-12-23 18:31:08
问题 i am so confuse i want employee id is automatic generate with prefix format i know that is possible from before trigger in sql server i am follow the post http://www.aspdotnet-suresh.com/2012/04/set-custom-auto-generatedincrement.html USE [test1] GO /****** Object: Table [dbo].[Users] Script Date: 03/08/2013 12:28:08 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Users]( [UserId] [varchar](50) NOT NULL, [UserName] [varchar](50) NULL,

MYSQL Trigger set datetime value using case statement

不想你离开。 提交于 2019-12-23 17:43:28
问题 I'm using mysqlimport to do mass table inserts (replacing duplicates primary keys). Several tables have date time columns with records containing values '0000-00-00'. What I would like is a trigger which detects these '0000-00-00' values and replaces with '1950-01-01', otherwise keep the datetime value in the record (i.e. when it's not '0000-00-00'). I have tried the following: CREATE TRIGGER set_datetime BEFORE INSERT ON tbl FOR EACH ROW CASE WHEN date_col='0000-00-00' THEN SET date_col=

Triggers in oracle

帅比萌擦擦* 提交于 2019-12-23 17:30:10
问题 What are the condtions where triggers can enhance or hinder the performance? When to use and when not to use the triggers in the system? How triggers can be used to impose complex constraints? 回答1: Executing a trigger always has some overhead-- at a minimum, you are doing a context shift from the SQL engine to the PL/SQL engine for every row that causes the trigger to fire. While the absolute magnitude of the overhead of firing a trigger is relatively constant, the percentage overhead is

Get row to swap tables on a certain condition

二次信任 提交于 2019-12-23 17:19:39
问题 I currently have a parent table: CREATE TABLE members ( member_id SERIAL NOT NULL, UNIQUE, PRIMARY KEY first_name varchar(20) last_name varchar(20) address address (composite type) contact_numbers varchar(11)[3] date_joined date type varchar(5) ); and two related tables: CREATE TABLE basic_member ( activities varchar[3]) INHERITS (members) ); CREATE TABLE full_member ( activities varchar[]) INHERITS (members) ); If the type is full the details are entered to the full_member table or if type