Tag Info

New answers tagged

0

You can (pick one) Create a view and build on it the trigger with INSTEAD OF. Then you mae insert on the view, not on the table (you can have a trigger on the table raising an error if you want to be sure). Do not make direct insert. Call a stored procedure and move logic there More on trigger and where they can be applied here: ...


2

I'm not sure if this code is fully accurate for columns that have more than 1 row with the same value, but I suppose that's a different subject. What I see is that the only value the null counter is ever initialized to is 0. That means it will never have an effect on the addition. Putting on my dev hat, I could see the start of an unfinished concept. If ...


6

Foreign key constraints are currently implemented with special internal triggers. All of them are run FOR EACH ROW. Note that these are implementation details that can change, so don't rely on it. But the basics have not changed over the last couple of major versions, so major changes are unlikely. I ran a quick test with a simple FK constraint from tbl to ...


4

It does execute N times, and the easiest way to see this is to execute the statement with an EXPLAIN ANALYZE prepended, i. e. EXPLAIN ANALYZE UPDATE a SET col = 1 WHERE othercol = 'foo'; This will give you information similar to this: Trigger for constraint t_col_fk on a: time=1.300 calls=9 (tested with 9.2)


1

Create a linked server connection with read access from Server B to Server A. Have a process running on Server B that does the following: Examine the table on ServerB to identity the last inserted record from Server A. Hopefully you have an auto-incrementing primary key (int). If not, look for the greatest "last updated timestamp". Connect to Server A ...


0

I have create following Procedure which goes thru all SP and Views in particular DB (can be extend to Functions, ...) and store each code script one by one into TXT files. Tested ON MS SQL 2008 R2 and 2014 First part Inserting all scripts of SP and Views into Temp table. Then later using BCP utility. If you wish you can can use for export SSIS package and ...


2

You want current_setting: SELECT current_setting('pubsubpull.request_id');


0

I suggest that using a VIEW is the wrong starting point, and that TRIGGERs are just adding complication. Instead of using Views and Triggers, have a "database layer" that segregates the Application code from the Database. The layer could be written as subroutines in your programming language or as Stored Routines in MySQL. The application would ask the ...


2

Thats correct you can not update the same table where the trigger is getting executed, however if you use before update you can set the st to 0 by checking the conditions something as DELIMITER $$ USE `smsdev`$$ DROP TRIGGER /*!50032 IF EXISTS */ `pageprivilege_update`$$ CREATE /*!50017 DEFINER = 'smsdev'@'%' */ TRIGGER `pageprivilege_update` ...


0

Don't use a TRIGGER. Instead, gather a minute's worth (say) of data in a staging table. Then do the desired updates en masse. If you need the user to get up-to-the-second information (instead of just up-to-the-minute), have the user's query do that final update also. To phrase it differently, summarization is much more efficiently done in bulk. Your ...


0

You have an InnoDB without an explicit PRIMARY KEY. This is a no-no. On each INSERT, 12 BTrees must be updated -- 1 for the data, 11 more for the indexes. What is the value of innodb_buffer_pool_size? It should be about 70% of available RAM. If it is sitting at some low value, the lack of caching is killing performance. SELECT count(alarm.AlarmType) ...



Top 50 recent answers are included