triggers

Get the string of the query that fired a trigger

安稳与你 提交于 2021-02-20 04:26:07
问题 I am creating a control table in a PostgreSQL database, this table should register the query that fired a trigger in a specific table. For instance if I do insert into employees('bob'); I would like to be able to capture the string 'insert into employees('bob');' inside a trigger associated with employees table. It doesn't matter if the trigger is before or after. 回答1: Use the function current_query() in the trigger function. insert into control_table(query_text) select current_query(); The

Showing Trigger DBMS_OUTPUT.PUT_LINE in Oracle Apex

不打扰是莪最后的温柔 提交于 2021-02-19 08:57:05
问题 I have a trigger: CREATE OR REPLACE TRIGGER Med_Allergy_Warning BEFORE INSERT ON Prescription FOR EACH ROW BEGIN IF (Find_ADR(:NEW.Visit_ID, :NEW.Medication_ID) != 'GOOOO') THEN DBMS_OUTPUT.PUT_LINE('Medication ('||:NEW.Medication_ID||') May cause an allergic reaction… You are warned!'); ELSE DBMS_OUTPUT.PUT_LINE('Medication ('||:NEW.Medication_ID||') was prescribed successfully!'); END IF; END;/ That outputs a DBMS_OUTPUT.PUT_LINE whenever a user enters a prescription that may cause allergic

trigger for not inserting members doesnt work

情到浓时终转凉″ 提交于 2021-02-17 07:04:27
问题 I have this table CREATE TABLE members ( member_id INT PRIMARY KEY NOT NULL, first_name VARCHAR(20), last_name VARCHAR(20), web_page VARCHAR(200), e_mail VARCHAR(200), cv VARCHAR(800), dep_id INT, teacher_id INT ); and I want to create a trigger that if someone wants to insert a member which has a dep_id of 1 or 2 or 3 . And the teacher_id is different than NULL (as the teacher_id column is filled with either NULL or an id of another member) I came up with this CREATE TRIGGER employee_insup1

trigger for not inserting members doesnt work

廉价感情. 提交于 2021-02-17 07:04:09
问题 I have this table CREATE TABLE members ( member_id INT PRIMARY KEY NOT NULL, first_name VARCHAR(20), last_name VARCHAR(20), web_page VARCHAR(200), e_mail VARCHAR(200), cv VARCHAR(800), dep_id INT, teacher_id INT ); and I want to create a trigger that if someone wants to insert a member which has a dep_id of 1 or 2 or 3 . And the teacher_id is different than NULL (as the teacher_id column is filled with either NULL or an id of another member) I came up with this CREATE TRIGGER employee_insup1

trigger mysql unknown table

强颜欢笑 提交于 2021-02-17 06:34:25
问题 I've been trying to solve this problem. Here is the code: CREATE TRIGGER some_trigger AFTER UPDATE ON table_a FOR EACH ROW BEGIN DECLARE tname VARCHAR(20); IF (table_a.field_offer=1) THEN SET tname='table_b'; ELSEIF (table_a.field_offer=0) THEN SET tname='table_c'; END IF; IF ((new.field_state = 0)) THEN UPDATE tname join table_a on tname.ID=table_a.ref_field SET tname.STOCK = tname.STOCK -1; ELSEIF ((new.field_state = 1)) THEN UPDATE tname join table_a on tname.ID=table_a.ref_field SET tname

Hiding worksheets from specific users inside a spreadsheet

白昼怎懂夜的黑 提交于 2021-02-13 17:32:20
问题 Sorry I'm not familiar with coding, I have a spreadsheet with multiple worksheets, it's shared with many people, I'm trying to make those sheets hidden by defaults when it's shared with a new person, and define some users as an admin users, and user groups for each location, I could run the code, and it worked when it was shorter, I know there might be easiest ways, however do you beilive there is a speific reason I'm getting nothing running the code, and users still see the hidden sheets

Invalid object name [dbo].[TriggerName]

隐身守侯 提交于 2021-02-11 15:00:42
问题 I created a trigger named UPDATE_MERCHANDISE . The query completed with one error, a simple typo. I fixed the typo and changed the code to ALTER TRIGGER , but now when I try to execute it I receive the error Invalid object name [dbo].[UPDATE_MERCHANDISE] Why would it be valid when I created it, but not when I try to alter it? Any and all help/ideas would be appreciated. Thanks. USE [CIS31038] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[UPDATE_MERCHANDISE] ON [dbo]

OnEdit function not working for shared users

谁说我不能喝 提交于 2021-02-11 13:35:16
问题 I have the following OnEdit script in a Google spreadsheet that inserts a timestamp when a checkbox is edited. The action is preformed when I make the edit, but does not work when the edit is made by another user. Any help is appreciated. function onEdit(e) { addTimestamp(e); } function addTimestamp(e){ //variables var startRow = 3; var targetColumn = 6; var ws = "MasterList"; //get modified row and column var row = e.range.getRow(); var col = e. range.getColumn(); if(col === targetColumn &&

Second trigger result disappear [closed]

笑着哭i 提交于 2021-02-11 12:51:40
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last month . Improve this question Please advise were result of trigger tr_stock_plus disappear? Because after INSERT query: INSERT INTO test.purchase( import_id, product_id, usd_price, qty) VALUES (2, 'CG-003', 40, 40); I have normal reply, no error message: INSERT 0 1 Query returned successfully in 242 msec.

Second trigger result disappear [closed]

非 Y 不嫁゛ 提交于 2021-02-11 12:50:54
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last month . Improve this question Please advise were result of trigger tr_stock_plus disappear? Because after INSERT query: INSERT INTO test.purchase( import_id, product_id, usd_price, qty) VALUES (2, 'CG-003', 40, 40); I have normal reply, no error message: INSERT 0 1 Query returned successfully in 242 msec.