logo
down
shadow

Oracle PL/SQL: Update table B with aggregation data of table A


Oracle PL/SQL: Update table B with aggregation data of table A

By : Francesco Lanzoni
Date : November 22 2020, 09:00 AM
I wish this help you Frankly I wouldn't use BULK COLLECT and FORALL here - I'd use a MERGE statement. Try something like
code :
MERGE INTO TABLE_B b
  USING (SELECT FIELD1, FIELD2, SUM(FIELD3) AS TOTAL_FIELD3
           FROM TABLE_A
           GROUP BY FIELD1, FIELD2) a
    ON (b.FIELD1 = a.FIELD1 AND
        b.FIELD2 = a.FIELD2)
WHEN NOT MATCHED THEN
   INSERT (FIELD1, FIELD2, FIELD3)
     VALUES (a.FIELD1, a.FIELD2, a.TOTAL_FIELD3)
WHEN MATCHED THEN
   UPDATE
     SET FIELD3 = a.TOTAL_FIELD3;


Share : facebook icon twitter icon
Oracle update one table in relation to entering data into another table

Oracle update one table in relation to entering data into another table


By : user3437829
Date : March 29 2020, 07:55 AM
it fixes the issue the scenario is simple , This trigger does it:
code :
create or replace trigger ins_two after insert on two
for each row
  update one set number_of_relations = number_of_relations + 1
    where one.id = :new.mock_id
insert into two values (1, 'hello');
insert into two values (1, 'hello again');
insert into two values (2, 'hello');

select * from one

        ID NUMBER_OF_RELATIONS
---------- -------------------
         1                   2 
         2                   1
How to update data from source table to Destination table with the help of third table in Oracle?

How to update data from source table to Destination table with the help of third table in Oracle?


By : Tharini Dasanayaka
Date : March 29 2020, 07:55 AM
wish helps you You can make use of temporary table's concept in oracle, which is a modular and easily understandable approach.
code :
create global temporary table TEMP1(
ID VARCHAR2(50), KEY VARCHAR2(50))
ON COMMIT DELETE ROWS;

create global temporary table TEMP2(
KEY VARCHAR2(50), FNAME VARCHAR2(100), LNAME VARCHAR2(100))
ON COMMIT DELETE ROWS;

create global temporary table TEMP3(
ID VARCHAR2(50), FNAME VARCHAR2(100), LNAME VARCHAR2(100))
ON COMMIT DELETE ROWS;  

BEGIN
INSERT INTO TEMP1 (ID, KEY)
(select TABLE1.ID, TABLE2.KEY 
from TABLE1, TABLE2 
where TABLE1.ID = TABLE2.ID

INSERT INTO TEMP2(KEY, FINAME, LNAME)
(SELECT ID, FNAME,LNAME
FROM TABLE3
WHERE TABLE3.KEY IN (SELECT KEY FROM TEMP1)); 

INSERT INTO TEMP3(ID, FNAME, LNAME)
(SELECT TEMP1.ID, TEMP2.FNAME, T2.LNAME 
FROM TEMP1, TEMP2 
WHERE TEMP1.KEY = TEMP2.KEY);

UPDATE TABLE1
SET (TABLE1.FNAME, TABLE1.LNAME) = (SELECT FNAME, LNAME FROM TEMP3
WHERE TEMP3.ID = TABLE1.ID);
commit; 
END
How to update a SQL Server table with updated Oracle table Data

How to update a SQL Server table with updated Oracle table Data


By : Sindhura Kudaravalli
Date : March 29 2020, 07:55 AM
This might help you I am using SQL Server (and Oracle as a linked Server). , to @elizabk, here's the answer.
code :
UPDATE MS 
    SET    MS.NAME = OC.NAME
    FROM   OPENQUERY(WZ12,
      'select EMP, NAME from Test') OC 
   INNER JOIN [dbo].[TEST1] MS 
     ON OC.EMP = MS.EMP
Oracle SQL: Update a table with data from another columns of the same table

Oracle SQL: Update a table with data from another columns of the same table


By : user3181713
Date : March 29 2020, 07:55 AM
I hope this helps you . Table: names , Do you just want a simple update?
code :
update names
    set namemaster = name;
How to update oracle table in Python using data from another table

How to update oracle table in Python using data from another table


By : user3549278
Date : March 29 2020, 07:55 AM
To fix the issue you can do As pointed out in the documentation, you would need to commit the changes as a transaction for them to be available to other users and sessions:
code :
self.DB_conn.commit()
Related Posts Related Posts :
  • Access out parameters of a procedure from another procedure in oracle
  • Oracle - Cannot fetch using table function on type-table, ORA-06504
  • How to mention schema name in dbms_metadata.get_ddl
  • Sum date with a varchar field
  • How I can debug a stored procedure with a VARRAY parameter?
  • test failure:io error: the network adapter could not estailish the connection in sql developer
  • Select all fields from a package datatype
  • Oracle PL/SQL collect values from a loop into a cursor
  • Setting default fetchSize for JOOQ queries
  • Does Oracle's Application Continuity Works only with RAC implementations?
  • Trying to creating a temporary table in a stored procedure
  • PL/SQL local variables dump
  • Oracle APEX tabular form, need to make a column Read Only. Except on a new row when “Add Row” is clicked
  • SQL using Union All solution required
  • Get first date of month in oracle
  • Counting records in a table and updating a table using a cursor
  • plsql tyring to create a string algorithm
  • ORA-00904: Invalid identifier when using forall
  • Oracle 11g error in merge using link on new record in insert statement
  • How to create if-then-else statement in an oracle sql script?
  • Oracle SQL query with CASE WHEN EXISTS subquery optimization
  • Why doesn't the trigger update the column value in an Oracle database?
  • Make a J2EE application avoid updating the DB
  • Trigger with Merge statement in oracle
  • Pl Sql Procedure handle exception while scheduled using oracle scheduler
  • Initialization section of the package
  • Two Oracle TNS Listener
  • oracle how to use schema different from current user?
  • Oracle 12c installation on ubuntu 15.10
  • Oracle APEX PL/SQL dynamic Action Function Body
  • Oracle generated column aliases different on two DB's
  • Max receiving parameter size in Oracle PL/SQL
  • Join two tables by two columns using a third mapping table
  • Oracle 10: pivot and unpivot without using pivot and unpivot
  • Oracle - deleting duplicates
  • How to migrate column data to new data type
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co