Trigger on update.
Hello
I have a stock of table (series, item_id, qty, max_to_min_factor, min_unit, packet_sell_price), it might have several lines with the same (item_id) and I have a block based on a (From Clause), based on the (stock) table.
(clausefrom) is:
SELECT I.ITEM_ID , S.ITEM_ENG_NAME , S.ITEM_ARABIC_NAME , SUM(I.QUANTITY) QTY , I.MAX_TO_MIN_FACTOR , I.MIN_UNIT , I.PACKET_SELL_PRICE FROM ITEM_DETAIL I , STOCK S WHERE I.ITEM_ID = S.ITEM_ID GROUP BY I.ITEM_ID , S.ITEM_ENG_NAME , S.ITEM_ARABIC_NAME , I.MAX_TO_MIN_ACTOR , I.MIN_UNIT , I .PACKET_SELL_PRICE ORDER BY S.ITEM_ENG_NAME
the columns that could be updated are (max_to_min_factor, min_unit, packet_sell_price)
If max_to_min_factor is being updated, I updated all the lines for the item_id with the new max_to_min_factor,
If min_unit is updated,...,
If packet_sell_price...
I don't know if it is better to create a trigger on update on block level and issue a statement to update for all columns,
or create a trigger on update on each item, to update only the updated item?
> I don't know if it is better to create a trigger on update on block level and issue an update for all columns statement.
> or create a trigger on update on each item, to update only the updated item?
On-Update trigger has only these levels of definition: shape or a block.
Kind regards
Zlatko
Tags: Oracle Development
Similar Questions
-
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
-
How to write the trigger for update of 2 tables
Hi all
I have 2 tables,
1.lv_data,
It contains the following fields,
2.leave_dataemp_name tot_days guru 18
It contains the following fields,
In the second table, if the data is inserted.emp_name From_date to_date no_of_days remaining_days guru 02/05/2012 03/05/2012 2
the no_of_days will be calculated automatically (from to_date - From_date) + 1,
Here, I need to write the trigger to update the remaining_days column,
First table for all tot_days emp_name is 18 days,
Thus, in the second table every time that the record is inserted.
the remaining_days must be calculated as follows,
remaining_days: = tot_days - no_of_days and this (calculated) value should be updated in the tot_days column in the first table (lv_data).
Example:
2.leave_dataemp_name tot_days guru 18
emp_name tot_daysemp_name From_date to_date no_of_days remaining_days guru 02/05/2012 03/05/2012 2 16 [/code Now the first table should be updated like,
Guru 16
So I need to update to 2 tables,
can someone help me to update these 2 tables through TRIGGER?
Thank you
Kind regards
gurujothi
Edited by: Gurujothi may 1, 2012 19:54It is generally considered bad practice to store the value even in 2 places. You are having the kind of problems that you are experiencing now. It is much easier to store in the main table and get the value from there where you need to show in your forms.
-
Oracle running on a table - form has a trigger on update
My Oracle form is performed on a table with a trigger on update sur-insert:
I was hoping that by using "AFTER INSERT or UPDATE" in the definition of the trigger that would save my form quickly. And then the trigger continues to operate. You see that the trigger takes a minute or two to run because it sends an alert message. So I tried my form to quickly record and popup message ' 1 Transaction Complete' normal even if the trigger is still ongoing.CREATE OR REPLACE TRIGGER TTMS.t_vacationNotificationPCM AFTER INSERT OR UPDATE OF BEGIN_DT ,END_DT ON TTMS.DROPPER_VACATIONS REFERENCING NEW AS New OLD AS Old FOR EACH ROW declare ...
Am I trying to accomplish even possible?
Any help would be greatly appreciated. Thank you.No, insert your code in where the sample is / * some code process * / as
'BEGIN MY_PROCEDURE(' || TO_CHAR(id) || ', TO_DATE(''' || TO_CHAR(datevar, 'DD.MM.YYYY') || ''', ''DD.MM.YYYY'')); END;'
-
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.
-
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/ -
How to write the trigger for update or delete multiple columns in a table?
Hello
I create one in the form of table of sample_emp. In that, every time I want to change of name, team_id, team_leader_id, supervisor_id, manager_id it must store the update-able and old values of those in the job_history table. When I write the trigger for which it shows "ORA-04082 new or the old value not table level triggers. Here is my emp_table. My table also similar job_history like this. Need your help.
Header 1 Header 2 Header 3 Header 4 Header 5 Heading 6 Heading 7 8 header Header 9 EMP_ID EMP_NAME DESIGNATION TEAM_ID TEAM_LEADER_ID EMPLOYEE MANAGER_ID HIRE_DATE RELIEVED_DATE --
Thank you.
Hi Joel,.
Venky_prs wrote:
Hello
I create one in the form of table of sample_emp. In that, every time I want to change of name, team_id, team_leader_id, supervisor_id, manager_id it must store the update-able and old values of those in the job_history table. When I write the trigger for which it shows "ORA-04082 new or the old value not table level triggers. Here is my emp_table. My table also similar job_history like this. Need your help.
Header 1 Header 2 Header 3 Header 4 Header 5 Heading 6 Heading 7 8 header Header 9 EMP_ID EMP_NAME DESIGNATION TEAM_ID TEAM_LEADER_ID EMPLOYEE MANAGER_ID HIRE_DATE RELIEVED_DATE --
Thank you.
You can try something like this given below to complete the historical table on update and delete.
create or replace TRIGGER "CLONE_EMP_UPDATE_DELETE" BEFORE DELETE OR UPDATE ON EMP FOR EACH ROW DECLARE PRAGMA autonomous_transaction; BEGIN INSERT INTO JOB_HISTORY("EMP_ID","EMP_NAME","DESIGNATION","TEAM_ID","TEAM_LEADER_ID","SUPERVISOR_ID","MANAGER_ID" ,"HIRE_DATE","RELIEVED_DATE") VALUES(:OLD.EMP_ID,:OLD.EMP_NAME,:OLD.DESIGNATION,:OLD.TEAM_ID,:OLD.TEAM_LEADER_ID,:OLD.SUPERVISOR_ID, :OLD.MANAGER_ID,:OLD.HIRE_DATE, :OLD.RELIEVED_DATE); COMMIT; END;
Hope this helps you,
Kind regards
Jitendra
-
need help to trigger to update the change of columns of a table
Hi all
I need help in the manufacture of change update trigger in the columns from one table to another table.
For example, table (col1 col 2 col 3 col 4 col 5 samplea
.. .Col 20
Now if I do any change in one of the data column must be changed to
sample_copya... table that contains duplicate column
So for this I thought to create a trigger with the following logic
If updating (col1) then
Update sample_copya set col1: =: new.col1 where n ° 1 =: new.no1;
Otherwise, if the update (col2) then
Update sample_copya set col2: =: new.col2 where n ° 1 =: new.no1;
Otherwise, if the update (col3) then
Update sample_copya set col3: =: new.col3 where n ° 1 =: new.no1;
end if;
But how doi handle if all columns are changed or say 2 columns record the number of columns is more than 20...
I would like to know if there is a simpler method to achieve...
Thank yoususf wrote:
Hi all
I need help in the manufacture of change update trigger in the columns from one table to another table.
For example, table (col1 col 2 col 3 col 4 col 5 samplea
.. .Col 20Now if I do any change in one of the data column must be changed to
sample_copya... table that contains duplicate columnSo for this I thought to create a trigger with the following logic
If updating (col1) then
Update sample_copya set col1: =: new.col1 where n ° 1 =: new.no1;
Otherwise, if the update (col2) then
Update sample_copya set col2: =: new.col2 where n ° 1 =: new.no1;
Otherwise, if the update (col3) then
Update sample_copya set col3: =: new.col3 where n ° 1 =: new.no1;end if;
But how doi handle if all columns are changed or say 2 columns record the number of columns is more than 20...
I would like to know if there is a simpler method to achieve...
Thank youWhat is the purpose of this trigger?
How can you be sure that ' where n ° 1 =: new.no1 "is true?
How does line in the SAMPLE_COPYA table at the start?
only the last modified value will lie in SAMPLE_COPYA than the previous values is written more -
Good night Oracle Community.
I want to create a trigger that receives and process updates to a table and update another one with the same data but by applying functions. I get the error 'Statement ignored' and 'Duplicate column name' ' sub_tycod =: new.sub_tycod "line. What I am doing wrong?
Thank you!
create or replace TRIGGER aeven_sreports_update AFTER UPDATE ON aeven FOR EACH ROW BEGIN UPDATE aeven_sreports SET ad_sec = :new.ad_sec , ad_ts = Hora_dst(:new.ad_ts), ag_id = :new.ag_id, alarm_lev = :new.alarm_lev, appt_alarm_until = :new.appt_alarm_until, appt_end_ts = Hora_dst(:new.appt_end_ts), appt_start_dst = Hora_dst(:new.appt_start_dts), ar_sec = :new.ar_sec, ar_ts = Hora_dst(:new.ar_ts), assigned_units = :new.assigned_units, callback_dts = :new.callback_dts, cdtime2 = :new.cbtime2, cdts = Hora_dst(:new.cdts), closing_allowed = :new.closing_allowed, cpers = :new.cpers, create_pers = :new.create_pers, create_term = :new.create_term, csec = :new.csec, cterm = :new.cterm, curent = :new.curent, dest_eid = :new.dest_eid, dgroup = :new.dgroup, dispass_unit = :new.dispass_unit, ds_sec = :new.ds_sec, ds_ts = Hora_dst(:new.ds_ts), due_dts = Hora_dst(:new.due_dts), eid = :new.eid, en_sec = :new.en_sec, en_ts = Hora_dst(:new.en_ts), esz = :new.esz, eta = :new.eta, event_status = :new.event_status, evt_rev_num = :new.evt_rev_num, ex_evt = :new.ex_evt, hold_dts = Hora_dst(:new.hold_dts), hold_type = :new.hold_type, hold_unt = :new.hold_unt, late_run = :new.late_run, lev2 = :new.lev2, lev3 = :new.lev3, lev4 = :new.lev4, lev5 = :new.lev5, hora_dst = Hora_dst(:new.loi_avail_dts), majevt_evty = :new.majevt_evty, majevt_loc = :new.majevt_loc, mun = :new.mun, num_1 = :new.num_1, open_and_curent = :new.open_and_curent, pend_dts = Hora_dst(:new.pend_dts), prim_member = :new.prim_member, prim_unit = :new.prim_unit, priority = :new.priority, probe_flag = :new.probe_flag, proqanumber = :new.proqanumber, recom_incomplete = :new.recom_incomplete, reopen = :new.reopen, resp_down = :new.resp_down, resp_time = :new.resp_time, rev_num = :new.rev_num, scdts = Hora_dst(:new.scdts), sdts = Hora_dst(:new.sdts), sitfnd = :new.sitfnd, ssec = :new.ssec, sub_eng = :new.sub_eng, sitfnd = :new.sub_sitfnd, sub_tycod = :new.sub_tycod, supp_info = :new.supp_info, ta_sec = :new.ta_sec, ta_ts = Hora_dst(:new.ta_ts), tr_sec = :new.tr_sec, tr_ts = Hora_dst(:new.tr_ts), tycod = :new.tycod, typ_eng = :new.typ_eng, udts = Hora_dst(:new.udts), upers = :new.upers, uterm = :new.uterm, vdtst = Hora_dst(:new.vdts), vsec = :new.vsec, xcmt = :new.xcmt, xdow = :new.xdow, xdts = Hora_dst(:new.xdts), xpers = :new.xpers, xsec = :new.xsec, xterm = :new.xterm WHERE :new.num_1||:new.rev_num = num_1||rev_num; END aeven_sreports_update;
K - wrote:
and 'Duplicate column name' on ' sub_tycod =: new.sub_tycod "line. What I am doing wrong?I see two times a sitfnd:
sitfnd = :new.sitfnd, ssec = :new.ssec, sub_eng = :new.sub_eng, sitfnd = :new.sub_sitfnd,
There could be other
(Edit: it does not exist, can be easily seen if the list is sorted in alphabetical order in a text editor)Concerning
Peter -
Best way to trigger the update of TreeItem?
I have a TreeView which consists of thumbnails - those responsible at the request and in the meantime, just text is displayed.
I however have TreeView problems to recognize when such an element is updated. Initially I tried this, calling setValue on the TreeItem element that is appropriate:
Unfortunately, I couldn't get this to work at all. After a few more tries, I found a way that works, but it is very heavy:private void updateItem(MediaItem item) { TreeItem<MediaItem> foundItem = findMediaItem(treeRoot, item); if(foundItem != null) { foundItem.setValue(item); } } private TreeItem<MediaItem> findMediaItem(TreeItem<MediaItem> treeRoot, MediaItem mediaItem) { for(TreeItem<MediaItem> treeItem : treeRoot.getChildren()) { if(treeItem.getValue().equals(mediaItem)) { return treeItem; } if(!treeItem.isLeaf()) { TreeItem<MediaItem> foundItem = findMediaItem(treeItem, mediaItem); if(foundItem != null) { return foundItem; } } } return null; }
Having to create a new object TreeItem and looking for the index of the former just if I can replace it in the ObservableList of its parent seem exaggerated. I was more looking for a method simple "updateTreeItem" or something, where I can move to the item that has been updated. The API TreeCell doesn't seem to have this method, but I donot see how I can use it.private void updateItem(MediaItem item) { TreeItem<MediaItem> foundItem = findMediaItem(treeRoot, item); if(foundItem != null) { int index = foundItem.getParent().getChildren().indexOf(foundItem); foundItem.getParent().getChildren().set(index, new TreeItem<MediaItem>(item)); // foundItem.setValue(item); } }
Note: the element 'nine', I update here is actually the same instance (in other words, it is equal to the previous one) - I want to only trigger a new drawing, her look has changed even if it is always equal. I have not tried the substitution of equals for her, but even if it works it would be unsatisfactory because, from an application perspective, these two items are equal apart from having a miniature finished loading...
A simpler solution?
Published by: john16384 on December 4, 2011 19:40I'd come to it from a different angle (but this is not to say that there nothing wrong with your approach in theory however).
See if this helps you:
import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.concurrent.Task; import javafx.concurrent.Worker; import javafx.scene.Scene; import javafx.scene.control.ProgressIndicator; import javafx.scene.control.TreeCell; import javafx.scene.control.TreeItem; import javafx.scene.control.TreeView; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; import javafx.util.Callback; import java.net.URL; public class TestApp extends Application { public static void main(String[] args) throws Exception { launch(args); } public void start(final Stage stage) throws Exception { BorderPane root = new BorderPane(); TreeView
tree = new TreeView (); TreeItem bears = new TreeItem (new Animal("Bears", null)); bears.getChildren().addAll( new TreeItem (new Animal("Asiatic Black Bear", new URL("http://d38kpozl2gihos.cloudfront.net/wp-content/themes/gbf/images/asiaticblackbear.png"))), new TreeItem (new Animal("Black Bear", new URL("http://d38kpozl2gihos.cloudfront.net/wp-content/themes/gbf/images/blackbear.png"))), new TreeItem (new Animal("Brown Bear", new URL("http://d38kpozl2gihos.cloudfront.net/wp-content/themes/gbf/images/brownbear.png"))), new TreeItem (new Animal("Panda Bear", new URL("http://d38kpozl2gihos.cloudfront.net/wp-content/themes/gbf/images/panda.png"))), new TreeItem (new Animal("Polar Bear", new URL("http://d38kpozl2gihos.cloudfront.net/wp-content/themes/gbf/images/polar.png"))), new TreeItem (new Animal("Sloth Bear", new URL("http://d38kpozl2gihos.cloudfront.net/wp-content/themes/gbf/images/sloth.png"))), new TreeItem (new Animal("Spectacled Bear", new URL("http://d38kpozl2gihos.cloudfront.net/wp-content/themes/gbf/images/spectacled.png"))), new TreeItem (new Animal("Sun Bear", new URL("http://d38kpozl2gihos.cloudfront.net/wp-content/themes/gbf/images/sunbear.png"))), new TreeItem (new Animal("Pooh Bear", new URL("http://images3.wikia.nocookie.net/__cb20101111001913/disney/images/f/fe/84108-pooh_bear.jpg"))) ); tree.setRoot(bears); tree.setCellFactory(new Callback , TreeCell >() { public TreeCell call(TreeView tree) { return new AnimalTreeCell(); } }); root.setCenter(tree); Scene scene = new Scene(root, 800, 600); stage.setScene(scene); stage.show(); } //------------------------------------------------------------------------- private class AnimalTreeCell extends TreeCell { private Task loadTask; protected void updateItem(Animal animal, boolean empty) { super.updateItem(animal, empty); if (!empty && animal != null) { setText(animal.getName()); if (animal.getPhotoUrl() != null) { loadPhoto(animal.getPhotoUrl()); } } } protected void loadPhoto(final URL photoUrl) { if (loadTask != null) { loadTask.cancel(); } loadTask = new Task () { protected Image call() throws Exception { return new Image(photoUrl.openStream()); } }; setGraphic(new ProgressIndicator()); loadTask.stateProperty().addListener(new ChangeListener () { public void changed(ObservableValue extends Worker.State> source, Worker.State oldState, Worker.State newState) { if (newState.equals(Worker.State.SUCCEEDED)) { // probably should reuse the image view, rather than create a new one each time ImageView imageView = new ImageView(loadTask.getValue()); imageView.setFitHeight(40D); imageView.setFitWidth(50D); setGraphic(imageView); } } }); new Thread(loadTask).start(); } } //------------------------------------------------------------------------- private class Animal { private String name; private URL photoUrl; private Animal(String name, URL photoUrl) { this.name = name; this.photoUrl = photoUrl; } public String getName() { return name; } public URL getPhotoUrl() { return photoUrl; } } } PS how cool are the sloth bear!
-
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
-
trigger to update a table after the use of commit_form;
Hi, I have a master detail shipping form where I enter the details and use commit_form; to save data... after that I want to update a column named as transit in deteil table
but the changes are not reflected.
I wrote it under the procedure and tried to call the block level under update post trigger but it doesn't...PROCEDURE transit_update IS BEGIN if :shipbill.billtype in ( 'Send it to site','Send it to staff','Send it to store','Send it to consumed ','send it to repair') then update ship_1 set transit_qty = transact_qty where billid =:shipbill.billid; end if ; if :shipbill.billtype in ('Received from staff','Received from site','Received from store','Received from STC') then update ship_1 set transit_qty = 0 where billid =:shipbill.billid; end if ; END;
Hello
Why not put the sub condition in PRE-INSERT/PRE-UPDATE (at the level of the blocks) of the retail block?IF :shipbill.billtype IN ('Send it to site','Send it to staff','Send it to store','Send it to consumed ','send it to repair') THEN :ship_1.transit_qty = :ship_1.transact_qty; ELSIF :shipbill.billtype IN ('Received from staff','Received from site','Received from store','Received from STC') THEN :ship_1.transit_qty = 0; END IF;
If billtype is not simple text (filled in by the user) and then trying to find no matter what other condtion. To reduce misspellings error etc.
-Clément
-
trigger that updates another table?
Hi all
I'm trying to define a trigger on tableA:
Name ID Pk Null column? Default data Type
TITLE 1 Y VARCHAR2 (5 Char)
FULLNAME 2 Y VARCHAR2 (80 Char)
UNIVERSITYID 3 N VARCHAR2 (9 Char)
APPL_NO 4 N NUMBER (11)
APPL_NO_HASH 5 N VARCHAR2 (4000 bytes)
OFFER_EXPIRATION_DATE 6 DATE
APPLICATION_CANCEL_DATE 7 Y DATE
ROOM_HALL 8 Y VARCHAR2 (39 bytes)
ACCEPTED_FLAG 9 Y CHAR (1 byte)
TIMESTAMP (6) Y ACCEPTED_DATE 10
RECORD_CREATE_DATE 11 Y TIMESTAMP (6) systimestamp
When the ACCEPTED_FLAG column is updated, I want an execution of the trigger and upadate a column with sysdate on another table...
That's what I have so far:
CREATE OR REPLACE TRIGGER INTER_SCHEMA. ACCEPTED_DATE_TRIGGER
AFTER UPDATE
OF ACCEPTED_FLAG
WE scheme. ACCOM_OFFER_ACCEPTANCE
REFERENCING NEW AS new OLD IN the old
FOR EACH LINE
BEGIN
insert id whre table_b (column) values (sysdate) =?
END;
Any advice would be appretiated.
Thank you very muchTrigger knows the records that are updated. Trigger can use the recordings ": OLD ' pointer.
You should have the code to something like:update table_b set table_b.column = sysdate) whre id = :old.table_b_id;
And column mus "table_b_id" exist in the ACCOM_OFFER_ACCEPTANCE 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.
-
trigger for update field in a table with the sum of the fields to another table
My experience in creation of triggers and pl/sql in general can be described in terms of oracle with the null value. I practiced by creating arrays and applications on my personal server at home to help me with some of my work related tasks. Right now I am creating a trigger which will, after insert, update, delete on the update of the table assignment_time_track the area of the time_spent on the table of assignments with the sum of the time_spent on the assignment_time_track table fields. I hope that run on the sentence it is clear to the people other than me. I tried this script on my own using the tool of creation of trigger for Oracle Database Express Edition, but I get the following error:
Create a trigger failed, for the following reason:
ORA-06552: PL/SQL: ORA-06553 finished Compilation unit analysis: PLS-320: the declaration of the type of the expression is incomplete or incorrect
Here is my attempt to create the trigger on my own.
create or replace trigger "ASSIGNMENT_TIME_TRACK_T1".
AFTER
INSERT or update or delete on 'ASSIGNMENT_TIME_TRACK '.
for each line
Start
update assignments
Set time_spent = (select sum (time_spent)
of assignment_time_track
where assignment_time_track.name = assignments.name);
end;
/
If what I posted is not clear or more detail is needed, let me know and I will respond with a full description of tables and my goals for each table. Thanks in advance for any help. I also gladly accepts links to tutorials or lessons that explain how to do this kind of thing.
Published by: bobonthenet on March 9, 2009 14:01I think I understand what you mean :)
Rather than use a trigger to keep the master table (assignments) in sync with the time spent on the details, it would be much easier to use a query to do this, maybe creating a view.
Something along the lines of
SQL> create table assignments 2 (id number primary key 3 ,name varchar2(10) 4 ); Table created. SQL> SQL> create table assignment_time_tbl 2 (id number primary key 3 ,assid number references assignments 4 ,time_spent number 5 ); Table created. SQL> SQL> insert into assignments 2 select rownum 3 , 'a' 4 from all_objects 5 where rownum < 5 6 / 4 rows created. SQL> SQL> insert into assignment_time_tbl 2 select rownum 3 , rownum 4 , rownum * 3 5 from all_objects 6 where rownum < 5 7 / 4 rows created. SQL> SQL> commit; Commit complete. SQL> SQL> SQL> select a.id 2 , a.name 3 , (select sum (time_spent) 4 from assignment_time_tbl 5 where assid = a.id 6 ) 7 from assignments a 8 / ID NAME (SELECTSUM(TIME_SPENT)FROMASSIGNMENT_TIME_TBLWHEREASSID=A.ID) ---------- ---------- ------------------------------------------------------------- 1 a 3 2 a 6 3 a 9 4 a 12
Maybe you are looking for
-
Each site has no javascript code
Some websites that I don't have javascript or they (sorry for my English) are messy. Images or videos don't is not loading. He started not so long ago, and I use 17.0.1.
-
Update Win 8.1 - error 0xC100101 - 0 x 30018
HelloSince this morning, I am trying to Win 8 on Win 8.1 update. This works until reboot the laptop. Then win 8 restored and the PC restarted again with the error message that the update failed and the original windows has been restarted with the 0xC
-
I would like to analyze more than 1 photo at a time, but the preview or scan separate file box is there but will not let me check this function so it will separate the photos when they scan... Thanks for any help.
-
I have looked closely at (even vbundle) canned reports and can not find a report that you alow me to select 2 vm and compare it sΔ said last week. Any ideas would be fantastic.
-
Graphics - Intel(r) HD Graphics 4600 failed
I ran analysis with SupportAssist and I came across this. Can someone help me solve this problem?