Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Create an sql script that compares two dbase and updates dbase and insert date of update in a column in oracle 11g

Create an sql script that compares two dbase and updates dbase and insert date of update in a column in oracle 11g

Scheduled Pinned Locked Moved Database
databaseoracletoolshelpquestion
18 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    What have you tried? Where are you stuck? Where's the problem?

    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

    M Offline
    M Offline
    Miguel Quintanilla
    wrote on last edited by
    #3

    The problem is that i am new at this and i need all the help i can get i have tried with program that compares and execute the changes but i need help qith some script so i can make a bat file that excutes every hour i am fresh at this and need all the help i can get. I can c++, java and some sql but i nned help with oracle.

    L 1 Reply Last reply
    0
    • M Miguel Quintanilla

      The problem is that i am new at this and i need all the help i can get i have tried with program that compares and execute the changes but i need help qith some script so i can make a bat file that excutes every hour i am fresh at this and need all the help i can get. I can c++, java and some sql but i nned help with oracle.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #4

      Miguel Quintanilla wrote:

      I can c++, java and some sql but i nned help with oracle.

      I've never worked in C++ nor Java, but the Oracle-database speaks SQL.

      Miguel Quintanilla wrote:

      and need all the help i can get.

      What are you trying to achieve (on a higher level)? Create some kind of synchronization?

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      M 1 Reply Last reply
      0
      • M Miguel Quintanilla

        Hi i need some help creating an sql script that can update info from one table in dbase1 to another table in dbase2 that has the same columns and if posible insert date and time in one column when the syncronized is done in the table thats modified? Can anyone help me whit this?

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #5

        We won't actually do the writing for you but will help when you have a problem (not the entire process). Try breaking it down into smaller bits. Write a query that compares the 2 tables and identifies the records that need to be updated. Test it Now change the query to do the actual update. Create a stored procedure using the update query. Look into database job scheduling to call the stored procedure you have created (I know SQL Server but not Oracle). If this is beyond you then you need to get some education in working with a database, specifically Oracle which is not a trivial exercise.

        Never underestimate the power of human stupidity RAH

        M 1 Reply Last reply
        0
        • L Lost User

          Miguel Quintanilla wrote:

          I can c++, java and some sql but i nned help with oracle.

          I've never worked in C++ nor Java, but the Oracle-database speaks SQL.

          Miguel Quintanilla wrote:

          and need all the help i can get.

          What are you trying to achieve (on a higher level)? Create some kind of synchronization?

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

          M Offline
          M Offline
          Miguel Quintanilla
          wrote on last edited by
          #6

          I have done this on TOAD for oracle: -- run every 5 MINUTES BEGIN dbms_scheduler.create_schedule( schedule_name => 'INTERVAL_EVERY_5_MINUTES', start_date => trunc(sysdate)+18/24, repeat_interval => 'freq=MINUTELY;interval=5', comments => 'Runtime: Every day all 5 minutes'); END; / begin -- Call a procedure of a database package dbms_scheduler.create_program (program_name=> 'PROG_COLLECT_SESS_DATA', program_type=> '???????', HERE IS MY PROBLEM IS IT POSIBLE TO MAKE A DBLINK TO CONNECTO TO THE OTHER DB AND RETRIEVE INFORMATION FROM A TABLE AND PAST IT ON TO SIMILAR TABLE ON THIS DB. AND PUT A FIELD DNM_SINC TO 'YES' WHEN IN DEFAULT IS NO? program_action=> '??????????????', enabled=>true, comments=>'Procedure to collect session information' ); end; begin -- Connect both dbms_scheduler parts by creating the final job dbms_scheduler.create_job (job_name => 'JOB_COLLECT_SESS_DATA', program_name=> 'PROG_COLLECT_SESS_DATA', schedule_name=>'INTERVAL_EVERY_5_MINUTES', enabled=>true, auto_drop=>false, comments=>'Job to collect data about session values every 5 minutes'); end;

          L 1 Reply Last reply
          0
          • M Mycroft Holmes

            We won't actually do the writing for you but will help when you have a problem (not the entire process). Try breaking it down into smaller bits. Write a query that compares the 2 tables and identifies the records that need to be updated. Test it Now change the query to do the actual update. Create a stored procedure using the update query. Look into database job scheduling to call the stored procedure you have created (I know SQL Server but not Oracle). If this is beyond you then you need to get some education in working with a database, specifically Oracle which is not a trivial exercise.

            Never underestimate the power of human stupidity RAH

            M Offline
            M Offline
            Miguel Quintanilla
            wrote on last edited by
            #7

            Hi many thanks for all the help you give me. here is my problem i want to use me of this: this i have on toad: -- run every 5 MINUTES BEGIN dbms_scheduler.create_schedule( schedule_name => 'INTERVAL_EVERY_5_MINUTES', start_date => trunc(sysdate)+18/24, repeat_interval => 'freq=MINUTELY;interval=5', comments => 'Runtime: Every day all 5 minutes'); END; / begin -- Call a procedure of a database package dbms_scheduler.create_program (program_name=> 'PROG_COLLECT_SESS_DATA', program_type=> 'STORED_PROCEDURE', program_action=> '?????? i dont have this yet', enabled=>true, comments=>'Procedure to collect session information' ); end; begin -- Connect both dbms_scheduler parts by creating the final job dbms_scheduler.create_job (job_name => 'JOB_COLLECT_SESS_DATA', program_name=> 'PROG_COLLECT_SESS_DATA', schedule_name=>'INTERVAL_EVERY_5_MINUTES', enabled=>true, auto_drop=>false, comments=>'Job to collect data about session values every 5 minutes'); end; I AM GOING TO USE THIS SCHEDULED JOB AND NOW I WANT TO CREATE MY SQL AND I HAVE A LITTLE BIT OF TROUBLE. I HAVE DONE THIS DBLINK: CREATE DATABASE LINK DB_2 CONNECT TO COMPUSOFT IDENTIFIED BY albosapam02 USING 'inv2' AND THEN I HAVE DONE THIS: SELECT * FROM PESAJE MINUS SELECT * FROM PESAJE@DB_2 IT GIVES ME A RESULT BUT NOW I WANT TO INSERT THAT RESULT IN THE DB_2 AND STORE THE QUERY SO I CAN ALL IT ON THE JOB.. aNY HELP???

            M 1 Reply Last reply
            0
            • M Miguel Quintanilla

              I have done this on TOAD for oracle: -- run every 5 MINUTES BEGIN dbms_scheduler.create_schedule( schedule_name => 'INTERVAL_EVERY_5_MINUTES', start_date => trunc(sysdate)+18/24, repeat_interval => 'freq=MINUTELY;interval=5', comments => 'Runtime: Every day all 5 minutes'); END; / begin -- Call a procedure of a database package dbms_scheduler.create_program (program_name=> 'PROG_COLLECT_SESS_DATA', program_type=> '???????', HERE IS MY PROBLEM IS IT POSIBLE TO MAKE A DBLINK TO CONNECTO TO THE OTHER DB AND RETRIEVE INFORMATION FROM A TABLE AND PAST IT ON TO SIMILAR TABLE ON THIS DB. AND PUT A FIELD DNM_SINC TO 'YES' WHEN IN DEFAULT IS NO? program_action=> '??????????????', enabled=>true, comments=>'Procedure to collect session information' ); end; begin -- Connect both dbms_scheduler parts by creating the final job dbms_scheduler.create_job (job_name => 'JOB_COLLECT_SESS_DATA', program_name=> 'PROG_COLLECT_SESS_DATA', schedule_name=>'INTERVAL_EVERY_5_MINUTES', enabled=>true, auto_drop=>false, comments=>'Job to collect data about session values every 5 minutes'); end;

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #8

              Miguel Quintanilla wrote:

              IS IT POSIBLE TO MAKE A DBLINK

              Like this[^]?

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

              M 1 Reply Last reply
              0
              • L Lost User

                Miguel Quintanilla wrote:

                IS IT POSIBLE TO MAKE A DBLINK

                Like this[^]?

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                M Offline
                M Offline
                Miguel Quintanilla
                wrote on last edited by
                #9

                I HAVE DONE THIS DBLINK: CREATE DATABASE LINK DB_2 CONNECT TO COMPUSOFT IDENTIFIED BY albosapam02 USING 'inv2' AND THEN I HAVE DONE THIS: SELECT * FROM PESAJE MINUS SELECT * FROM PESAJE@DB_2 IT GIVES ME A RESULT BUT NOW I WANT TO INSERT THAT RESULT IN THE DB_2 AND STORE THE QUERY SO I CAN cALL IT ON THE JOB.. aNY HELP???

                L 1 Reply Last reply
                0
                • M Miguel Quintanilla

                  I HAVE DONE THIS DBLINK: CREATE DATABASE LINK DB_2 CONNECT TO COMPUSOFT IDENTIFIED BY albosapam02 USING 'inv2' AND THEN I HAVE DONE THIS: SELECT * FROM PESAJE MINUS SELECT * FROM PESAJE@DB_2 IT GIVES ME A RESULT BUT NOW I WANT TO INSERT THAT RESULT IN THE DB_2 AND STORE THE QUERY SO I CAN cALL IT ON THE JOB.. aNY HELP???

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #10

                  Your message is all in caps-lock; on the internet that's interpreted as shouting.

                  Miguel Quintanilla wrote:

                  IT GIVES ME A RESULT BUT NOW I WANT TO INSERT THAT RESULT IN THE DB_2 AND STORE THE QUERY SO I CAN cALL IT ON THE JOB..
                  aNY HELP??

                  With what exactly? You can select and insert; please describe the problem you're having.

                  Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                  M 1 Reply Last reply
                  0
                  • L Lost User

                    Your message is all in caps-lock; on the internet that's interpreted as shouting.

                    Miguel Quintanilla wrote:

                    IT GIVES ME A RESULT BUT NOW I WANT TO INSERT THAT RESULT IN THE DB_2 AND STORE THE QUERY SO I CAN cALL IT ON THE JOB..
                    aNY HELP??

                    With what exactly? You can select and insert; please describe the problem you're having.

                    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                    M Offline
                    M Offline
                    Miguel Quintanilla
                    wrote on last edited by
                    #11

                    Ok i have the result from the both db's in this query now i want to insert the result in DB_2 this the query that gives me the result: select /*+ FULL(Tbl1) */ PSJ_GESTION, PSJ_COD, PSJ_PLACA, PSJ_PESO, PSJ_FECHA , PSJ_ESTADO, BLZ_COD, MNF_COD, DMN_COD, USR_COD , PSJ_OPERACION, TIC_COD, PSJ_TARA, PSJ_NETO from COMPUSOFT.PESAJE Tbl1 minus select /*+ FULL(Tbl2) */ PSJ_GESTION, PSJ_COD, PSJ_PLACA, PSJ_PESO, PSJ_FECHA , PSJ_ESTADO, BLZ_COD, MNF_COD, DMN_COD, USR_COD , PSJ_OPERACION, TIC_COD, PSJ_TARA, PSJ_NETO from COMPUSOFT.PESAJE@"DB_2" Tbl2 Order by PSJ_GESTION ASC NULLS LAST, PSJ_COD ASC NULLS LAST, PSJ_PLACA ASC NULLS LAST, PSJ_PESO ASC NULLS LAST, PSJ_FECHA ASC NULLS LAST, PSJ_ESTADO ASC NULLS LAST, BLZ_COD ASC NULLS LAST, MNF_COD ASC NULLS LAST, DMN_COD ASC NULLS LAST, USR_COD ASC NULLS LAST, TIC_COD ASC NULLS LAST, PSJ_TARA ASC NULLS LAST, PSJ_NETO ASC NULLS LAST

                    L 1 Reply Last reply
                    0
                    • M Miguel Quintanilla

                      Ok i have the result from the both db's in this query now i want to insert the result in DB_2 this the query that gives me the result: select /*+ FULL(Tbl1) */ PSJ_GESTION, PSJ_COD, PSJ_PLACA, PSJ_PESO, PSJ_FECHA , PSJ_ESTADO, BLZ_COD, MNF_COD, DMN_COD, USR_COD , PSJ_OPERACION, TIC_COD, PSJ_TARA, PSJ_NETO from COMPUSOFT.PESAJE Tbl1 minus select /*+ FULL(Tbl2) */ PSJ_GESTION, PSJ_COD, PSJ_PLACA, PSJ_PESO, PSJ_FECHA , PSJ_ESTADO, BLZ_COD, MNF_COD, DMN_COD, USR_COD , PSJ_OPERACION, TIC_COD, PSJ_TARA, PSJ_NETO from COMPUSOFT.PESAJE@"DB_2" Tbl2 Order by PSJ_GESTION ASC NULLS LAST, PSJ_COD ASC NULLS LAST, PSJ_PLACA ASC NULLS LAST, PSJ_PESO ASC NULLS LAST, PSJ_FECHA ASC NULLS LAST, PSJ_ESTADO ASC NULLS LAST, BLZ_COD ASC NULLS LAST, MNF_COD ASC NULLS LAST, DMN_COD ASC NULLS LAST, USR_COD ASC NULLS LAST, TIC_COD ASC NULLS LAST, PSJ_TARA ASC NULLS LAST, PSJ_NETO ASC NULLS LAST

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #12

                      INSERT INTO TableName
                      SELECT [...]

                      Source[^]

                      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                      M 1 Reply Last reply
                      0
                      • L Lost User

                        INSERT INTO TableName
                        SELECT [...]

                        Source[^]

                        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                        M Offline
                        M Offline
                        Miguel Quintanilla
                        wrote on last edited by
                        #13

                        I have try this: Insert into COMPUSOFT.PESAJE@DB_2 select /*+ FULL(Tbl1) */ PSJ_GESTION, PSJ_COD, PSJ_PLACA, PSJ_PESO, PSJ_FECHA , PSJ_ESTADO, BLZ_COD, MNF_COD, DMN_COD, USR_COD , PSJ_OPERACION, TIC_COD, PSJ_TARA, PSJ_NETO from COMPUSOFT.PESAJE Tbl1 minus select /*+ FULL(Tbl2) */ PSJ_GESTION, PSJ_COD, PSJ_PLACA, PSJ_PESO, PSJ_FECHA , PSJ_ESTADO, BLZ_COD, MNF_COD, DMN_COD, USR_COD , PSJ_OPERACION, TIC_COD, PSJ_TARA, PSJ_NETO from COMPUSOFT.PESAJE@"DB_2" Tbl2; But i get "missing values"

                        L 1 Reply Last reply
                        0
                        • M Miguel Quintanilla

                          I have try this: Insert into COMPUSOFT.PESAJE@DB_2 select /*+ FULL(Tbl1) */ PSJ_GESTION, PSJ_COD, PSJ_PLACA, PSJ_PESO, PSJ_FECHA , PSJ_ESTADO, BLZ_COD, MNF_COD, DMN_COD, USR_COD , PSJ_OPERACION, TIC_COD, PSJ_TARA, PSJ_NETO from COMPUSOFT.PESAJE Tbl1 minus select /*+ FULL(Tbl2) */ PSJ_GESTION, PSJ_COD, PSJ_PLACA, PSJ_PESO, PSJ_FECHA , PSJ_ESTADO, BLZ_COD, MNF_COD, DMN_COD, USR_COD , PSJ_OPERACION, TIC_COD, PSJ_TARA, PSJ_NETO from COMPUSOFT.PESAJE@"DB_2" Tbl2; But i get "missing values"

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #14

                          Miguel Quintanilla wrote:

                          But i get "missing values"

                          Can you post the complete message? This would only work if the table you're inserting to has columns to match the query's result.

                          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                          M 1 Reply Last reply
                          0
                          • M Miguel Quintanilla

                            Hi many thanks for all the help you give me. here is my problem i want to use me of this: this i have on toad: -- run every 5 MINUTES BEGIN dbms_scheduler.create_schedule( schedule_name => 'INTERVAL_EVERY_5_MINUTES', start_date => trunc(sysdate)+18/24, repeat_interval => 'freq=MINUTELY;interval=5', comments => 'Runtime: Every day all 5 minutes'); END; / begin -- Call a procedure of a database package dbms_scheduler.create_program (program_name=> 'PROG_COLLECT_SESS_DATA', program_type=> 'STORED_PROCEDURE', program_action=> '?????? i dont have this yet', enabled=>true, comments=>'Procedure to collect session information' ); end; begin -- Connect both dbms_scheduler parts by creating the final job dbms_scheduler.create_job (job_name => 'JOB_COLLECT_SESS_DATA', program_name=> 'PROG_COLLECT_SESS_DATA', schedule_name=>'INTERVAL_EVERY_5_MINUTES', enabled=>true, auto_drop=>false, comments=>'Job to collect data about session values every 5 minutes'); end; I AM GOING TO USE THIS SCHEDULED JOB AND NOW I WANT TO CREATE MY SQL AND I HAVE A LITTLE BIT OF TROUBLE. I HAVE DONE THIS DBLINK: CREATE DATABASE LINK DB_2 CONNECT TO COMPUSOFT IDENTIFIED BY albosapam02 USING 'inv2' AND THEN I HAVE DONE THIS: SELECT * FROM PESAJE MINUS SELECT * FROM PESAJE@DB_2 IT GIVES ME A RESULT BUT NOW I WANT TO INSERT THAT RESULT IN THE DB_2 AND STORE THE QUERY SO I CAN ALL IT ON THE JOB.. aNY HELP???

                            M Offline
                            M Offline
                            Mycroft Holmes
                            wrote on last edited by
                            #15

                            Sorry my knowledge of Oracle and DB2 is very limited, I'm not going to be able to help with the details on those platforms. Oracle has a dedicated support forum, Ask Ted I think, you should get more relevant support there!

                            Never underestimate the power of human stupidity RAH

                            M 1 Reply Last reply
                            0
                            • M Mycroft Holmes

                              Sorry my knowledge of Oracle and DB2 is very limited, I'm not going to be able to help with the details on those platforms. Oracle has a dedicated support forum, Ask Ted I think, you should get more relevant support there!

                              Never underestimate the power of human stupidity RAH

                              M Offline
                              M Offline
                              Miguel Quintanilla
                              wrote on last edited by
                              #16

                              Thanks anyway

                              1 Reply Last reply
                              0
                              • L Lost User

                                Miguel Quintanilla wrote:

                                But i get "missing values"

                                Can you post the complete message? This would only work if the table you're inserting to has columns to match the query's result.

                                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                                M Offline
                                M Offline
                                Miguel Quintanilla
                                wrote on last edited by
                                #17

                                I have solved it ! It was a missmatch in the first select ok how do i store the query so i can call it in a store_procedure

                                L 1 Reply Last reply
                                0
                                • M Miguel Quintanilla

                                  I have solved it ! It was a missmatch in the first select ok how do i store the query so i can call it in a store_procedure

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #18

                                  Doesn't Oracle have a "create procedure" or something similar? :)

                                  Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups