need to trigger when updating a column then sysdate record on another column
HelloGurus
I have a table named RTV_PLAN
And it has two columns,
FORCE_KEYIN_FLAG VARCHAR (2)
DATE OF FORCE_KEYIN_DATE
I want when FORCE_KEYIN_FLAG get a value
Then FORCE_KEYIN_DATE save the sysdate
Please kindly give help
Thank you very much
Saven
Florian wrote:
You can check out what they have another error?
Relaxation compile? I don't see obvious syntax errors. If you get a compile error, see the error.
What is the trigger that is supposed to do? It is impossible for anyone to tell you if your trigger does what you want it to do. You would have to tell us what it is supposed to do. Since you have the tables and the application of the APEX in question, you would have to tell us if it does not have what you want in some specific cases.
Justin
Tags: Database
Similar Questions
-
Trigger when only eno column change!
Hello
I have column A, B, C.
I wonder if create a trigger that is fired when ONLY column b is changed?
In this release I want to insert this old record of column B in another table.
What would be the best solution for my problem?
Kind regards
IgorIgorKSCon wrote:
When the ONLY column b is changed?If you want to call the trigger code only when the value of the column is changed then... you can also do like
CREATE OR REPLACE TRIGGER trg_name AFTER UPDATE OF col1 ON testing FOR EACH row WHEN (new.col1 != old.col1) --check this line BEGIN -- your trigger body here NULL; END;
-
Need help with the update server behaviors and deleting records
I am 'trying' to use the update and delete record server behaviors and I can't get the redirection page to set up correctly. What I'm trying to do, is to have the redirection came up with the right records depending on the CompId page. It seems that it is taking the CompId and agreementId (which are my unique ID) and use them in the url of the redirection page. Also, it updates the table. Here is the url that appears after I have send the update:
http://localhost:8888/dotweb/maintenance/agreement_home.php?CompId= & agreementId = 7
Here is the code for the update page:
Pending patent, trade mark, Tradesecret and straightened to copy recordedCopyright KML designs 2009Can someone tell me why it would show the CompId and agreementId when everything I asked the CompId? Thanks for your help. Just in case, I enclose you an html version of this file. It must be a php file, but is not one of the allowed file types.
CompId is not filled in the URL because you try to use the result of the rsAgree recordset object until the result of the recordset is created. However, you pass the CompId value via array $_POST as a hidden field.
Change this line (52):
$updateGoTo = "agreement_home.php?CompId=" . $row_rsAgree['CompId'] . "";
to do this:
$updateGoTo = "agreement_home.php?CompId=" . $_POST['CompId'];
-
Update of data based on records in another table
I have 2 tables
Table 1
Name Date of article
Jon apples 2013/06/11 00:30:00 hrs
Sam Oranges
NISH applesTable 2 - Net number
Number of name components
NISH apples 10
NISH Oranges 17
NISH banana
Sam 10 apples
Sam Oranges 1
Sam bananas 1
Jon potatoes 8I need to create a job that checks the table 1 for new records added after the last race and then add the count in table 2 accordingly.
Please guide on how to do this using the PL/SQl or something similarYou need a third table where you store the time stamp of the last execution or an additional field in table 1 which indicates if a record has been processed already. (or the Date column has this information?).
Then he must know if all possible combinations of the name and are already in Table2. If so, a simple update would do the job. If this isn't the case, you should take a look at the merge statement:
http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_9016.htm
Good bye
DPT
-
Need logic to update the column in a Varchar table
Hello
Could you tell me logic below.
I have a xx_dbc of the table where one of the Attribute1 column is varchar2 (240).
Attribute1 has values such as
==================
(AIN, PUP, GRI, NINE)
(AIN, PUP)
(AIN)
(GRI, NINE)
I have to update this column for each record with values AIN = 10, PUP = 20, GRI = 30, NINE = 40
Columns must be updated as below
(10,20,30,40)
(10.20)
(10)
(30, 40)
Thank you.
Hello
Here's one way:
WITH the replacements AS a
(
SELECT "AIN" AS old_str, '10' AS new_str FROM dual UNION ALL
SELECT 'PUP', '20' FROM dual UNION ALL
SELECT 'GRI', '30' FROM dual UNION ALL
SELECT 'NEW', '40' DOUBLE
)
normalized_data AS
(
SELECT p_key
LEVEL AS sort_key
REGEXP_SUBSTR (attribut1,
, '[^(,)]+'
1
LEVEL
) AS str
OF xx_dbc
-WHERE... - If you need any filtering, put it here
CONNECT BY LEVEL<= 1="" +="" regexp_count="" (attribute1,="">=>
AND PRIOR p_key = p_key
AND PRIOR SYS_GUID () IS NOT NULL
)
SELECT '(' ||) LISTAGG (NVL (r.new_str, n.str)
, ','
) (ORDER BY sort_key) group
|| ')' AS new_attribute1
n.p_key - if wanted
OF normalized_data n
LEFT OUTER JOIN replacements r ON r.old_str = n.str
GROUP BY n.p_key
ORDER BY n.p_key
;
Like everything else, it depends on your version of Oracle.
In the above query, p_key can be any unique key of xx_dbc, including attribute1 or ROWID.
Relational databases, such as Oracle, work best when each column of each row contains 1 single piece of information, not a list delimited a number of parts. It is so fundamental to the design of the table what he called the first normal form. Most of the work to this problem is to convert your data denormalized in first normal form, and then convert back again. This problem, like many others, would be much simpler and more effective if your table is in first normal form.
The above query assumes that the replacement of the chains (for example 'AIN' and '10') are not already in a table. If they are, or they can be derived from a table, then you need not replacements subquery; Use your actual table.
-
problem with trigger to update column
I am creating a trigger when I INSERTS a record into the CHART table, it will also insert the record in the MASTER_TAB table as well. I can't make the statement to UPDATE the trigger.
To do so, the relaxation, I have currently below.
But what I am also eager to make, only to do an UPDATE if the 'REMARKS' column changes.
So, something like:
If the update and: NEW.COMMENTS! =: OLD.COMMENTS THEN
do not include a record
Thank youcreate or replace TRIGGER "TABLE_BIU" BEFORE INSERT OR UPDATE ON "CHART" FOR EACH ROW BEGIN INSERT INTO MASTER_TAB ( CASE_NUMBER, COMMENTS ) VALUES ( :NEW.CASE_NUMBER, :NEW.COMMENTS ); END;
Deannacreate or replace TRIGGER TABLE_BIU BEFORE INSERT OR UPDATE ON CHART FOR EACH ROW BEGIN IF INSERTING OR NOT NVL(:OLD.COMMENTS,:NEW.COMMENTS || 'X') = NVL(:NEW.COMMENTS,:OLD.COMMENTS || 'X') THEN INSERT INTO MASTER_TAB ( CASE_NUMBER, COMMENTS ) VALUES ( :NEW.CASE_NUMBER, :NEW.COMMENTS ); END IF; END;
SY.
-
How to design a trigger to update only if a column value is changed?
Hello
I have a nice little trigger that updates the CARD table when the table is updated. This table is updated within a master/detail form. It's the main table.
Relaxation is used mainly to update the columns 'FICHE_MODIFIEE_PAR' (in English, it means "modified by") and "DATE_MODIFICATION" (in English, it means 'date modified'). I wish that these columns updates ONLY when the values in the columns 'TOTAL_HEURES' and 'TOTAL_HEURES_EXCEPTIONNELLES' are changed. These two columns have a default value for the number 0. That means that these columns change means change it value from the value 0 by default with another value or a value to another value. If the value of one or two of these two columns changes, the trigger must be fired for updating the column 'FICHE_MODIFIEE_PAR' and 'DATE_MODIFICATION '.
Thank you for your help.create or replace TRIGGER OBSERVATOIRE.TIB_FICHE before insert or update on OBSERVATOIRE.FICHE for each row begin if inserting and :new.fiche_id is null then select FICHE_SEQ.NEXTVAL INTO :new.FICHE_ID from dual; end if; if inserting then :new.fiche_cree_par := v('USER'); :new.date_creation := sysdate; end if; if updating then :new.fiche_modifiee_par := v('USER'); :new.date_modification := sysdate; end if; end;
ChristianHello Christian,.
You can reference and compare the old and new values. For example
IF: NEW. TOTAL_HEURES <> : OLD. TOTAL_HEURES OR: NEW. TOTAL_HEURES_EXCEPTIONNELLES <> : OLD. TOTAL_HEURES_EXCEPTIONNELLES
THEN
do your stuff
END IF;Greetings,
Roelhttp://roelhartman.blogspot.com/
http://www.bloggingaboutoracle.org/
http://www.Logica.com/ -
Need to write the cursor to update the column
Hi all
I want to write a cursor in the CALC_TAX of the PP_TAX of the UPDATE table column
Currently I use following update instructions to update the CALC_TAX column.
UPDATE PP_TAX P
SET CALC_TAX = ROUND (((P.ACTV_AMT * 5)/100), 2)
WHERE PROV_DEC_FOR_TAX ("AB", "NT", "YT", "NAKED", "NV");
UPDATE PP_TAX P
SET CALC_TAX = Round (((P.ACTV_AMT * 5)/100), 2) + Round (((P.ACTV_AMT + Round (((P.ACTV_AMT * 5)/100), 2)) * 8.5) / 100), 2)
WHERE PROV_DEC_FOR_TAX ("QC");
UPDATE PP_TAX P
SET CALC_TAX = Round (((P.ACTV_AMT * 5)/100), 2) + (((P.ACTV_AMT * 7)/100), 2nd round)
WHERE PROV_DEC_FOR_TAX IN ("MB");
UPDATE PP_TAX P
SET CALC_TAX = Round (((P.ACTV_AMT * 5)/100), 2) + Round (((P.ACTV_AMT + (Tower (((P.ACTV_AMT * 5)/100), 2)) * 10) / 100), 2)
WHERE PROV_DEC_FOR_TAX IN ('PE');
UPDATE PP_TAX P
SET CALC_TAX = Round (((P.ACTV_AMT * 5)/100), 2) + (((P.ACTV_AMT * 5)/100), 2nd round)
WHERE PROV_DEC_FOR_TAX ('SK');
UPDATE PP_TAX P
SET CALC_TAX = Round (((P.ACTV_AMT * 13)/100), 2)
WHERE PROV_DEC_FOR_TAX IN ('WE', 'NB', 'NL', 'YY');
UPDATE PP_TAX P
SET CALC_TAX = Round (((P.ACTV_AMT * 12)/100), 2)
WHERE PROV_DEC_FOR_TAX IN ("BC");
UPDATE PP_TAX P
SET CALC_TAX = Round (((P.ACTV_AMT * 15)/100), 2)
WHERE PROV_DEC_FOR_TAX IN ('NS');
Kindly help.This is what it would look like for the first two,
UPDATE pp_tax p SET calc_tax = CASE WHEN prov_dec_for_tax IN ('AB', 'NT', 'YT', 'NU', 'NV') THEN ROUND ( ( (p.actv_amt * 5) / 100), 2) WHEN prov_dec_for_tax IN ('QC') THEN ROUND ( ( (p.actv_amt * 5) / 100), 2) + ROUND ( ( ( (p.actv_amt + ROUND ( ( (p.actv_amt * 5) / 100), 2)) * 8.5) / 100), 2) END WHERE prov_dec_for_tax IN ('AB', 'NT', 'YT', 'NU', 'NV', 'QC');
Just add several WHEN clauses and include in the list of in WHERE clause.
Concerning
Peter -
My 7.0.1 program tells me there's an update available, 8.0.1...
I trigger the update that downloads an installation program.
When I restart firefox to get the update installed, restart and triggers a new window indicating that it contacts the server to update. This will continue to get in touch for 30 minutes with no established connection.
To keep my browser to 7.0.1.Windows Vista Ultimate sp2 64-bit.
Try the alternative and more simple way to download from here and simply run
-
I recently bought a HP with Windows 7 computer. It is used for work only and is not connected to the internet. I need to copy the updates on a CD/DVD and install them manually. Please tell me how.
Security updates are available on ISO-9660 DVD5 from the Microsoft Download Center image files
http://support.Microsoft.com/kb/913086How do to download drivers and updates from Windows Update (Microsoft) [catalog]
http://support.Microsoft.com/kb/323166~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft
-
Do you need a trigger in the timeline when you add an action?
I'm doing a replay button that works very well in an animation, but when I do exactly the same thing in another it does not work.
The animation of the work has no label at the end of the animation, no code just triggers not specified in the action and works very well. When I try to do exactly the same thing in another file, it does not at all. Can someone please advise? Am I missing something simple?
Thank you.
Kat
Nevermind, I thought about it and it was something SIMPLE! Instead of the symbols, I just had to select the stage: sym.play(1000) (0)
I was more complicated than necessary. arghghgh.
-
Update multiple columns from multiple tables in a single UPDATE request
Hello
I'm trying to figure if I'm heading in the right direction.
I want to update multiple columns from multiple tables in a single UPDATE request. Also, I would like to update multiple columns in a table from the tables.
Scenario 1
UPDATE Table2, Table 3 SET T2.Column1 = T1.Column1 ,T2.Column2 = T1.Column2 ,T3.Column2 = T1.Column2 FROM Table1 T1, Table2 T2, Table3 T3 WHERE T1.id = T2.id and T1.id = T3.id
Scenario 2
UPDATE Table3 SET T3.Column1 = T1.Column1 T3.Column2 = T1.Column2 ,T3.Column3 = T2.Column3 ,T3.Column4 = T2.Column4 FROM Table1 T1, Table2 T2, Table3 T3 WHERE T3.id = T1.id and T3.id = T2.id
Hello
For scenario 1, you must write separate instructions UPDATE table2 and table3.
To guard against someone else change one of these tables while you act so you can copy all relevant data in a global temporary table and update this global temporary table table3.
ENGAGE only when two tables have been changed.
You can write a procedure or an INSTEAD OF trigger to do all this.
For scenario 2, you can reference many tables that you need when new table3. It might be more efficient and simpler to use the MERGER rather than UPDATED. For example:
MERGE INTO table3 dst
WITH THE HELP OF)
SELECT t1.id
t1.column1
t1.column2
t2.column3
t2.column4
FROM table1 t1
JOIN table2 t2 ON t1.id = t2.id
) src
WE (dst.id = src_id
WHEN MATCHED THEN UPDATE
SET dst.column1 = src.column1
dst.column2 = src.column2,
dst.column3 = src.column3,
dst.column4 = src.column4,
;
-
update to column values (false) in a copy of the same table with the correct values
Database is 10gr 2 - had a situation last night where someone changed inadvertently values of column on a couple of hundred thousand records with an incorrect value first thing in the morning and never let me know later in the day. My undo retention was not large enough to create a copy of the table as it was 7 hours comes back with a "insert in table_2 select * from table_1 to timestamp...» "query, so I restored the backup previous nights to another machine and it picked up at 07:00 (just before the hour, he made the change), created a dblink since the production database and created a copy of the table of the restored database.
My first thought was to simply update the table of production with the correct values of the correct copy, using something like this:
Update mnt.workorders
Set approvalstat = (select b.approvalstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi)
where exists (select *)
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi)
It wasn't the exact syntax, but you get the idea, I wanted to put the incorrect values in x columns in the tables of production with the correct values of the copy of the table of the restored backup. Anyway, it was (or seem to) works, but I look at the process through OEM it was estimated 100 + hours with full table scans, so I killed him. I found myself just inserting (copy) the lines added to the production since the table copy by doing a select statement of the production table where < col_with_datestamp > is > = 07:00, truncate the table of production, then re insert the rows from now to correct the copy.
Do a post-mortem today, I replay the scenario on the copy that I restored, trying to figure out a cleaner, a quicker way to do it, if the need arise again. I went and randomly changed some values in a column number (called "comappstat") in a copy of the table of production, and then thought that I would try the following resets the values of the correct table:
Update (select a.comappstat, b.comappstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi - this is a PK column
and a.comappstat! = b.comappstat)
Set b.comappstat = a.comappstat
Although I thought that the syntax is correct, I get an "ORA-00904: 'A'. '. ' COMAPPSTAT': invalid identifier ' to run this, I was trying to guess where the syntax was wrong here, then thought that perhaps having the subquery returns a single line would be cleaner and faster anyway, so I gave up on that and instead tried this:
Update mnt.workorders_copy
Set comappstat = (select distinct)
a.comappstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi
and a.comappstat! = b.comappstat)
where a.comappstat! = b.comappstat
and a.workordersoi = b.workordersoi
The subquery executed on its own returns a single value 9, which is the correct value of the column in the table of the prod, and I want to replace the incorrect a '12' (I've updated the copy to change the value of the column comappstat to 12 everywhere where it was 9) However when I run the query again I get this error :
ERROR on line 8:
ORA-00904: "B". "" WORKORDERSOI ": invalid identifier
First of all, I don't see why the update statement does not work (it's probably obvious, but I'm not)
Secondly, it is the best approach for updating a column (or columns) that are incorrect, with the columns in the same table which are correct, or is there a better way?
I would sooner update the table rather than delete or truncate then re insert, as it was a trigger for insert/update I had to disable it on the notice re and truncate the table unusable a demand so I was re insert.
Thank youHello
First of all, after post 79, you need to know how to format your code.
Your last request reads as follows:
UPDATE mnt.workorders_copy SET comappstat = ( SELECT DISTINCT a.comappstat FROM mnt.workorders a , mnt.workorders_copy b WHERE a.workordersoi = b.workordersoi AND a.comappstat != b.comappstat ) WHERE a.comappstat != b.comappstat AND a.workordersoi = b.workordersoi
This will not work for several reasons:
The sub query allows you to define a and b and outside the breakets you can't refer to a or b.
There is no link between the mnt.workorders_copy and the the update and the request of void.If you do this you should have something like this:
UPDATE mnt.workorders A -- THIS IS THE TABLE YOU WANT TO UPDATE SET A.comappstat = ( SELECT B.comappstat FROM mnt.workorders_copy B -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat ) WHERE EXISTS ( SELECT B.comappstat FROM mnt.workorders_copy B WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat )
Speed is not so good that you run the query to sub for each row in mnt.workorders
Note it is condition in where. You need other wise, you will update the unchanged to null values.I wouold do it like this:
UPDATE ( SELECT A.workordersoi ,A.comappstat ,B.comappstat comappstat_OLD FROM mnt.workorders A -- THIS IS THE TABLE YOU WANT TO UPDATE ,mnt.workorders_copy B -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat ) C SET C.comappstat = comappstat_OLD ;
This way you can test the subquery first and know exectly what will be updated.
This was not a sub query that is executed for each line preformance should be better.Kind regards
Peter
-
DB trigger error - update even table in the script of the trigger
Hi all
I have a table tab1, whenever any update is done on this table on column col1 and col2 also needs to get the update. (These are related to user forms can be updated only col1 form frontend)
So I created a trigger as follows.
----------------
CREATE OR REPLACE TRIGGER tri1
AFTER UPDATE
ON tab1
FOR EACH LINE
WHERE (NEW.col1 = 'YES')
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
Tab1 SET col2 = 1 UPDATE
WHERE transaction_id =: OLD.transaction_id;
COMMIT;
END;
--------
When there is no update on this table, I get following error. Please let me know if I'm missing something.
ORA-00060: Deadlock detected while you wait resource
ORA-06512: at "user1.tab1", line 5
ORA-04088: error during execution of trigger 'user1.tab1 '.
Please let me know if I'm not clear. Thank you
Published by: DharV on August 23, 2011 05:17Your transaction_id is unique?
If this is the case, then you could perhaps use AFTER UPDATE BEFORE UPDATE:
CREATE OR REPLACE TRIGGER tri1 BEFORE UPDATE ON tab1 FOR EACH ROW WHEN (NEW.col1 = 'YES') BEGIN :NEW.col2 := 1; END;
If your transaction_id is not unique - if you really want to update more than one line in tab1 - your update cannot update the same line that the trigger has responded, even with the use of an autonomous transaction. Then you could combine the BEFORE UPDATE trigger above with your own AFTER UPDATE, but then add ROWID! =: OLD. ROWID to where clause, but it would be a bad idea because some of your lines will be updated in a single transaction and others in another transaction.
In general the autonomous transaction is not a great way to solve the problem of changing table within a trigger. I hope that you have a unique transaction_id and can do BEFORE the UPDATE - if it is then a better way is to save the update id in an overall picture in FOR EACH ROW triggers, and only then AFTER an UPDATE fire is NOT "for each line" update the list of saved IDs
-
Referring to a date colum (: old.return_dt) in a trigger to update now
I moved this Post to the SQL forum. Thanks anyway.
_______________________________________________________________________________________________________________________
I have a date column on my table named return_dt:
In a trigger on update, I want to use a condition IF referring to: old.return_dt. Something like:
But I'm not sure what format: OLD. RETURN_DT will look like? In my condition IF will look like ' 02 - 02-2222' or ' 02 - FEB - 2222 "or 2 February 22"?IF OLD.RETURN_DT <> '02-02-2222' THEN ...
If I use SQLPLUS and to_char the value of the column in my query, it looks like this:
But it is an indication of how it will look when I talk about it in my IF condition? Any help would be greatly appreciated.SQL> select to_char(return_dt) from scanner_assignment 2 where serial_num='7408341021'; TO_CHAR(R --------- 02-FEB-22
Published by: sharpe on July 11, 2011 13:51
Published by: sharpe on July 11, 2011 13:56IF OLD. RETURN_DT ' 02 - 02 - 2222 "THEN
...most of the time that you need to convert the dates as otherwise you never know what's going to happen.
Dates are a number of days between a given date.example: this is the date equal to dec 12, 2010?
If :old.return_dt = to_date('12-01-2010','mm-dd-yyyy') then
I would try never depend on what format was created. There is a huge mystery here and can change.
Maybe you are looking for
-
Toshiba 48L5445DG stucks - 3.6.3c firmware need
Hello ladies and gentlemen, I wonder if anyone has the Firmware version 3.6.3c apart or from a source to download from?My 48L5445DG is stuck on 3.3.6k after receiving a USB key with the 'new' version of the firmware. The Toshiba firmware download pag
-
What is clear to the left of the button works / stop on the Board front of the P7-1222. The image of what looks like 3 CD above him flickers power on and off while the computer is turned on.
-
OfficeJet Pro 8610: Non-instantanee cartridge installed
Hi, I signed at the instant when I bought the printer but installed ink cartridges supplied with the printer rather than installing those who came in the post, a week later. Anyone know if this is why I get the error according to the subject line? Ev
-
How can I use Windows Live Onecare to restore my hard drive?
I need to use windows live onecare to restore my hard drive I have backup files but no way we them... can you help me? original title: windows live onecare
-
Could not load the profile user (XP OS) and lost files
Hello I tried to connect to my help my profile on XP last night and message box came up saying that my profile cannot be loaded. I am currently in the temporary profile that was created automatically by the system for this profile. It seems that fi