INSERT with dynamic table name in trigger function

Modern PostgreSQL format() has a built-in way to escape identifiers. Simpler than before: CREATE OR REPLACE FUNCTION foo_before() RETURNS trigger LANGUAGE plpgsql AS $func$ BEGIN EXECUTE format(‘INSERT INTO %I.%I SELECT $1.*’ , TG_TABLE_SCHEMA, TG_TABLE_NAME || ‘shadow’) USING OLD; RETURN OLD; END $func$; Works with a VALUES expression as well. db<>fiddle here Old sqlfiddle Major points … Read more

Trigger to fire only if a condition is met in SQL Server

Given that a WHERE clause did not work, maybe this will: CREATE TRIGGER [dbo].[SystemParameterInsertUpdate] ON [dbo].[SystemParameter] FOR INSERT, UPDATE AS BEGIN SET NOCOUNT ON If (SELECT Attribute FROM INSERTED) LIKE ‘NoHist_%’ Begin Return End INSERT INTO SystemParameterHistory ( Attribute, ParameterValue, ParameterDescription, ChangeDate ) SELECT Attribute, ParameterValue, ParameterDescription, ChangeDate FROM Inserted AS I END

jquery trigger function when element is in viewport

jQuery Waypoints plugin http://imakewebthings.github.com/jquery-waypoints/ should do the trick UPDATE <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”utf-8″> <title>jQuery Waypoints Plugin – Test</title> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js” type=”text/javascript”></script> <script src=”http://imakewebthings.github.com/jquery-waypoints/waypoints.min.js” type=”text/javascript”></script> <style type=”text/css”> #mydiv {background-color:#FF0000; margin:1500px 0;} </style> </head> <body> <div id=”mydiv”> Content goes here </div> <script type=”text/javascript”> $(function() { $(‘#mydiv’).waypoint(function() { window.location.href=”http://google.com”; }, { offset: ‘100%’ }); }); … Read more

How to detect a long press on a div in Jquery?

Add a throttle that only allows the click to happen after 2 seconds of mousedown. var timer; $(‘div’).on(“mousedown”,function(){ timer = setTimeout(function(){ alert(“WORKY”); },2*1000); }).on(“mouseup mouseleave”,function(){ clearTimeout(timer); }); Edit: I added mouseleave too since if the mouse leaves the element and then triggers mouseup, it won’t stop the timer.

mysql after insert trigger which updates another table’s column

Try this: DELIMITER $$ CREATE TRIGGER occupy_trig AFTER INSERT ON `OccupiedRoom` FOR EACH ROW begin DECLARE id_exists Boolean; — Check BookingRequest table SELECT 1 INTO @id_exists FROM BookingRequest WHERE BookingRequest.idRequest= NEW.idRequest; IF @id_exists = 1 THEN UPDATE BookingRequest SET status=”1″ WHERE idRequest = NEW.idRequest; END IF; END; $$ DELIMITER ;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)