Help me in creating a trigger Insert and Update Options
HelloPlease help me in creating a trigger.
My requirement is that, after insert or update on a Table, I want to launch an event.
I have started this way, but does not know how to fully implement it.
I have a dept table
CREATE TRIGGER DepartmentTrigger
INSERT AFTER on Dept
BEGIN
INSERT INTO mytable VALUES("123","Kiran");
END DepartmentTrigger;
Please tell me how I can put the update option also.
Thanks in advance.
Please tell me how I can put the update option also.
Add "or update". ;-)
Here are a few suggestions, but you definitely need to refer to the manual page that suggested the previous poster.
CREATE OR REPLACE the TRIGGER DepartmentTrigger
AFTER INSERT or Update ON Dept
BEGIN
INSERT INTO mytable VALUES(:new.) Dept 'DEPT ADDED OR CHANGED');
END DepartmentTrigger;
The "or replace" means that you can replace the shutter button as you develop without having to type in a drop statement each time. Just change and reissue your script over and over again until you get it right.
The addition of "update or" or "Or remove" fact the trigger too much fire for these events. Note, you peut want separate triggers in different scripts and with different names for each event. You must decide whether your design is really the same thing either an insert or an update.
: new. Dept, this is how you should refer to the vale has changed the Dept column (: old.) Dept is the previous value). I changed the double quotes in the string in the clause VALUES of apostrophes.
Andy
Tags: Database
Similar Questions
-
Create triggers in the table, sequence, insert and update with "model"?
It must be of rtfm, trial and error thing but you wanted to ask, is it possible to have models or similar automation for the following scenario:
1.), I add the table to the logic model
2.) Using glossary I transform a relational model that was recovered / synchronized with the data dictionary
3.) then I have the new table to add
-but
I would then have auto-DDL of to be synchronized to database:
-create sequence for the id column
-create table
-create indexes for the id column pk
-Create triggers for insert and update
-l' idea is to have db_created_dt and db_modified_dt defined in the table, so that each table has them to the fields of record etc.
-activate the triggers
Each of them following the same naming convention.
Similarity with approx. generator Apex workshop utils sql create table of the copy paste "excel" that creates 'id' - column + sequence and insert the trigger.
rgrds Paavo
Hi Paavo,
most of the steps can be made in one or other way
-create sequence for the id column
-create table
-create indexes for the id column pk
If you want to start in the logic model and you don't want to have the ID column in the logic model and select 'Create the surrogate key' checkbox in the dialog entity - you will get an identity column in the relational model and the version of database and settings in ' preferences > Data Modeler > model > physics > Oracle "you can set the sequence generation and the trigger for taking in load.
fields of record defined in the table, so that each table has them
You can add the same set of columns in all tables with the transformation script 'model of Table... ».
You can also look here Oracle SQL Developer Data Modeler 4.1 user - defined DDL generation using transformation scripts
to see how to grant your DDL generation using the transformation script. DM comes with example to generate separate tables of logging and triggers. You can create your build script of triggers that support logging in these common columns.
Philippe
-
Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE Production 11.2.0.4.0
AMT for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
I create the structure of the table like that.
create table test1 (a primary key, b (2) char number, date c, d varchar2 (10), date of e);
create table test2 (number of ab, cd (2) tank, date of the ef, gh varchar2 (10), date of the ij, kl varchar2 (100));
Create materialized view log on test1;
create materialized view fast refresh test1_v on commit in select * from test1;
I have create a trigger of the sample
CREATE OR REPLACE TRIGGER test1_trig
AFTER INSERT OR UPDATE OR DELETE
ON test1_v
FOR EACH LINE
DECLARE
lr_test2 test2% ROWTYPE;
lv_error VARCHAR2 (4000);
BEGIN
lr_test2. AB: =: NEW.a;
lr_test2. CD: =: NEW.b;
lr_test2. GH: =: NEW.d;
IF THE INSERTION
THEN
lr_test2. EF: = SYSDATE;
lr_test2.IJ: = SYSDATE;
lr_test2.KL: = 'INSERT ';
INSERT INTO test2
VALUES lr_test2;
ELSIF UPDATE
THEN
lr_test2.IJ: = SYSDATE;
lr_test2.KL: = 'UPDATE ';
UPDATE test2 = lr_test2 ab WHERE = LINE: OLD.a;
ELSIF REMOVAL
THEN
DELETE FROM test2
AB = WHERE: old.a;
END IF;
EXCEPTION
WHILE OTHERS
THEN
lv_error: = SQLERRM;
INSERT INTO XXDOMINO_FG_DATA_LOAD_ERROR
VALUES ('test1_trig',
: OLD.a,.
"test1_trig,"
LV_ERROR,
SYSDATE);
COMMIT;
END test1_trig;
/
So, if check you my code,.
When I insert EF = SYSDATE, IJ = SYSDATE.
Update EF is not changed, IJ = SYSDATE.
So I like to capture their insertion and update dates.
But if updates or insert arrives on the materialized table. The trigger themselves as an INSERT only.
So how do you capture the updates?
I use the statemnet with out merger with performance and also able to capture the update dates.
CREATE OR REPLACE TRIGGER test1_trig_merge
AFTER INSERT OR UPDATE OR DELETE
ON test1_v
FOR EACH LINE
DECLARE
lr_test2 test2% ROWTYPE;
lv_error VARCHAR2 (4000);
BEGIN
IF THE REMOVAL
THEN
DELETE FROM test2
AB = WHERE: old.a;
ELSIF INSERTION
THEN
MERGE INTO test2 one
B using (SELECT 1 FROM DUAL)
WE (ab =: new.a)
WHEN MATCHED
THEN
UPDATE the VALUE ab =: NEW.a.
CD =: NEW.b,
GH =: NEW.c
IJ = SYSDATE,
KL = "Update"
AB WHERE =: old.a
WHEN NOT MATCHED
THEN
INSERTING VALUES (: NEW.a,)
: NEW.b,.
: NEW.c.
: NEW.d,.
: NEW.e,.
"INSERT");
END IF;
EXCEPTION
WHILE OTHERS
THEN
lv_error: = SQLERRM;
INSERT INTO XXDOMINO_FG_DATA_LOAD_ERROR
VALUES ('test1_trig',
: OLD.a,.
"test1_trig,"
LV_ERROR,
SYSDATE);
END test1_trig_merge;
/
DISPLAY ERRORS;
-
Mr President
Jdev worm is 12.2.1
How to modify and update a line later was inserted and updated in the doDML() method?
I added two rows in my table a method of action-listener in bean managed and secondly with operation doDML() as below.
Method 1-first row in managed bean
public void addNewPurchaseVoucher(ActionEvent actionEvent) { // Add event code here... BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator"); RowSetIterator rsi = dciter.getRowSetIterator(); Row lastRow = rsi.last(); int lastRowIndex = rsi.getRangeIndexOf(lastRow); Row newRow = rsi.createRow(); newRow.setNewRowState(Row.STATUS_NEW); rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow); rsi.setCurrentRow(newRow); BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator"); RowSetIterator rsi1 = dciter1.getRowSetIterator(); Row lastRow1 = rsi1.last(); int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1); Row newRow1 = rsi1.createRow(); newRow1.setNewRowState(Row.STATUS_NEW); rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1); rsi1.setCurrentRow(newRow1); }
Method of doDML() of line 2 seconds in the entityImpl class
protected void doDML(int operation, TransactionEvent e) { setAmount(getPurqty().multiply(getUnitpurprice())); if (operation == DML_INSERT) { insertSecondRowInDatabase(getVid(),getLineitem(),getDebitst(), (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100)); } if(operation == DML_UPDATE) { updateSecondRowInDatabase(getVid(),getLineitem(),getDebitst(), (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100)); } super.doDML(operation, e); } private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4) { PreparedStatement stat = null; try { String sql = "Insert into vdet (VID,LINEITEM,DEBITST,AMOUNT) values ('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "')"; System.out.println("sql= " + sql); stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } } private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4) { PreparedStatement stat = null; try { String sql = "update vdet set vid='"+ value1+"',lineitem='"+ value2+"',DEBITST='" + value3 + "', AMOUNT='" + value4 + "' where VID='" + VID + "'"; System.out.println("sql= " + sql); stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } }
Now the problem is that when later I change the quantity and price of the first line isn't updated but second row, because I used the command
<af:button actionListener="#{bindings.Commit.execute}" text="Commit"
This button update the first line added by bean managed, but the second row remains unchanged.
Please help how to update the two lines with the same button or something else.
Concerning
DML_UPDATE will call only if there is some change data attributes.
I guess that the update statement is false because vid looks like a primary key for the table, then, how update you the primary key of the update statement and how the update condition statement where the vid = '0'
I assume the update statement should look like:
private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4) { PreparedStatement stat = null; try { String sql = "update vdet set lineitem='" + value2 + "',DEBITST='" + value3 + "', AMOUNT='" + value4 + "' where VID='" + value1 + "'"; System.out.println("sql= " + sql); stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } }
-
Add error causing senior in 4.2.1 when inserting and updating same time
Hi all
I have problems with the top to add a line in a table.
There is already a thread here on how to add the line above in table form in version 4.0.
We have recently upgraded to version 4.2.1 Apex.
Since then we have question while inserting a new line and update an existing line at the same time, and then click Save button causing the error below:
Current version of the data in the database has changed since the user initiated the update process. version of current line identifier = "xxxxxx" line application version identifier = "xxxxxx".
But insert a new record and update an existing record works well separately with an error.
Here's the code to add the line at the top of page header HTML<script language="javascript" type="text/javascript"> function addRowTop() { apex.widget.tabular.addRow(); apex.jQuery(apex.widget.tabular.gTabForm).find(".highlight-row").last() .insertBefore(apex.jQuery(apex.widget.tabular.gTabForm). find(".highlight-row").first()); } </script>
If I use by default addRow so absolutely no problem to insert and update at the same time.
Here is the example of work in the workspace apex.
Looks like a bug to me.
Can any of the Oracle team please see this and let us know if it needs a patch.
Thank you
REDA
Not sure that I consider this a bug since you are somehow hacking the default functionality of the APEX. Maybe you could add a feature request 'Add Top line' to https://apex.oracle.com/vote
It seems that you hit some enhancments to safety that have been made to the tabular forms. You should be able to work around it by putting the new lines to the bottom of the form before submitting the page.
Create a dynamic action based on the click of the submit button.
Event: click on
Selection type: button
Button: SUBMIT (Submit)
Condition: - no requirement.
Add real action to run the JavaScript Code:
Action: run the JavaScript Code
Fire when the result of the event is: true
Fire on Page load: [disabled]
Code:
apex.jQuery(apex.widget.tabular.gTabForm).find("input[value=''][name='frowid']").closest(".highlight-row") .insertAfter(apex.jQuery(apex.widget.tabular.gTabForm).find(".highlight-row").last());
Add a real action to send the page:
Action: send the Page
E: Nam request/buttonSUBMIT
-Jeff
-
INSERT and UPDATE audit generating more lines expected in $ AUD
Environment:
Oracle 11.2.0.3 EE on Solaris
I had a request for verification of the INSERT and UPDATE on the activities of all the tables in a particular schema. It was in anticipation of a request that will live and the owner wanted to see a 'typical' of some test users activity.
Here are the steps I took:
I also "audit_sys_operations = TRUE' so I know I'll take some SYS audit data in $ AUD as well, but I can ask around those."alter system set audit_trail=DB_EXTENDED scope=spfile; Bounce the instance audit INSERT table, UPDATE table by USERX;
My question is that I see several connections from the application server with "LOGIN" and "LOGOUT" actions and I don't know why they are appearing in the table of AUD $.
Is it because I have auditing enabled for inserts and updates on all THE tables for USERX and opening operations and logoff do I/O in tables that are not owned by USERX under logon logoff procedure?
I'm a newbie audit and the docs I read not answered this question.
I just found an article on the value of 'SESSION_REC' of ACTION_NAME and I need to change my check to "by access. I'll change that and see what happens, but it shouldn't change my question.
Thanks much for any help!
-garyHello
I have the SYS activities audited but I never said anything about the session auditing for this particular user.
"audit session;" check all successful and failed connections to and disconnections of the database, regardless of the user, by session
Is there a way to confirm what has been turned on for auditing?
You can check with the following query
Select * from dba_stmt_audit_opts;
Select * from dba_priv_audit_opts;You can also check out the link below for more deatails
http://psoug.org/reference/auditing.html -
FORALL using insert and update
Hello
I want to use FORALL for insert and update at the same time in a single FORALL...
It's like...
FORALL INDX IN 1... record. Count
insert into Table values (record (i)); - Table is updated with some values in the column
Update Table
Set table.col10 = (select val table11 where table11.column = record.count (i))
-update the Table by taking the value of some other column table... passing the parameter each time...
Help, please...Refer to this
http://docs.Oracle.com/CD/B19306_01/AppDev.102/b14261/forall_statement.htm
But why PL SQL?
You can do this with the Merge statement
http://docs.Oracle.com/CD/B19306_01/server.102/b14200/statements_9016.htm
Mezaber
-
Combining insert and update to a form?
Hello
I am a developer web amateur who is new to dynamic Web sites, php and dreamweaver. I am currently working on a project that uses many forms to send data to a database.
Data that are inserted must also be available to update if necessary. so I need currently 2 versions of each form 1 to insert and the other for the update.
Is it possible to use a single form for insert and update, instead of using 2 forms 1 for each function. This would help reduce the level of duplication on the site.
If so is anyway to do this in Dreamweaver? or could someone point me to an example of how this can be achieved.
Thank you all
Thanks for the information, disappointing that Dreamweaver cannot handle it, but at least I know where I am...
Looks like that's what I need... http://forums.Adobe.com/message/1927405
Once again thanks for your help
-
Insert and update server behaviors in the same form
I have a php form that is inserted into a table and then update another table. I have the form of inserting the record first and then I want to update the other table. I'm starting to learn and understand PHP, but I don't know how to have the update function to run after that it inserts the records. I guess that's something like if you insert this disc, then update this record and then go to the redirect page. I know this goes to redirect page after it inserts the record, but I don't know how to tell him not to go to the $insertGoTo. I want him to run the following update function and then go to the $insertGoTo and not the $updateGoTo. Thanks in advance for any help.
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO employee (CompId, empfirstname, empmiddleint, emplastname, EmpType, EmpStatus) VALUES (%s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['CompId'], "int"), GetSQLValueString($_POST['empfirstname'], "text"), GetSQLValueString($_POST['empmiddleint'], "text"), GetSQLValueString($_POST['emplastname'], "text"), GetSQLValueString($_POST['EmpType'], "text"), GetSQLValueString($_POST['EmpStatus'], "text")); mysql_select_db($database_dotweb, $dotweb); $Result1 = mysql_query($insertSQL, $dotweb) or die(mysql_error()); $insertGoTo = "Roster.php?CompId=" . $_POST['CompId'] . ""; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE company SET CompanyType=%s WHERE CompId=%s", GetSQLValueString($_POST['CompanyType'], "text"), GetSQLValueString($_POST['CompId'], "int")); mysql_select_db($database_dotweb, $dotweb); $Result1 = mysql_query($updateSQL, $dotweb) or die(mysql_error()); $updateGoTo = "purchases.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); }
PHP code is executed from top down and is controlled by the conditional statements ('if' blocks). To achieve what you want, you need to combine the conditional statements that control the insert and update server behaviors and to move the redirect to the end of the code. Amend as follows:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO employee (CompId, empfirstname, empmiddleint, emplastname, EmpType, EmpStatus) VALUES (%s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['CompId'], "int"), GetSQLValueString($_POST['empfirstname'], "text"), GetSQLValueString($_POST['empmiddleint'], "text"), GetSQLValueString($_POST['emplastname'], "text"), GetSQLValueString($_POST['EmpType'], "text"), GetSQLValueString($_POST['EmpStatus'], "text")); mysql_select_db($database_dotweb, $dotweb); $Result1 = mysql_query($insertSQL, $dotweb) or die(mysql_error()); $updateSQL = sprintf("UPDATE company SET CompanyType=%s WHERE CompId=%s", GetSQLValueString($_POST['CompanyType'], "text"), GetSQLValueString($_POST['CompId'], "int")); mysql_select_db($database_dotweb, $dotweb); $Result1 = mysql_query($updateSQL, $dotweb) or die(mysql_error()); $insertGoTo = "Roster.php?CompId=" . $_POST['CompId'] . ""; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); }
-
Insert and update by the select statement
Hi all
How can I insert and update in an oracle 10g database table
by a select statement. do not merge.Florian wrote:
Hi all
How can I insert and update in an oracle 10g database table
by a select statement. do not merge.
>How can I insert and update in a table of database oracle 10g via a select statement. do not merge.
Do you mean by using subqueries?
Something like
insert into whatever ...select statement update whatever set (column, column) = (select column, column ...)
There is a lot of information on this topic in the online documentation
-
apostrophe problem for insert and update pages
I read in the book "Dreamweaver MX dynamic Applications" that a solution must be placed in the ASP to insert code and form fields record updated to replace the apostrophes by their equivalent html entity character (') before its entry in a database do not have SQL wrong interpret the entered text. How would you say this hotfix is essential because I tested my form with apostrophes and have not gotten into trouble yet?> I read in the book "Dreamweaver MX dynamic Applications" as a fix
> should
> place in the ASP code for insert and update the fields of the registration form to
> replace
> apostrophes with their equivalent html entity character (') before his
> entry
> in a database do not have SQL wrong interpret the entered text. How
> Essentials
> would you say this fix is that I tested my form with single quotes and
> have
> not got any trouble yet?If you are user of Jack and sending it to the db in plaintext in
the query, and then people can use techniques of SQL injection basically destroy
your database:http://en.Wikipedia.org/wiki/SQL_injection
So, Yes, it's a pretty serious problem.
-Darrel
-
How to write insert and update blocks about with an if
Hai All
How to write an insert and update block education about with in an if
I had a condition Ie
If the time is between 0630 and 1030
then
Insert into Daily_attend
----
Update Daily_attend set
-----
Concerning
Srikkanth.MThere is nothing preventing you to do this:
BEGIN INSERT INTO x (mycolumn) VALUES ('A'); UPDATE x SET mycolumn = 'B' WHERE mycolumn = 'A'; COMMIT; END; /
other than the fact that he seems a bit inefficient. Yet once you try to do, and why, is not clear.
Can you put an IF statement in there to choose one way or the other under certain conditions? Yes. But I wonder if what you
are actually trying to do is to reinvent the MERGE statement.
http://www.morganslibrary.org/reference/merge.html -
How to create a voice recorder with pause, insert and replace option
I want to create a recorder of the word where I can insert an audio between the two already created voice file. It should be able to record audio, and then retrieve it later and play, insert a new record into the current file, overwrite the files. Help, please!
Check the first link, you get an array of bytes as a result:
_data = _output.toByteArray ();If you take half of the content you delete the second half of the record. If you create a larger painting and copy the old and something new add you etc.
-
How to create the trigger insert for DBSequence? 10.1.3 Jdev
Hello.. I m trying to create a field DBSequence and I read you need to create an insert on it s trigger...
This trigger is in the database or in Jdeveloper... If it s in Jdeveloper how can I do this?
Thank you.User,
You can create the trigger in the database or write code in the class of java feature object to do.
You can have a reading in the developer's Guide to the ADF for forms/4GL developers 6.6.3.8 section to know more about the trigger of the DB. 9.4.1.2 section talking about how to do java EO class if you prefer this method.
John
-
Create a trigger instead of update several tables in a view
Dear everybody
I am trying to create a trigger that updates instead of to day joined several tables in a view, but I can't get my trigger to work. The create view command was as follows:
The view above connects a polygon table to the table of function names which means that a polygon appears several times in a view, even though one version of the polygon exists in the base table. This means the direct update of view cannot take place, since 1 polygon can appear multiple times in a view. The two original base tables and their columns names are:CREATE OR REPLACE VIEW VIEW_MI_JOIN_GC AS SELECT MAP_INDEX.mi_prinx, index_type_id, original_map_publication_id, original_map_sheet_number_id, name_of_feature, geog_coordinates_id, GEOG_COORDINATES.mi_prinx AS "mi_prinx_polygon", GEOG_COORDINATES.geographical_coordinates, GEOG_COORDINATES.mapinfo_style_row FROM MAP_INDEX JOIN GEOG_COORDINATES ON geog_coordinates_id=GEOG_COORDINATES.mi_prinx;
Relax, I created was as follows:MAP_INDEX --------- MI_PRINX INDEX_TYPE_ID ORIGINAL_MAP_PUBLICATION_ID ORIGINAL_MAP_SHEET_NUMBER_ID NAME_OF_FEATURE MAPINFO_STYLE_ROW GEOGRAPHICAL_COORDINATES GEOG_COORDINATES_ID GEOG_COORDINATES ---------------- MI_PRINX GEOGRAPHICAL_COORDINATES MAPINFO_STYLE_ROW
The idea is that when I draw a new polygon in MapInfo and assign him a revised number geog_coordinates_id and the number of mi_prinx_polygon, which are the same, once I have save the view as then it updates the underlying tables. Geographical_coordinates and mapinfo_style_row of map_index table columns are columns with ancient polygon data which while not having currently new data inserted into them, are required for the previous data they contain. These data are currently being added to the geog_coordinates table with other scripts. The idea is that all the data is then read using a view and updates made to the view, triggering instead of relaxing, so data are not duplicated but still visible as if it were.CREATE OR REPLACE TRIGGER TRIG_VIEW_MI_JOIN_GC INSTEAD OF UPDATE ON VIEW_MI_JOIN_GC REFERENCING NEW AS NEW FOR EACH ROW BEGIN UPDATE MAP_INDEX SET mi_prinx = :NEW.mi_prinx, index_type_id = :NEW.index_type_id, original_map_publication_id = :NEW.original_map_publication_id, original_map_sheet_number_id = :NEW.original_map_sheet_number_id, name_of_feature = :NEW.name_of_feature, mapinfo_style_row = :NEW.mapinfo_style_row, geographical_coordinates = :NEW.geographical_coordinates, geog_coordinates_id = :NEW.geog_coordinates_id WHERE geog_coordinates_id = :OLD.geog_coordinates_id; UPDATE GEOG_COORDINATES SET mi_prinx = :NEW.mi_prinx, geographical_coordinates = :NEW.geographical_coordinates, mapinfo_style_row = :NEW.mapinfo_style_row WHERE mi_prinx = :OLD.mi_prinx; END; /
When I created first the relaxation above in SQLdeveloper it seems to run constantly. Then my computer crashed, not related to this work, and I lost session because I did not commit it. I was not ready to commit it because I believe that something is wrong.
I am in the trigger syntax correctly and I go about it in the right way? I want to only update the rows that have changed, that's why I was using: NEWS and: OLD.
Kind regards
Tim
Published by: user467357 on November 18, 2008 18:07
I modified my script a little because there were a few errors. for example. start and old as old and view name typoSomething like this->
satyaki> satyaki>select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod PL/SQL Release 10.2.0.3.0 - Production CORE 10.2.0.3.0 Production TNS for 32-bit Windows: Version 10.2.0.3.0 - Production NLSRTL Version 10.2.0.3.0 - Production Elapsed: 00:00:01.78 satyaki> satyaki> satyaki>create table MAP_INDEX 2 ( 3 mi_prinx NUMBER(10) not null, 4 index_type_id NUMBER(6) not null, 5 original_map_publication_id NUMBER(6) not null, 6 original_map_sheet_number_id NUMBER(6) not null, 7 name_of_feature VARCHAR2(80) not null, 8 mapinfo_style_row VARCHAR2(80), 9 geographical_coordinates SDO_GEOMETRY, 10 geog_coordinates_id NUMBER(10), 11 constraints pk_mi_prinx primary key(mi_prinx) 12 ); Table created. Elapsed: 00:00:04.39 satyaki> satyaki>create table GEOG_COORINDATES 2 ( 3 mi_prinx NUMBER(10) not null, 4 geographical_coordinates SDO_GEOMETRY, 5 mapinfo_style_row VARCHAR2(80), 6 constraints pk_mi_prinx_n primary key(mi_prinx) 7 ); Table created. Elapsed: 00:00:00.30 satyaki> satyaki> satyaki>CREATE OR REPLACE VIEW VIEW_MI_JOIN_GC 2 AS 3 SELECT MAP_INDEX.mi_prinx, 4 MAP_INDEX.index_type_id, 5 MAP_INDEX.original_map_publication_id, 6 MAP_INDEX.original_map_sheet_number_id, 7 MAP_INDEX.name_of_feature, 8 MAP_INDEX.geog_coordinates_id, 9 GEOG_COORINDATES.mi_prinx AS "mi_prinx_polygon", 10 GEOG_COORINDATES.geographical_coordinates, 11 GEOG_COORINDATES.mapinfo_style_row 12 FROM MAP_INDEX , GEOG_COORINDATES 13 WHERE MAP_INDEX.geog_coordinates_id=GEOG_COORINDATES.mi_prinx; View created. Elapsed: 00:00:00.32 satyaki> satyaki> satyaki>insert into MAP_INDEX values( 2 &mi_prinx, 3 &index_type_id, 4 &original_map_publication_id, 5 &original_map_sheet_number_id, 6 '&name_of_feature', 7 '&mapinfo_style_row', 8 null, 9 &geog_coordinates_id); Enter value for mi_prinx: 1 old 2: &mi_prinx, new 2: 1, Enter value for index_type_id: 44 old 3: &index_type_id, new 3: 44, Enter value for original_map_publication_id: 5678 old 4: &original_map_publication_id, new 4: 5678, Enter value for original_map_sheet_number_id: 356 old 5: &original_map_sheet_number_id, new 5: 356, Enter value for name_of_feature: AA old 6: '&name_of_feature', new 6: 'AA', Enter value for mapinfo_style_row: GG old 7: '&mapinfo_style_row', new 7: 'GG', Enter value for geog_coordinates_id: 9 old 9: &geog_coordinates_id) new 9: 9) 1 row created. Elapsed: 00:00:00.16 satyaki>/ Enter value for mi_prinx: 2 old 2: &mi_prinx, new 2: 2, Enter value for index_type_id: 55 old 3: &index_type_id, new 3: 55, Enter value for original_map_publication_id: 6789 old 4: &original_map_publication_id, new 4: 6789, Enter value for original_map_sheet_number_id: 357 old 5: &original_map_sheet_number_id, new 5: 357, Enter value for name_of_feature: BB old 6: '&name_of_feature', new 6: 'BB', Enter value for mapinfo_style_row: 10 old 7: '&mapinfo_style_row', new 7: '10', Enter value for geog_coordinates_id: 8 old 9: &geog_coordinates_id) new 9: 8) 1 row created. Elapsed: 00:00:00.04 satyaki> satyaki>commit; Commit complete. Elapsed: 00:00:00.03 satyaki> satyaki> satyaki>insert into GEOG_COORINDATES values(&mi_prinx,null,'&mapinfo_style_row'); Enter value for mi_prinx: 9 Enter value for mapinfo_style_row: FFG old 1: insert into GEOG_COORINDATES values(&mi_prinx,null,'&mapinfo_style_row') new 1: insert into GEOG_COORINDATES values(9,null,'FFG') 1 row created. Elapsed: 00:00:00.07 satyaki>/ Enter value for mi_prinx: 8 Enter value for mapinfo_style_row: GGT old 1: insert into GEOG_COORINDATES values(&mi_prinx,null,'&mapinfo_style_row') new 1: insert into GEOG_COORINDATES values(8,null,'GGT') 1 row created. Elapsed: 00:00:00.05 satyaki> satyaki>commit; Commit complete. Elapsed: 00:00:00.02 satyaki> satyaki>select * from VIEW_MI_JOIN_GC; MI_PRINX INDEX_TYPE_ID ORIGINAL_MAP_PUBLICATION_ID ORIGINAL_MAP_SHEET_NUMBER_ID NAME_OF_FEATURE GEOG_COORDINATES_ID mi_prinx_polygon GEOGRAPHICAL_COORDINATES(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES) ---------- ------------- --------------------------- ---------------------------- -------------------------------------------------------------------------------- ------------------- ---------------- --------------------------------------------------------------------------------------------------------------- 1 44 5678 356 AA 9 9 2 55 6789 357 BB 8 8 Elapsed: 00:00:00.09 satyaki> satyaki> satyaki>CREATE OR REPLACE TRIGGER TRIG_VIEW_MI_JOIN_GC 2 INSTEAD OF UPDATE ON VIEW_MI_JOIN_GC 3 FOR EACH ROW 4 DECLARE 5 m_info_svw varchar2(80); 6 BEGIN 7 m_info_svw := :NEW.mapinfo_style_row; 8 9 UPDATE MAP_INDEX 10 SET mi_prinx = :NEW.mi_prinx, 11 index_type_id = :NEW.index_type_id, 12 original_map_publication_id = :NEW.original_map_publication_id, 13 original_map_sheet_number_id = :NEW.original_map_sheet_number_id, 14 name_of_feature = :NEW.name_of_feature, 15 mapinfo_style_row = m_info_svw, 16 geographical_coordinates = :NEW.geographical_coordinates, 17 geog_coordinates_id = :NEW.geog_coordinates_id 18 WHERE geog_coordinates_id = :OLD.geog_coordinates_id; 19 UPDATE GEOG_COORINDATES 20 SET mi_prinx = :NEW.geog_coordinates_id, 21 geographical_coordinates = :NEW.geographical_coordinates, 22 mapinfo_style_row = m_info_svw 23 WHERE mi_prinx = :OLD.geog_coordinates_id; 24 END; 25 / Trigger created. Elapsed: 00:00:00.20 satyaki> satyaki>select * from VIEW_MI_JOIN_GC; MI_PRINX INDEX_TYPE_ID ORIGINAL_MAP_PUBLICATION_ID ORIGINAL_MAP_SHEET_NUMBER_ID NAME_OF_FEATURE GEOG_COORDINATES_ID mi_prinx_polygon GEOGRAPHICAL_COORDINATES(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES) ---------- ------------- --------------------------- ---------------------------- -------------------------------------------------------------------------------- ------------------- ---------------- --------------------------------------------------------------------------------------------------------------- 1 44 5678 356 CC 9 9 2 55 6789 357 BB 8 8 Elapsed: 00:00:00.09 satyaki> satyaki>select mi_prinx,mapinfo_style_row from GEOG_COORINDATES; MI_PRINX MAPINFO_STYLE_ROW ---------- -------------------------------------------------------------------------------- 9 FFG 8 GGT Elapsed: 00:00:00.07 satyaki>select * from MAP_INDEX; MI_PRINX INDEX_TYPE_ID ORIGINAL_MAP_PUBLICATION_ID ORIGINAL_MAP_SHEET_NUMBER_ID NAME_OF_FEATURE MAPINFO_STYLE_ROW GEOGRAPHICAL_COORDINATES(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), S ---------- ------------- --------------------------- ---------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ------------------------------------------------------------------- 1 44 5678 356 CC HHH 2 55 6789 357 BB HHH Elapsed: 00:00:00.12 satyaki> satyaki>update VIEW_MI_JOIN_GC 2 set name_of_feature = 'DD' 3 where mi_prinx = 1; 1 row updated. Elapsed: 00:00:00.05 satyaki> satyaki>select * from VIEW_MI_JOIN_GC; MI_PRINX INDEX_TYPE_ID ORIGINAL_MAP_PUBLICATION_ID ORIGINAL_MAP_SHEET_NUMBER_ID NAME_OF_FEATURE GEOG_COORDINATES_ID mi_prinx_polygon GEOGRAPHICAL_COORDINATES(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES) ---------- ------------- --------------------------- ---------------------------- -------------------------------------------------------------------------------- ------------------- ---------------- --------------------------------------------------------------------------------------------------------------- 1 44 5678 356 DD 9 9 2 55 6789 357 BB 8 8 Elapsed: 00:00:00.08 satyaki> satyaki>select mi_prinx,mapinfo_style_row from GEOG_COORINDATES; MI_PRINX MAPINFO_STYLE_ROW ---------- -------------------------------------------------------------------------------- 9 FFG 8 GGT Elapsed: 00:00:00.06 satyaki> satyaki>update VIEW_MI_JOIN_GC 2 set mapinfo_style_row = 'OOOO' 3 where mi_prinx = 1; 1 row updated. Elapsed: 00:00:00.05 satyaki> satyaki>select mi_prinx,mapinfo_style_row from GEOG_COORINDATES; MI_PRINX MAPINFO_STYLE_ROW ---------- -------------------------------------------------------------------------------- 9 OOOO 8 GGT Elapsed: 00:00:00.06 satyaki> satyaki>select mapinfo_style_row from MAP_INDEX; MAPINFO_STYLE_ROW -------------------------------------------------------------------------------- OOOO HHH Elapsed: 00:00:00.06 satyaki>
Hope this will help you.
Kind regards.
LOULOU.
Maybe you are looking for
-
How to merge Photos with IPhoto
Just realized that I am under IPhoto and photo on my IMac how to merge these two? or just delete the old APP?
-
Designjet T520 36 inches (CQ893): Designjet T520 36 - in
My tracer: HP designjet T520 36 inches (CQ893) start. The screen is blue, B87E7114 error code Turn off and turn on probably. Power button 15 seconds and powering button 50 seconds also. If push yellow power light. power on no beep error. End of warra
-
I updated my windows media player 10 or 11, and the information album site is messed up. It won't change my album information. Please fix the site.
-
RACAgent.exe hogging CPU
I installed Vista Home Premium SP1.RACAgent.exe is striking almost 50% of my CPU.Cannot find anything anywhere on why this is happening.I think that this exe is owned by reliability monitor, but when I go to Task Scheduler, I don't see the parameters
-
Contacting a representative of MS tech
I sent a query about my problem with IE8 on WIN7 and received a reply, but to meet the tech rep email address that it provided seems to be invalid or not recognized. Here's his address: * email address is removed from the privacy *. And follows the