triggers

SQL Server Trigger that works - fires just once

与世无争的帅哥 提交于 2019-12-24 06:29:06
问题 I want to do some calculations when my table data is changed. However, I am updating my table manually and copy pasting about 3000 rows in once. That makes my trigger work 3000 times, but I want it to do the trigger only once. Is there a way to do that ? Thanks. 回答1: If by 'manually' you mean you are copying and pasting into some User Interface tool (like an Access dataGrid) or something like that, then the tool may be issuing one insert statement per row, and in that case you are out of luck

How to change the push button label text and add a new functionality in runtime? Oracle Forms

谁说我不能喝 提交于 2019-12-24 05:56:25
问题 I'm learning Oracle Forms and Reports, This time I would like to coding within a push button some functionalities. I've added a push button named "Filter" for active the "enter_query" mode to add some search criteria using "WHEN-BUTTON-PRESSED" trigger in item level and adding code within this trigger. It's too easy to code: BEGIN ENTER_QUERY; END; But now, I have to add two new functionalities to this button: 1- First, When I write some search criteria and after push in the second button

Syntax exception on trigger with multiple statements with MySQL and JDBC

[亡魂溺海] 提交于 2019-12-24 05:43:05
问题 I am trying to create a trigger that performs multiple operations in MySQL 5.5.28 with InnoDB. I have two tables, "test" and "test_watcher": changes to the first are recorded in the watcher table with the help of triggers. The last trigger needs to perform 2 operations on DELETE , it works in MySQL Workbench (with DELIMITER ) but doesn't if I create it with JDBC. CREATE TRIGGER `AD_test_FER` AFTER DELETE ON `test` FOR EACH ROW BEGIN -- if it's been inserted, modified and deleted but never

onOpen trigger for view-only users

放肆的年华 提交于 2019-12-24 05:26:06
问题 The built-in onOpen trigger in Google Apps Script only runs when a user with permission to edit opens a spreadsheet or document. I am developing a spreadsheet where only developers have edit privileges and all other users must have view-only privileges. How do I create an onOpen trigger that fires when view-only users open my spreadsheet as well as those with edit privileges? 回答1: You can't, because it's not supported. Google Apps Script, embedded in either Google Sheets, Docs, Forms, and as

Replace double quotes with single quotes in Postgres (plpgsql)

荒凉一梦 提交于 2019-12-24 04:57:09
问题 I am building a trigger function in plpgsql for my partitioned table and I've got all of my logic working, but am having trouble inserting the actual record into my table. I have to reference my specific table by a variable reference, so that (as far as I understand) forces me to use an EXECUTE command, as so: EXECUTE 'INSERT INTO ' || tablename || ' VALUES ' || NEW.*; However, this does not handle unpacking the record stored in NEW in a way that Postgres' INSERT function can understand. It

Why am I unable to create a trigger using my SqlCommand?

可紊 提交于 2019-12-24 02:45:10
问题 The line cmd.ExecuteNonQuery(); cmd.CommandText CREATE TRIGGER subscription_trig_0 ON subscription AFTER INSERT AS UPDATE user_data SET msg_count=msg_count+1 FROM user_data JOIN INSERTED ON user_data.id = INSERTED.recipient; The exception: Incorrect syntax near the keyword 'TRIGGER'. Then using VS 2010, connected to the very same file (a mdf file) I run the query above and I get a success message. WTF! 回答1: Do you have CommandType set wrong? 回答2: Options The 1st line of the actual SQL sent is

multiple triggers with the same action time and event for one table mysql error

断了今生、忘了曾经 提交于 2019-12-24 02:32:21
问题 I'm new to triggers and am getting "multiple triggers with the same action time and event for one table" error. I have created an AFTER Update and an AFTER Delete which are two separate action time/events so I am not really sure why I would be getting the error. Here is my query: CREATE TRIGGER `new_enrolment` AFTER INSERT ON `mdl_user_enrolments` FOR EACH ROW BEGIN INSERT INTO c_master ( ud, firstname, lastname, email, username, cid, course ) SELECT mdl_user.id AS uid, mdl_user.firstname,

How to trigger ServiceNow workflow from ui action?

∥☆過路亽.° 提交于 2019-12-24 02:18:06
问题 I am getting started with workflows in ServiceNow. I can see that the trigger for at workflow is based on conditions. But can a workflow be triggered by some sort of user action, i.e. a UI Action/button or through a script? 回答1: There's a Workflow object accessible server side that you can use to start a workflow that's documented here. Here's an example from that wiki article: // where current is a task record with a workflow context var w = new Workflow(); var context = w.startFlow(id,

Allow insertion only from within a trigger

自古美人都是妖i 提交于 2019-12-24 02:09:05
问题 I'm new to SQL programming, and I couldn't find an answer to this question online. I'm working with pl/pgsql and I wish to achieve the following result: I have a table A with certain attributes. I am supposed to keep this table updated at any time - thus whenever a change was made that can affect A's values (in other tables B or C which are related to A) - a trigger is fired which updates the values (in the process - new values can be inserted into A, as well as old values can be deleted). At

Conditional CASCADE operation for foreign key constraint?

好久不见. 提交于 2019-12-24 01:54:43
问题 I have parent and child table where child has a FK pointing to the PK of parent table. When I delete something in parent table I can have child records deleted as well by having ON DELETE CASCADE . However, in my parent table I don't delete records at all. Instead I set the column state = "passive" . I want to delete related entries in the child table. Do we have something like a "conditional CASCADE" in Postgres? Or is the solution to manually delete entries in the child table? 回答1: You