Discussions
Categories
- 197K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.8K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 556 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 468 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
insert values using trigger

Data will be first inserted into temp_data(using oracle APEX DML process) after the insertion comlplete i need to get those records and insert into temp_head and temp_detail. In, temp_head i need to insert sum on RATE and sum of Total when ID is same and in temp_detail there will be line wise entry same as temp_data based on ID.
create table temp_head(id number,rate number,total number);create table temp_detail(id number,rate number,total number);create table temp_data (id number,rate number,total number);insert into temp_data(1001,100,100);insert into temp_data(1001,200,200);insert into temp_data(1001,300,300);insert into temp_data(1002,400,400);insert into temp_data(1002,500,500); commit;
TEMP_DATA
id rate total
1001 100 100
1001 200 200
1001 300 300
1002 400 400
1002 500 500
So, expected output of TEMP_HEAD for ID = 1001 and ID = 1002:
id rate total
1001 600 600
1002 900 900
TEMP_DETAIL
id rate total
1001 100 100
1001 200 200
1001 300 300
1002 400 400
1002 500 500
is there any way i can accomplish this using trigger.
Answers
-
Why do you want a trigger for this?
If you're using apex, then you just need to create another process to happen after the insertion(s) have taken place, and then apply whatever insert code you want in that.
-
-
Thanks for feed back. Please consider DML process as which APEX provides which is inbuilt process where by i don't have to code manually which is better that way only.
-
On insert/update/delete trigger on table temp_detail, adjust that row's ID totals in table temp_head.
But the solution you are describing here sounds flawed. Why temp tables? Why duplicate rows from the data table into the detail table? What is the use case for the header table?
-
Billy~Verreynne wrote:On insert/update/delete trigger on table temp_detail, adjust that row's ID totals in table temp_head.But the solution you are describing here sounds flawed. Why temp tables? Why duplicate rows from the data table into the detail table? What is the use case for the header table?
- temp tables are just naming convection so can create a show case to put here.
- header table will further be processed for other operations as well as detail table.
- its not duplicate data every table will be used for different purposes.
Thank you
-
Marco Foxx wrote:Thanks for feed back. Please consider DML process as which APEX provides which is inbuilt process where by i don't have to code manually which is better that way only.
Sorry, that doesn't make sense. Apex is meant to be coded just as much as we write code on the database.
If you must, then write a procedure on the database and have a post insertion process in Apex that calls that.
Triggers are not the correct place to be analysing and doing DML that isn't solely related to the table that the trigger is on.