database-trigger

Why am i returning an INVALID identifier when trying to COMPILE this TRIGGER?

丶灬走出姿态 提交于 2019-12-11 17:36:31
问题 So I am trying to compile this trigger that prints some lines as outputs ( have the variables declared because i will be building onto this trigger using these variables later on). There's an existing trigger in the same database that does the same exact thing with a different table passing the same data, but my trigger seems to throw an error saying that 'new.PROCESSED is an invalid identifier'. What am I doing wrong? I may just not know what is fully going on here in my code... (thanks in

How to do trigger that implements this condition?

心不动则不痛 提交于 2019-12-11 17:24:37
问题 I need trigger that implements this process: I should +add some number 50 to that user to table money where in table paym both columns table1 and table2 are not empty. For example: User 'John' has both columns not empty and to him added 50 in table money . Example in table below: table: paym ID username table1 Table2 +-------+-------------+-------------+-----------+ | 1 | John | Value | Value | +-------+-------------+-------------+-----------+ | 2 | Alex | Null | Null | +-------+-------------

Is it possible to insert a value from one table to another on the basis of value using trigger?

末鹿安然 提交于 2019-12-11 15:58:13
问题 I've a table named employee. I've two other tables named hrm, accounting. I want to insert the employee into hrm and accounting table according to their departments. CREATE TABLE employees ( employee_id INT(4) NOT NULL AUTO_INCREMENT, employee_first_name VARCHAR(30) NOT NULL, employee_last_name VARCHAR(30) NOT NULL, employee_department VARCHAR(30) NOT NULL, PRIMARY KEY (employee_id)); according to the employee_department, I want to insert that employee to that particular table. CREATE TABLE

monitor renaming a table in a sql server database with trigger

本秂侑毒 提交于 2019-12-11 15:27:34
问题 I have a trigger that logs on changes to the metadata of tables in a database. it saves the logs in another table called tblMonitorChange . When i rename a table no triggers is generated. this is the trigger : USE ReportServer GO CREATE TRIGGER trgMonitorChange ON DATABASE FOR CREATE_TABLE, ALTER_TABLE, DROP_TABLE , RENAME_TABLE AS set nocount on declare @EventType varchar(100) declare @SchemaName varchar(100) declare @ObjectName varchar(100) declare @ObjectType varchar(100) SELECT @EventType

creating a trigger that updates a table when a column in a different table is updated

戏子无情 提交于 2019-12-11 14:32:36
问题 For some reason I'm having a hard time fully understanding triggers. For my homework assignment I need to create a table that holds product id, total sales, and total quantity sold for each product (these columns are already in two different tables). Then I create a trigger that updates this table when the orderplaced column from a different table is updated to 1. Not exactly sure where to start. Since the table I created is empty would I do an UPDATE table as the assignment suggests or an

Trigger not firing for one particular CLOB column

半腔热情 提交于 2019-12-11 12:17:53
问题 We have a C++ legacy application that connects to an Oracle 11g database. The application uses Microsoft Data Access Objects (DAO) library to allow record browsing and modification. We also have some triggers on tables to track row updates and insertions. The problem is that the triggers don't fire for the CLOB columns that we have in our tables. It gets fired for other columns but for this one CLOB column, it neither fires during update nor during delete. I've added the trigger for all three

Inserting new row using a trigger on same table

徘徊边缘 提交于 2019-12-11 11:44:46
问题 I have a table JOB . It has following columns : cycle_id, job_id, status . There are 7 jobs that are executed for every cycle. So cycle_id and job_id form composite primary key. status column can have the following values : WAITING_TO_START, RUNNING. COMPLETED . Each job is a cron job. And each job is responsibility of different person, so to sync each person I am using a database table JOB. Each job listen to JOB table and watch it if there's a row with their job_id and status as 'WAITING_TO

PostgreSQL 9.6 stored procedure performance improvement

巧了我就是萌 提交于 2019-12-11 06:23:18
问题 i have two tables users and products and the association between them is that User has many products . I want to store the count of products in the users table and it should be updated at every insert or delete. So i have written a stored procedure in the database for it and trigger to fire it. The problem is when i am inserting thousands of products at once it is executing the trigger per row insertion and it is taking too much time. CREATE FUNCTION update_product_count() RETURNS trigger AS

How to write triggers to enforce business rules?

冷暖自知 提交于 2019-12-11 05:39:40
问题 I want to create triggers for practicing PL/SQL and I sorta got stuck with these two ones, which I'm sure they're simple, but I can't get a hold of this code. The first trigger forbids an employee to have a salary higher than the 80% of their boss (The code is incomplete because I don't know how to continue): CREATE OR REPLACE TRIGGER MAX_SALARY BEFORE INSERT ON EMP FOR EACH ROW P.BOSS EMP.JOB%TYPE := 'BOSS' P.SALARY EMP.SAL%TYPE BEGIN SELECT SAL FROM EMP WHERE JOB != P.BOSS ... And the

Check if trigger exists

ⅰ亾dé卋堺 提交于 2019-12-10 18:37:02
问题 I have the following query to triggers on all tables in schema public: SELECT 'CREATE TRIGGER ' || tab_name|| '_if_modified_trg INSERT OR UPDATE OR DELETE ON ' || tab_name|| ' FOR EACH ROW EXECUTE PROCEDURE audit.if_modified_func(); ' AS trigger_creation_query FROM ( SELECT quote_ident(table_schema) || '.' || quote_ident(table_name) as tab_name FROM information_schema.tables WHERE table_schema='public' ) AS foo; And I know how to check if a trigger exists: SELECT tgname from pg_trigger where