triggers

TSQL is expecting the identity column to be inserted when using an instead of insert trigger

天大地大妈咪最大 提交于 2019-12-24 17:19:33
问题 I'm setting up a view (foo), in place of a table with the same name. The new view will use 3 sub-tables (A, B, C) instead of the original table. I'm using instead-of triggers to accomplish this. CREATE VIEW [dbo].[foo] AS select b2 as oldkey, b3 as boat, c2 as state, a2 as name from A join B on a1 = b1 join C on a1 = c1 foo columns : oldkey (identity) | boat | state | name My issue is that I have a large code base that is written to insert into foo as follows: insert into foo values ('fishing

PostgreSQL same trigger function to UPDATE on INSERT into different tables (using the same schema)

ε祈祈猫儿з 提交于 2019-12-24 17:19:19
问题 I have 100s of tables having the same schema and I have a trigger function to UPDATE some column whenever data is INSERTed into that table. Table Schema: CREATE TABLE symbol_daily_ohlc ( cdate date, open numeric(8,2), high numeric(8,2), low numeric(8,2), close numeric(8,2), sma8 numeric(8,2) ); Trigger function: create or replace function update_sma8() RETURNS TRIGGER AS $$ BEGIN UPDATE symbol_daily_ohlc d SET sma8 = s.simple_mov_avg FROM ( SELECT sec.cdate,AVG(sec.close) OVER(ORDER BY sec

ORA-04091 - How can I alter a table that a trigger fires on?

丶灬走出姿态 提交于 2019-12-24 16:27:39
问题 So I have table foo and I would like to delete other foo rows when trigger t_foo fires: CREATE OR REPLACE TRIGGER "t_foo" AFTER INSERT OR DELETE OR UPDATE ON foo /*delete some other records from foo that are not :NEW.* or :OLD.* \* How would I go about doing this without getting a ORA-04091: table name is mutating, trigger/function may not see it. Is this even possible? 回答1: Why not do this in a stored procedure, where you can wrap the insert and deletes in a transaction, and can clearly

Issue with execution query of update table in stored trigger

情到浓时终转凉″ 提交于 2019-12-24 16:21:45
问题 I'm trying to execute this auto generate query from PHP but it's not working INSERT INTO mvt (id_piece, article_id_article, code_mvt, origine_mvt, type_mvt, code_art, des_art, qte_old, qte_mvt, qte_new, link_piece) SELECT 32, 57, 'MVT/15/12/0001', 'BSR/15/12/001', 'S', 'ART_039', 'AAAA', a.qte_art, 1, a.qte_art - 1, 'uuuu' FROM article a WHERE a.id_article = 57 Structure of table mvt CREATE TABLE IF NOT EXISTS `mvt` ( `id_mvt` int(11) NOT NULL AUTO_INCREMENT, `id_piece` int(10) NOT NULL,

INSERT a real number in a column based on other columns OLD INSERTs

时光怂恿深爱的人放手 提交于 2019-12-24 16:15:19
问题 In PostgreSQL I have this table... (there is a primary key serial column in the most left side "stmtserial" which is not shown in this image) in the table above, all columns are entered via queries, except the "time_index" which is automatically filled via a BEFORE INSERT, PER-ROW trigger. This is the code to create the same table (without any value) so everyone could create it using the Postgre SQL query panel. CREATE TABLE table_ebscb_spa_log04 ( pcnum smallint, stmtserial integer NOT NULL

Invoke Windows service from Oracle AFTER INSERT Trigger

我们两清 提交于 2019-12-24 13:53:49
问题 How can we invoke windows service (or) dll file from Oracle AFTER INSERT Trigger Any suggestion will be highly appreciated Best Regards, 回答1: You can run OS commands from plsql. This can be done as described in this AskTom post or this (preior to 11g) So, if you can call the service or dll from a script, then this might work 来源: https://stackoverflow.com/questions/14918695/invoke-windows-service-from-oracle-after-insert-trigger

How to sum up all rows based on a enumeration column in PostgreSQL part2?

大憨熊 提交于 2019-12-24 13:42:50
问题 ))Hi all, this is my table... Currently Im using this function trigger... IF NEW.timetype = 'Total' THEN SELECT SUM(timeelapse) FROM (SELECT DISTINCT ON (floor(timeindex)::int) floor(timeindex)::int timeindex, timeelapse FROM mytable WHERE pcnum = NEW.pcnum AND fnname = NEW.fnname AND timetype = 'Lap' ORDER BY 1, 2 DESC) alias INTO v_sumtimeelapse_fn; IF FOUND THEN NEW.timeelapse := v_sumtimeelapse_fn; ELSE RAISE EXCEPTION USING MESSAGE = 'There is not any previous row...'; END IF; END IF; So

SQL Server/Oracle table writable only by a trigger?

人走茶凉 提交于 2019-12-24 12:46:40
问题 I am wondering if is there a way to make a table writable only by an specific trigger in SQL Server or Oracle DB. Just to make an example: Table: "Operation" ID | Date | Account1_ID | Account2_ID | Amount Table: "Transactions" ID | Date | Account | Debt | Credit What I want to ensure is that the Transactions table only receive data from a trigger in the Operation table. Is there a way to achieve that? 回答1: Execute As allows you to create a trigger that runs as a user different to the current

Launch script after Windows service start

大城市里の小女人 提交于 2019-12-24 12:25:42
问题 I would like to launch script after windows service start or restart. Like monitor wsupdate and at start or restart execute a batch script test.bat Any ideas ? 回答1: That could be easily done with a scheduled task: You just need to: 1) Start and Stop the Service to got the appropriate Events in the Eventlog. 2) taskschd.msc and create a new Costum Task. As Trigger you can select the Events created before with the start and/or stop action. 3) As Action call your cmd/bat, whatever you want. Hint

Updating files with a Perforce trigger before submit

邮差的信 提交于 2019-12-24 12:25:17
问题 I understand that this question has, in essence, already been asked, but that question did not have an unequivocal answer, so please bear with me. Background: In my company, we use Perforce submission numbers as part of our versioning. Regardless of whether this is a correct method or not, that is how things are. Currently, many developers do separate submissions for code and documentation: first the code and then the documentation to update the client-facing docs with what the new version