Search Results

Search found 1486 results on 60 pages for 'triggers'.

Page 2/60 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Audit Table using Triggers

    - by Jose
    DROP TABLE IF EXISTS `actividades`.`act_actividad_audit`; CREATE TABLE `actividades`.`act_actividad_audit` ( `fe_creacion` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `usr_digitador` char(10) NOT NULL, `ip_digitador` char(15) NOT NULL, `id_act_actividad` int(10) unsigned NOT NULL, `titulo` char(64) NOT NULL, `act_prioridad_id` int(10) unsigned NOT NULL, `act_motivo_id` int(10) unsigned NOT NULL, `detalle` text, `detalle_tecnico` text, `hostname_id` int(10) unsigned NOT NULL, `hostname_nombre` char(50) NOT NULL, `es_SMOP` tinyint(1) NOT NULL, `url_SMOP` text, `es_tecnico` tinyint(1) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Auditoria Actividad General'; I want to populate that audit table with a trigger but how can i send or fill the values for usr_digitador or ip_digitador if that values are on client side.? please help

    Read the article

  • loops and conditionals inside triggers

    - by Ying
    I have this piece of logic I would like to implement as a trigger, but I have no idea how to do it! I want to create a trigger that, when a row is deleted, it checks to see if the value of one of its columns exists in another table, and if it does, it should also perform a delete on another table based on another column. So say we had a table Foo that has columns Bar, Baz. This is what id be doing if i did not use a trigger: function deleteFromFooTable(FooId) { SELECT (Bar,Baz) FROM FooTable WHERE id=FooId if not-empty(SELECT * FROM BazTable WHERE id=BazId) DELETE FROM BarTable WHERE id=BarId DELETE FROM FooTable WHERE id=FooId } I jumped some hoops in that pseudo code, but i hope you all get where im going. It seems what i would need is a way to do conditionals and to loop(in case of multiple row deletes?) in the trigger statement. So far, I haven't been able to find anything. Is this not possible, or is this bad practice? Thanks!

    Read the article

  • SQLServer triggers

    - by Evl-ntnt
    Please help me to write trigger that, adds new rows in table I have 3 tables in my database. 1) Regions (id, name); id - primary 2) Technics (id, name); id - primary 3) Availability (id, region, technic, count); id - primary, region - foreign on Regions.id, Technik - foreign on technics.id I want to add new row in Availability for each Technics row on adding row in Regions. Somethink like: procedure void OnAddNewRegion(int region) { foreach (Row r in Technic) { Availability.Rows.Add(new Row(id, region, r.Id, 0)); } } But in SQL trigger. Same I want to do on the adding new Technics row

    Read the article

  • Firing Postgres triggers on different table columns

    - by aatifh
    CONTENT_TABLE id | author | timestamp | title | description ----+-----------------+-----------+----------------+---------------------- (0 rows) SEARCH_TABLE id | content_type_id | object_id | tsvector_title | tsvector_description ----+-----------------+-----------+----------------+---------------------- (0 rows) I have to fire a trigger when ever CONTENT_TABLE is UPDATED/INSERTED Something like this: "CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON course_course FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger(SHOULD_BE_THE_COLUMN_OF_SEARCH_TABLE(tsvector_description), 'pg_catalog.english', description);" Actually, i have to add tsvector for title and description of the CONTENT_TABLE to the table SEARCH_TABLE tsvector_title and tsvector_description. Can i just fire one trigger for it? Any sort of help will be appreciated. Thanks in advance.

    Read the article

  • Oracle Triggers Query..

    - by AGeek
    Lets consider a Table STUD and a ROW-Level TRIGGER is implemented over INSERT query.. My scenario goes like this, whenever a row is inserted, a trigger is fired and it should access some script file which is placed in the hard disk, and ultimately should print the result. So, is this thing is possible? and if yes, then this thing should exist in dynamic form, i.e. if we change the content of script file, then the oracle should reflect those changes as well. I have tried doing this for java using External Procedures, but doesn't feel that much satisfied with the result that i wanted. Kindly give your point-of-view for this kind of scenario and ways that this can be implemented.

    Read the article

  • PostgreSQL, triggers, and concurrency to enforce a temporal key

    - by Hobbes
    I want to define a trigger in PostgreSQL to check that the inserted row, on a generic table, has the the property: "no other row exists with the same key in the same valid time" (the keys are sequenced keys). In fact, I has already implemented it. But since the trigger has to scan the entire table, now i'm wondering: is there a need for a table-level lock? Or this is managed someway by the PostgreSQL itself?

    Read the article

  • How to use Externel Triggers on Oracle 11g..

    - by RBA
    Hi, I want to fire a trigger whenever an insert command is fired.. The trigger will access a pl/sql file which can change anytime.. So the query is, if we design the trigger, how can we make sure this dynamic thing happens.. As during the stored procedure, it is not workingg.. I think - it should work for 1) External Procedures 2) Execute Statement Please correct me, if I am wrong.. I was working on External Procedures but i am not able to find the way to execute the external procedure from here on.. SQL> CREATE OR REPLACE FUNCTION Plstojavafac_func (N NUMBER) RETURN NUMBER AS 2 LANGUAGE JAVA 3 NAME 'Factorial.J_calcFactorial(int) return int'; 4 / @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ SQL> CREATE OR REPLACE TRIGGER student_after_insert 2 AFTER INSERT 3 ON student 4 FOR EACH ROW How to call the procedure from heree... And does my interpretations are right,, plz suggest.. Thanks.

    Read the article

  • Query on Triggers..

    - by RBA
    Created One Trigger in Oracle.. SQL> CREATE OR REPLACE TRIGGER student_after_insert 2 AFTER INSERT 3 ON student 4 FOR EACH ROW 5 BEGIN 6 @hello.pl 9 END student_after_insert; 10 / Contents of hello.pl are:- BEGIN DBMS_OUTPUT.PUT_LINE('hello world'); END; And.. the result is pretty good, as the content of hello.pl is displayed on screen while inserting a record.. Now, the query is -- When i change the content of the hello.pl file, after exiting from oracle, and then logging again, It doesn't shows the updated contents, instead it shows the previous content.. I noticed that, if i drop the trigger and create it again, then it is working fine.. Why is it happening so.. And what is the solution to this problem..

    Read the article

  • HTTP triggers for Postgres

    - by HeineyBehinds
    I'm trying to write a Postgres trigger such that when a configuration table is updated, a backend component is notified and can handle the change. I know that Oracle has the concept of a web/HTTP trigger, where you can execute an HTTP GET from the Oracle instance itself to a URL that can then handle the request at the application layer. I'm wondering if Postgres (v. 9.0.5) has the same feature, or comes with anything similar (and, subsequently, how to set it up/configure it)?

    Read the article

  • Are Triggers Based On Queries Atomic?

    - by David
    I have a table that has a Sequence number. This sequence number will change and referencing the auto number will not work. I fear that the values of the trigger will collide. If two transactions read at the same time. I have ran simulated tests on 3 connections @ ~1 million records each and no collisions. CREATE TABLE `aut` ( `au_id` int(10) NOT NULL AUTO_INCREMENT, `au_control` int(10) DEFAULT NULL, `au_name` varchar(50) DEFAULT NULL, `did` int(10) DEFAULT NULL, PRIMARY KEY (`au_id`), KEY `Did` (`did`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 TRIGGER `binc_control` BEFORE INSERT ON `aut` FOR EACH ROW BEGIN SET NEW.AU_CONTROL = (SELECT COUNT(*)+1 FROM aut WHERE did = NEW.did); END;

    Read the article

  • Creating audit triggers in SQL Server

    - by Mike C.
    I need to implement change tracking on two tables in my SQL Server 2005 database. I need to audit additions, deletions, updates (with detail on what was updated). I was planning on using a trigger to do this, but after poking around on Google I found that it was incredibly easy to do this incorrectly, and I wanted to avoid that on the get-go. Can anybody post an example of an update trigger that accomplishes this successfully and in an elegant manner? I am hoping to end up with an audit table with the following structure: ID LogDate TableName TransactionType (update/insert/delete) RecordID FieldName OldValue NewValue ... but I am open for suggestions. Thanks!

    Read the article

  • MySQL Trigger with dynamic table name

    - by Thomas
    I've look around a bit and can't quite find an answer to my problem: I want a trigger to execute after an insert on a table and to take that data that is being inserted and do two things Create a new table from the client id and partner id Insert the 'data' that just was inserted into the new table I am fairly new to the Stored procedures and triggers so I came up with this but am having difficulty debugging it: delimiter $$ CREATE TRIGGER trg_creas_insert BEFORE INSERT ON tracking.creas for each row BEGIN DECLARE @tableName varchar(40); DECLARE @createStmnt mediumtext; SET @tableName = concat('crea_','_', NEW.idClient_crea,'_',NEW.idPartenaire_crea); SET @createStmnt = concat('CREATE TABLE IF NOT EXISTS', @tableName, '( `data_crea` mediumtext NOT NULL ) ENGINE=MyISAM AUTO_INCREMENT=29483330 DEFAULT CHARSET=utf8 PACK_KEYS=0'); PREPARE stmt FROM @createStmnt; EXECUTE stmt; INSERT INTO @tableName (data_crea) values (NEW.data_crea); END$$ delimiter ; Thoughts?

    Read the article

  • archiving table records to another table by trigger(move daialy table records to weekly table, evry

    - by sirvan
    I have written this trigger in mysql 5: create trigger changeToWeeklly after insert on tbl_daily for each row begin insert into tbl_weeklly SELECT * FROM vehicleslocation v where v.recivedate < curdate(); delete FROM tbl_daily where recivedate < curdate(); end; i want to archive records by date, move yesterday inserted record from dailly to weekly table and last weekly table to mounthly table and deletes this records from previous table this trigger has following error when insert in daily tabled occurred : "Can't update table 'tbl_daily' in stored function/trigger because it is already used by statement which invoked this stored function/trigger." please help me to solve th problem of archive old data in related tables: move yesterday inserted records to weekly table, if there is a reliable solution tell me please.

    Read the article

  • How to get use text columns in a trigger

    - by Jeremy
    I am trying to use an update trigger in sql 2000 so that when an update occurs, I insert a row into a history table, so I retain all history on a table: CREATE Trigger trUpdate_MyTable ON MyTable FOR UPDATE AS INSERT INTO [MyTableHistory] ( [AuditType] ,[MyTable_ID] ,[Inserted] ,[LastUpdated] ,[LastUpdatedBy] ,[Vendor_ID] ,[FromLocation] ,[FromUnit] ,[FromAddress] ,[FromCity] ,[FromProvince] ,[FromContactNumber] ,[Comment]) SELECT [AuditType] = 'U', D.* FROM deleted D JOIN inserted I ON I.[ID] = D.[ID] GO Of course, I get an error "Cannot use text, ntext, or image columns in the 'inserted' and 'deleted' tables." I tried joining to MyTable instead of deleted, but because the insert triger fires after the insert, it ends up inserting the new record into the history table, when I want the original record. How can I do this and still use text columns?

    Read the article

  • I need to create Trigger for delete action which backsup all fields old value in audit table

    - by Parth
    I need to create Trigger for delete action which backsup all fields old value in audit table. I have a table structure for audit table as id, menuid, field, oldvalue, changedone now whenever any of the row is deleted from its mother table(menu) having 21 fields in count, every fields old value should get insert in the audit table with new audit id.. like If I delete a row having fields as: menuid, name, age, address, sex, town now in audit table 6 rows should get inserted seperately for every field given above as: AUdit Table: id=2(audittable id) menuid = menuid field = name oldvalue = joy changedone = (whatever the deleted time was) id=3(audittable id) menuid = menuid field = age oldvalue = 23 changedone = (whatever the deleted time was) an so on..

    Read the article

  • WPF Style Triggers: can I apply the one style for a variety of Properties?

    - by Matt H.
    It seems like there has to be a way to do this: I am applying an ItemContainerStyle in my Listbox, based on two property triggers. As you can see, I'm using the exact same set of trigger enter/exit actions, simply applied on two different properties. Is there something equivalent to a <Trigger Property="prop1" OR Property="prop2" ??? (Obviously wouldn't look like that, but that probably gets the point across.) <Style x:Key="ListBoxItemStyle" TargetType="ListBoxItem"> <Style.Triggers> <Trigger Property="IsKeyboardFocusWithin" Value="True"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Height" To="50" Duration="0:0:.3"></DoubleAnimation> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Height" To="25" Duration="0:0:.3" /> </Storyboard> </BeginStoryboard> </Trigger.ExitActions> </Trigger> </Style.Triggers> </Style> <Style x:Key="ListBoxItemStyle" TargetType="ListBoxItem"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Height" To="50" Duration="0:0:.3"></DoubleAnimation> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Height" To="25" Duration="0:0:.3" /> </Storyboard> </BeginStoryboard> </Trigger.ExitActions> </Trigger> </Style.Triggers> </Style>

    Read the article

  • Triggers, Service Broker, CDC or Change Tracking?

    - by Derek D.
    When one trigger inserts into a table and that table also contains a trigger, this is a “nested trigger”. The reason that nested triggers are a concern is because the first call that performs the initial insert does not return until the last trigger in sequence is complete. In trying to circumvent this [...]

    Read the article

  • COLUMNS_UPDATED() for audit triggers

    - by Piotr Rodak
    In SQL Server 2005, triggers are pretty much the only option if you want to audit changes to a table. There are many ways you can decide to store the change information. You may decide to store every changed row as a whole, either in a history table or as xml in audit table. The former case requires having a history table with exactly same schema as the audited table, the latter makes data retrieval and management of the table a bit tricky. Both approaches also suffer from the tendency to consume...(read more)

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >