triggers

Retrieve username inside a trigger function

一个人想着一个人 提交于 2019-12-23 16:34:06
问题 In our database we have a login table featuring coloumns username and password . How can this username be retrieved inside a trigger function so that it can also be audited. user keyword inside the trigger function retrieves the postgresql username, what I need is the application username. Any suggestions? 回答1: You can set a custom GUC up in postgresql.conf . Use it to store the application username at login using SET myapp_username . Access that in triggers with current_setting(myapp

firebase Cloud function transaction working sporadically

一笑奈何 提交于 2019-12-23 16:12:03
问题 I have the cloud function like so: exports.updateNewsCount = functions.database.ref('/channels/{channelId}/news/{newsId}/') .onWrite (event => { const channelId = event.params.channelId; const newsId = event.params.newsId; let CntRef = admin.database().ref('/channelDetails/' + channelId + '/newsCnt'); if (event.data.exists() && !event.data.previous.exists()){ return CntRef.transaction(function(current){ if (current){ console.log ('current is not null'); return (current || 0) + 1; } else {

WPF: Activate Trigger when a MVVM bound property changes

霸气de小男生 提交于 2019-12-23 16:09:30
问题 somehow I am going in circles here. Please forgive me if the answer to this question is obvious. I want to react to changed properties in the ViewModel in the View. When the properties (bool) change the View should start an animation (BeginStoryBoard). Actually in my application there are 4 of these properties each with its own name in the VM and two desired animations each (hide/show) for the respective 4 container view elements. When setting these Triggers (tried DataTrigger/Trigger

SQL Server : DDL trigger, controlling table creation

风格不统一 提交于 2019-12-23 15:15:58
问题 I'm using SQL Server 2008. I'm creating a DDL trigger like this: CREATE TRIGGER tName ON database FOR CREATE_TABLE as print 'A table has been created' Can I get that table that has been created !? Something like inserted or deleted in the normal table triggers ?! 回答1: Try this: CREATE TRIGGER TRG_TABLES ON DATABASE AFTER CREATE_TABLE AS BEGIN SET NOCOUNT ON DECLARE @TABLE_NAME SYSNAME SELECT @TABLE_NAME = EVENTDATA().value('(/EVENT_INSTANCE/ObjectName)[1]','SYSNAME') ... END GO 回答2: I believe

SQL Server trigger execution in batch updating

寵の児 提交于 2019-12-23 13:19:06
问题 I need to know about how the trigger execution happens for the below scenario. I have 20 records in a table and I have an AFTER INSERT, UPDATE trigger on that table. When I'm updating all the records in that table using a MERGE or batch update statement, how will the trigger execute? Does it execute for each row by row? Or is it executing once per a batch (once for all 20 records)? If it is execute once per batch do we need to write a loop inside the trigger to perform a task for each row?

SQL Server 2008 MERGE statement - how to disable INSTEAD OF INSERT trigger to allow the MERGE

大兔子大兔子 提交于 2019-12-23 12:27:03
问题 I am attempting to use the SQL SERVER 2008 MERGE statement in a stored procedure for updating/inserting a table. I have an INSTEAD OF INSERT trigger on the table, and I get the following error message when attempting to CREATE the procedure The target 'Phone' of the MERGE statement has an INSTEAD OF trigger on some, but not all, of the actions specified in the MERGE statement. In a MERGE statement, if any action has an enabled INSTEAD OF trigger on the target, then all actions must have

How to emulate a BEFORE DELETE trigger in SQL Server 2005

主宰稳场 提交于 2019-12-23 12:16:39
问题 Let's say I have three tables, [ONE], [ONE_TWO], and [TWO]. [ONE_TWO] is a many-to-many join table with only [ONE_ID and [TWO_ID] columns. There are foreign keys set up to link [ONE] to [ONE_TWO] and [TWO] to [ONE_TWO]. The FKs use the ON DELETE CASCADE option so that if either a [ONE] or [TWO] record is deleted, the associated [ONE_TWO] records will be automatically deleted as well. I want to have a trigger on the [TWO] table such that when a [TWO] record is deleted, it executes a stored

PostgreSQL/JPA - Import functions in import.sql file?

独自空忆成欢 提交于 2019-12-23 12:11:15
问题 I'm trying to define some PostgreSQL functions and triggers in my JPA import.sql file. I'm using Hibernate 5.x as my underlying JPA provider. Since my import.sql file has commands that are multiple lines, I've got this property set in my persistence.xml file: <property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" /> From there, I'm trying to define my functions in import.sql . They look something like this: DROP

Triggering a drop event with jQuery droppables

荒凉一梦 提交于 2019-12-23 11:44:13
问题 Variations of this question have been asked, but the answers are all different, somewhat dated, and aren't working for me so I'm hoping it's a matter of changed syntax rules in jQuery that I'm missing. The scenario HTML: <div id="theDroppable">Droppable</div> <div id="theDraggable">Draggable</div> <div id="theTrigger">Click to trigger a drop</div> The jQuery: $( "#theDroppable" ) .droppable({ drop: function( event, ui ) { alert('dropped'); } }); $( "#theDraggable" ).draggable({}); $( "

Serial numbers, created and modified in SQL Server

微笑、不失礼 提交于 2019-12-23 10:10:01
问题 I'm needing to add serial numbers to most of the entities in my application because I'm going to be running a Lucene search index side-by-side. Rather than having to run an ongoing polling process, or manually run my indexer by my application I'm thinking of the following: Add a Created column with a default value of GETUTCDATE() . Add a Modified column with a default value of GETUTCDATE() . Add an ON UPDATE trigger to the table that updates Modified to GETUTCDATE() (can this happen as the