Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8161311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:28:21+00:00 2026-06-06T18:28:21+00:00

I want to do a script that retrieves all the data in the table

  • 0

I want to do a script that retrieves all the data in the table COURBE_CHARGE to copy them to the table with HISTORIQUE_COURBE_CHARGE measurement date (the field CCH_DATE) that is either earlier than 14 months, and that removes the copied data.

COURBE_CHARGE and HISTORIQUE_COURBE_CHARGE is the same table

COURBE_CHARGE:

Column                Data Type

CCH_ID                  NUMBER(*,0)
TLM_ID                  NUMBER(*,0)
CPT_ID                  NUMBER(*,0)
CCH_DATE                    DATE
CCH_DATE_INTEGRATION    DATE
CCH_NEW                 NUMBER(*,0)
CCH_NB_HEURES           NUMBER(*,0)
CCH_TYPE_ENERGIE            VARCHAR2(12)
P1                          NUMBER(*,0)
P2                          NUMBER(*,0)
P3                          NUMBER(*,0)
…                           NUMBER(*,0)
P149                    NUMBER(*,0)
P150                    NUMBER(*,0)
PH1                         NUMBER(*,0)
PH2                         NUMBER(*,0)
…                           NUMBER(*,0)
PH24                    NUMBER(*,0)
PH25                    NUMBER(*,0)

HISTORIQUE_COURBE_CHARGE:

Column                Data Type

HIS_CCH_ID                  NUMBER(*,0)
TLM_ID                  NUMBER(*,0)
CPT_ID                  NUMBER(*,0)
CCH_DATE                    DATE
CCH_DATE_INTEGRATION    DATE
CCH_NEW                 NUMBER(*,0)
CCH_NB_HEURES           NUMBER(*,0)
CCH_TYPE_ENERGIE            VARCHAR2(12)
P1                          NUMBER(*,0)
P2                          NUMBER(*,0)
P3                          NUMBER(*,0)
…                           NUMBER(*,0)
P149                    NUMBER(*,0)
P150                    NUMBER(*,0)
PH1                         NUMBER(*,0)
PH2                         NUMBER(*,0)
…                           NUMBER(*,0)
PH24                    NUMBER(*,0)
PH25                    NUMBER(*,0)

I have an error when i execute my script

error

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:28:22+00:00Added an answer on June 6, 2026 at 6:28 pm
    INSERT INTO HISTORIQUE_COURBE_CHARGE (CCH_DATE, [field list]) 
        AS 
          SELECT SYSDATE, [field list] 
            FROM COURBE_CHARGE
           WHERE CH_DATE < (SYSDATE - 425);
    

    [Field list] should be expanded to the full field list of your tables. (eg. P1, P2, P3…) without the CH_DATE

    The where cond: 14 months are roughly 425 days, adjust the condition if you need exactly 14 months.

    EDIT: please note that ch_date will be set to SYSDATE in historical table, that can be right or wrong, depending on situation, if you need to keep track of when archiviation has been actually done (but I suggest you to add a new date column HIST_DATE and use it to store SYSDATE). In that scenario insert will be:

    ALTER TABLE HISTORIQUE_COURBE_CHARGE ( ADD HIST_DATE DATE ); — execute this only once

    INSERT INTO HISTORIQUE_COURBE_CHARGE (HIST_DATE, [field list]) 
            AS 
              SELECT SYSDATE, [field list] 
                FROM COURBE_CHARGE
               WHERE ... -- whatever where cond
    

    In this case, [field list] is the whole field list of the table. Likewise you can store other informations (such as user performing the storicization and so on).

    for the deletion:

    DELETE 
      FROM COURBE_CHARGE 
     WHERE CC_ID IN (SELECT HIS_CC_ID 
                       FROM HISTORIQUE_COURBE_CHARGE );
    

    this will delete each saved row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scripts that retrieves huge data on a table. I want to
I want a PHP script that adds some data at the end of a
I want to build a script that builds up the data needed for the
I got a problem with JavaScript. I want a script that will pop-up on
I want to write a script that compares two directories. However, the file names
I want to make a script that takes a URL to a file and
I want to make a script that can be used to send messages to
I want to make a script that starts a program and then sends it
I have a python script that I want always to run in the background.
I have a script that polls a MySQL database (Nagios, specifically) for the date/time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.