exception in two places to insert statement

Hi all

I want to insert an exception to two places in pl sql. I get the error. Is it possible to apply the exception to two places in the insert statement.

Thank you

Uday


Begin
Declare
Number of V_Code;
V_Errm Varchar2 (64);
Number of V_Code1;
V_Errm1 Varchar2 (64);



INSERT INTO recovery
Select Employee_Id, salary * 1.1 employees
Where Commission_Pct >. 2;
EXCEPTION
While others then
V_Code: = Sqlcode;
V_Errm: = Substr (Sqlerrm, 1, 64);
Dbms_Output.put_line ("Error Code" |) V_Code | ': ' || V_Errm);

Insert Into Scap_Fact_Loading_Errors Values (V_Code, V_Errm, Systimestamp);


INSERT INTO recovery
Select Employee_Id, salary * 1.1 employees
Where Commission_Pct >. 1;
EXCEPTION
While other then V_Code1: = Sqlcode;
V_Errm1: = Substr (Sqlerrm, 1, 64);
Dbms_Output.put_line ("Error Code" |) V_Code1 | ': ' || V_Errm1);
INSERT INTO Scap_Fact_Loading_Errors VALUES (v_code1, v_errm1, SYSTIMESTAMP);

END;

Published by: 929521 on January 7, 2013 10:15

for example.

Declare
  V_Code Number;
  V_Errm Varchar2(64);
  V_Code1 Number;
  V_Errm1 Varchar2(64);

begin

  -- 1st begin .. end block
  begin
    INSERT INTO Raise
    Select Employee_Id, Salary*1.1 From Employees
     Where Commission_Pct > .2;
  EXCEPTION
    When Others Then
      V_Code := Sqlcode;
      V_Errm := Substr(Sqlerrm, 1, 64);
      Dbms_Output.Put_Line ('Error code ' || V_Code || ': ' || V_Errm);
      Insert Into Scap_Fact_Loading_Errors Values (V_Code, V_Errm, Systimestamp);
  end;

  -- 2nd begin .. end block
  begin
    INSERT INTO Raise
    Select Employee_Id, Salary*1.1 From Employees
     Where Commission_Pct > .1;
  EXCEPTION
    When Others Then V_Code1 := Sqlcode;
      V_Errm1 := Substr(Sqlerrm, 1, 64);
      Dbms_Output.Put_Line ('Error code ' || V_Code1 || ': ' || V_Errm1);
      INSERT INTO Scap_Fact_Loading_Errors VALUES (v_code1, v_errm1, SYSTIMESTAMP);
  end;

end;

Tags: Database

Similar Questions

  • Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Hello

    2796614 wrote:

    Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Of course, it is possible.  According to what the text file looks like to, you can create an external table that treats the text file as if it were a table.  Otherwise, you can always read the file in PL/SQL, using the utl_file package and INSERT of PL/SQL commands.

    You have problems whatever you wantt?  If so, your zip code and explain what the problem is.

    Whenever you have any questions, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the exact results you want from these data, so that people who want to help you can recreate the problem and test their ideas.  In this case, also post a small sample of the text involved file.

    If you ask about a DML operation, such as INSERT, then INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • INSERT statement is slower in PL/SQL, SQL

    I can't understand why an insert in PL/SQL is much slower than in SQL (against 5 minutes 2 seconds).

    INSERT statement and explain plans are below.


    The BIG difference is that I use an immediate execution with bind variable because I'm passing in the dynamic table/column names. Maybe that confuses the optimizer? Another point is that if I remove the 2 'GOLD' terms these two queries run the same speed.


    Oracle 10g

    Jason

    The insert statement is:

    [code]

    INSERT / * + APPEND * / INTO linker_sec_betach_ip

    SELECT

    SEC_CLIENTVISIT_GUID

    SEC_INST

    SEC_ADMIT_DT

    SEC_DISCHARGE_DT

    SEC_ENCOUNTER

    SEC_TYPE

    SEC_STATUS

    SEC_CARE_LEVEL

    BETACH_CD_ENCOUNTER_ID

    BETACH_INST

    BETACH_ADMIT_DT

    BETACH_DISCH_DT

    BETACH_PCU_FIRST

    DATE_SCORE

    LAST_UPDATE_DT AS SYSDATE

    CEN

    SELECT

    BT. CLIENTVISIT_GUID AS SEC_CLIENTVISIT_GUID

    bt. INST AS SEC_INST

    bt. ADMIT_DT AS SEC_ADMIT_DT

    bt. DISCHARGE_DT AS SEC_DISCHARGE_DT

    bt. MEETING AS SEC_ENCOUNTER

    bt. SEC_TYPE ACE TYPE

    bt. STATE SEC_STATUS

    bt. CARE_LEVEL AS SEC_CARE_LEVEL

    JT. CD_ENCOUNTER_ID AS BETACH_CD_ENCOUNTER_ID

    JT. INST AS BETACH_INST

    JT. ADMIT_DT AS BETACH_ADMIT_DT

    JT. DISCH_DT AS BETACH_DISCH_DT

    JT. PCU_FIRST AS BETACH_PCU_FIRST

    ABS (bt. ADMIT_DT - JT. ADMIT_DT) AS DATE_SCORE

    MIN (ABS (bt. ADMIT_DT - JT. ADMIT_DT)) OVER (PARTITION BY bt. CLIENTVISIT_GUID) AS LINK_PRIMARY_KEY_SCORE

    MIN (ABS (bt. ADMIT_DT - JT. ADMIT_DT)) OVER (PARTITION BY JT. CD_ENCOUNTER_ID) AS BASE_PRIMARY_KEY_SCORE

    OF sec_encounters_delme bt

    jt betach_visits

    WHERE)

    (bt. RSP = JT. PHN)

    OR (bt. PTN_CHART = JT. RHRN) - IF I REMOVE THESE TWO THEN THEY BOTH RUN THE SAME SPEED

    OR (bt. MEET = JT. ENCOUNTER_NO) -IF I REMOVE THESE TWO and THEN THEY BOTH PERFORM THE SAME SPEED

    )

    AND bt. ADMIT_DT < trunc (sysdate)

    AND bt. ADMIT_DT > = JT. ADMIT_DT - 1.5

    AND bt. ADMIT_DT < = JT. ADMIT_DT + 1.5

    AND bt. ADMIT_DT > = trunc(sysdate-7)

    AND bt. ADMIT_DT < trunc(sysdate-7) + 7

    AND JT. ADMIT_DT > = trunc(sysdate-7) - 1.5

    AND JT. ADMIT_DT < = trunc(sysdate-7) + 7 + 1.5

    AND 1 = 1

    );

    [/ code]

    THIS PLAN IS < 2 seconds for 5000 lines

    Hash value of plan: 1434516581

    -----------------------------------------------------------------------------------------------------------

    | ID | Operation | Name                  | Lines | Bytes | Cost (% CPU). Time |

    -----------------------------------------------------------------------------------------------------------

    |   0 | INSERT STATEMENT.                       |     3.   378.    42 (3) | 00:00:01 |

    |   1.  LOAD SELECT ACE | LINKER_SEC_BETACH_IP |       |       |            |          |

    |   2.   VIEW                            |                       |     3.   378.    42 (3) | 00:00:01 |

    |   3.    CONCATENATION.                       |       |       |            |          |

    |*  4 |     FILTER                        |                       |       |       |            |          |

    |*  5 |      TABLE ACCESS BY INDEX ROWID | SEC_ENCOUNTERS_DELME |     1.    74.     3 (0) | 00:00:01 |

    |   6.       NESTED LOOPS |                       |     1.   137.    13 (0) | 00:00:01 |

    |   8 S        TABLE ACCESS BY INDEX ROWID | BETACH_VISITS |     1.    63.    10 (0) | 00:00:01 |

    |*  8 |         INDEX RANGE SCAN | IDX_BETACH_VISITS_006 |     1.       |     9 (0) | 00:00:01 |

    |*  9 |        INDEX RANGE SCAN | NDX_SEC_ENC_05 |     1.       |     2 (0) | 00:00:01 |

    | * 10 |     FILTER                        |                       |       |       |            |          |

    | * 11 |      TABLE ACCESS BY INDEX ROWID | SEC_ENCOUNTERS_DELME |     1.    74.     4 (0) | 00:00:01 |

    |  12.       NESTED LOOPS |                       |     1.   137.    14 (0) | 00:00:01 |

    |  13.        TABLE ACCESS BY INDEX ROWID | BETACH_VISITS |     1.    63.    10 (0) | 00:00:01 |

    | * 14 |         INDEX RANGE SCAN | IDX_BETACH_VISITS_006 |     1.       |     9 (0) | 00:00:01 |

    | * 15 |        INDEX RANGE SCAN | NDX_SEC_ENC_06 |     3.       |     2 (0) | 00:00:01 |

    | * 16.     FILTER                        |                       |       |       |            |          |

    | * 17.      TABLE ACCESS BY INDEX ROWID | SEC_ENCOUNTERS_DELME |     1.    74.     4 (0) | 00:00:01 |

    |  18.       NESTED LOOPS |                       |     1.   137.    14 (0) | 00:00:01 |

    | * 19.        TABLE ACCESS BY INDEX ROWID | BETACH_VISITS |     1.    63.    10 (0) | 00:00:01 |

    | * 20.         INDEX RANGE SCAN | IDX_BETACH_VISITS_006 |     1.       |     9 (0) | 00:00:01 |

    | * 21.        INDEX RANGE SCAN | NDX_SEC_ENC_03 |     3.       |     2 (0) | 00:00:01 |

    -----------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    4 filter (TRUNC (SYSDATE@!-7) - 1.5 < = TRUNC (SYSDATE@!-7) + 7 + 1.5 AND)

    TRUNC (sysdate@!-7) < TRUNC (SYSDATE@!-7) + 7 AND TRUNC(SYSDATE@!) > TRUNC (SYSDATE@!-7))

    5 - filter("BT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) AND "BT". "" ADMIT_DT "< TRUNC(SYSDATE@!) AND

    'BT '. "" ADMIT_DT "< TRUNC (SYSDATE@!-7) + 7 AND"BT ". "" ADMIT_DT "> = INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 "

    (AND "BT". "" ADMIT_DT "< = INTERNAL_FUNCTION ("JT". "ADMIT_DT") + (1.5) "

    8 - access("JT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) - 1.5 AND

    "JT". ("' ADMIT_DT" < = TRUNC (SYSDATE@!-7) + 7 + 1.5)

    filter (INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC(SYSDATE@!) " AND

    INTERNAL_FUNCTION ("JT". "ADMIT_DT") + 1.5 > = TRUNC (SYSDATE@!-7) AND "

    INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC (SYSDATE@!-7)(+7) "

    9 - access("BT".") MEET JT '=' '. ("' ENCOUNTER_NO")

    10 filter (TRUNC (SYSDATE@!-7) - 1.5 < = TRUNC (SYSDATE@!-7) + 7 + 1.5 AND)

    TRUNC (sysdate@!-7) < TRUNC (SYSDATE@!-7) + 7 AND TRUNC(SYSDATE@!) > TRUNC (SYSDATE@!-7))

    11 - filter("BT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) AND "BT". "" ADMIT_DT "< TRUNC(SYSDATE@!) AND

    'BT '. "" ADMIT_DT "< TRUNC (SYSDATE@!-7) + 7 AND"BT ". "" ADMIT_DT "> = INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 "

    (AND "BT". "" ADMIT_DT "< = INTERNAL_FUNCTION ("JT". "ADMIT_DT") + 1.5 AND "

    LNNVL ("BT". "JT"="MEETING" "." " ENCOUNTER_NO'))

    14 - access("JT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) - 1.5 AND

    "JT". ("' ADMIT_DT" < = TRUNC (SYSDATE@!-7) + 7 + 1.5)

    filter (INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC(SYSDATE@!) " AND

    INTERNAL_FUNCTION ("JT". "ADMIT_DT") + 1.5 > = TRUNC (SYSDATE@!-7) AND "

    INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC (SYSDATE@!-7)(+7) "

    15 - access("BT".") PTN_CHART «= TO_NUMBER ("JT".» RHRN'))

    16 filter (TRUNC (SYSDATE@!-7) - 1.5 < = TRUNC (SYSDATE@!-7) + 7 + 1.5 AND)

    TRUNC (sysdate@!-7) < TRUNC (SYSDATE@!-7) + 7 AND TRUNC(SYSDATE@!) > TRUNC (SYSDATE@!-7))

    17 - filter("BT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) AND "BT". "" ADMIT_DT "< TRUNC(SYSDATE@!) AND

    'BT '. "" ADMIT_DT "< TRUNC (SYSDATE@!-7) + 7 AND"BT ". "" ADMIT_DT "> = INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 "

    (AND "BT". "" ADMIT_DT "< = INTERNAL_FUNCTION ("JT". "ADMIT_DT") + 1.5 AND "

    LNNVL ("BT". "PTN_CHART '= TO_NUMBER ("JT".' RHRN')) AND LNNVL ("BT". "JT"="MEETING" "." " ENCOUNTER_NO'))

    19 - filter("JT".") PHNS' IS NOT NULL)

    20 - access("JT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) - 1.5 AND

    "JT". ("' ADMIT_DT" < = TRUNC (SYSDATE@!-7) + 7 + 1.5)

    filter (INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC(SYSDATE@!) " AND

    INTERNAL_FUNCTION ("JT". "ADMIT_DT") + 1.5 > = TRUNC (SYSDATE@!-7) AND "

    INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC (SYSDATE@!-7)(+7) "

    21 - access("BT".") PHN '=' JT '. ("' PHN ')


    When I placed this SQL in PL/SQL (AND place it in an immediate execution) it slows down.

    THIS PLAN GOES ~ 5minutes to 5000 lines

    Hash value of plan: 60405780

    ----------------------------------------------------------------------------------------------------------

    | ID | Operation | Name                  | Lines | Bytes | Cost (% CPU). Time |

    ----------------------------------------------------------------------------------------------------------

    |   0 | INSERT STATEMENT.                       |     1.   126.     2 (0) | 00:00:01 |

    |   1.  LOAD SELECT ACE | LINKER_SEC_BETACH_IP |       |       |            |          |

    |   2.   VIEW                           |                       |     1.   126.     2 (0) | 00:00:01 |

    |*  3 |    FILTER                        |                       |       |       |            |          |

    |*  4 |     TABLE ACCESS BY INDEX ROWID | SEC_ENCOUNTERS_DELME |     1.    74.     1 (0) | 00:00:01 |

    |   5.      NESTED LOOPS |                       |     1.   137.     2 (0) | 00:00:01 |

    |   4 >       TABLE ACCESS BY INDEX ROWID | BETACH_VISITS |     1.    63.     1 (0) | 00:00:01 |

    |*  7 |        INDEX RANGE SCAN | IDX_BETACH_VISITS_006 |     1.       |     1 (0) | 00:00:01 |

    |*  8 |       INDEX RANGE SCAN | NDX_SEC_ENC_07 |     2.       |     1 (0) | 00:00:01 |

    ----------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    3 filter (TO_NUMBER(:4) - 1.5 < = TO_NUMBER(:5) + 7 + AND 1.5: 2 < TO_NUMBER(:3) + 7 AND)

    To_date(:1) > TO_DATE (:2))

    4 - filter("BT".") PHN '=' JT '. "' PHN ' AND 'JT '. "' PHN ' IS NOT NULL OR

    'BT '. «PTN_CHART «= TO_NUMBER ("JT".» ("' RHRN") OR "BT". «"JT MEETING «=»» ("' ENCOUNTER_NO")

    7 - access("JT".") ADMIT_DT' > = TO_NUMBER(:4) - 1.5 AND "JT". ("' ADMIT_DT" < = TO_NUMBER(:5) + 7 + 1.5)

    filter (INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TO_NUMBER(:3) + 7 AND "

    INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 <: 1 AND INTERNAL_FUNCTION ("JT" ".") " (ADMIT_DT') + 1.5 > =: 2)

    8 - access("BT".") ADMIT_DT' > = INTERNAL_FUNCTION ("JT". "ADMIT_DT") - 1.5 AND "BT". ("' ADMIT_DT" <: 1).

    filter ("BT". "ADMIT_DT" < TO_NUMBER(:3) + 7 AND "BT" "." " ADMIT_DT' > =: 2 AND

    'BT '. "" ADMIT_DT "< = INTERNAL_FUNCTION ("JT". "ADMIT_DT") + (1.5) "

    I have it!

    I added / * + USE_CONCAT * / forces subquery and not it the PL/SQL plan of union the subqueries.

    Hoek thanks for the link to the use of the tracing utility.

    Jason

  • Can I omit THEN in a when then the clause of an insert statement multi-table?

    Example of a test of the demo:

    You have been appointed as the DBA for a National Bank that provides services of credit and debit cards to its customers. The records for these two types of card users are stored and preserved in the card_customers of Bank data table.

    You decide to create separate tables for credit card users and users of debit cards and then use the data in the card_customers table to populate the new tables. Information for clients who hold both types of card must be added to the time of the tables.

    Which of the two following options provide the most effective way of inserting the customer data in the credit_card_holders and debit_card_holders tables? (Choose two.)

    Explanation:

    In this scenario, the following statement provides the most effective way of inserting data in the credit_card_holders and debit_card_holders tables:

    INSERT ALL
    When card_type = 'Crédit' THEN credit_card_holders
    When card_type = 'Throughput' THEN debit_card_holders
    SELECT * FROM card_customers;

    Le INSERT all THE statement verifies the conditions in the two clauses WHEN , regardless whether one of them is true or false. If a condition when is true, then the line corresponding to the INSERT statement is executed is inserted in the card_customers in the credit_card_holders table or the debit_card_holders table. If a customer has a credit card and a debit card, there will be two rows in the table card_customers for the same customer, one with card_type = 'Crédit' and the other with card_type = 'Throughput'. This statement inserts the correct lines in the tables in a single pass.


    The TIME is here (in bold) are not present in answer C.


    basic question: can I omit the keyword THEN in a moment, then clause?

    What happened when you tried the failure THEN?

    Do not be afraid to break the Oracle by actually TRYING things.

    The best and fastest, to learn is to try things yourself.

    Then, see the documentation for the basic issues.

    http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_9014.htm

    View the diagram of syntax for the 'conditional_insert_clause' and you will see that the word is necessary.

  • Reg: Insert statement.

    Hello

    I have a button on my form.
    And the button that I wrote an insert statement.

    After filling out the form, click on the sound button do not get any errors.
    but the records do not insert into the table.

    -the bouton-poussoir--
    Start

    insert into LOGINDETAILS (EMPID, EMPFIRSTNAME, EMPMIDDLENAME, EMPLASTNAME, username, PASSWORD)

    values (seqlogindetails.nextval,
    : LOGINDETAILS. EMPFIRSTNAME,
    : LOGINDETAILS. EMPMIDDLENAME,
    : LOGINDETAILS. EMPLASTNAME,
    : LOGINDETAILS.username,.
    : LOGINDETAILS. Password
    );
    -commit;
    exception
    When dup_val_on_index then
    message (-20001, "duplicate data found '");
    raise form_trigger_failure;
    while others then
    MESSAGE (SQLERRM);
    raise form_trigger_failure;

    end;


    Help, please.

    Published by: Aude chouchou on January 29, 2013 03:11

    Rajnish Chauhan says:
    Hello

    I have a button on my form.
    And the button that I wrote an insert statement.

    After filling out the form, click on the sound button do not get any errors.
    but the records do not insert into the table.

    -the bouton-poussoir--
    Start

    insert into LOGINDETAILS (EMPID, EMPFIRSTNAME, EMPMIDDLENAME, EMPLASTNAME, username, PASSWORD)

    values (seqlogindetails.nextval,
    : LOGINDETAILS. EMPFIRSTNAME,
    : LOGINDETAILS. EMPMIDDLENAME,
    : LOGINDETAILS. EMPLASTNAME,
    : LOGINDETAILS.username,.
    : LOGINDETAILS. Password
    );
    -commit;
    exception
    When dup_val_on_index then
    message (-20001, "duplicate data found '");
    raise form_trigger_failure;
    while others then
    MESSAGE (SQLERRM);
    raise form_trigger_failure;
              
    end;

    Help, please.

    Published by: Aude chouchou on January 29, 2013 03:11

    Hello
    After your insert statement writing

    forms_ddl('commit');
    

    Hope it works...

  • Help with the insert statement

    Hello

    I was wondering if someone could help write me a sql statement.

    Here is my table:
    CREATE TABLE "TEMP_INVOICE" 
       ("INVOICE" VARCHAR2(100 BYTE),
         "DATE_OF_DOCUMENT" DATE, 
         "DATE_OF_PAY_DAY" DATE, 
         "D" NUMBER, 
         "K" NUMBER
       );
    Here are the instructions for correct insertion. This time, I posted 2 examples with 2 numbers different otherwise.
    insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (1000,to_date('01.02.2012','dd.mm.yyyy'),to_date('01.03.2012','dd.mm.yyyy'),5000,0);
     
    insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (1000,to_date('01.04.2012','dd.mm.yyyy'),'','',1000);
     
    insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (1000,to_date('01.05.2012','dd.mm.yyyy'),'','',3000);
     
    insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (1000,to_date('01.06.2012','dd.mm.yyyy'),'','',1000);
    
    insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (2000,to_date('01.07.2012','dd.mm.yyyy'),to_date('01.09.2012','dd.mm.yyyy'),8000,0);
     
    insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (2000,to_date('01.10.2012','dd.mm.yyyy'),'','',5000);
     
    insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (2000,to_date('01.11.2012','dd.mm.yyyy'),'','',2000);
     
    insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (2000,to_date('01.12.2012','dd.mm.yyyy'),'','',1000);
    I want to do is make an insert allows you to table another call is MADE:
    CREATE TABLE "INVOICE" 
       ("INVOICE" VARCHAR2(100 BYTE),
        "DATE_OF_DOCUMENT" DATE, 
         "DATE_OF_PAY_DAY" DATE,
         "DATE_OF_PAYMENT_REC" DATE,
         "VALUE" NUMBER,
         "VALUE_DEDUCT" NUMBER,
        "DATE_FROM" DATE,     
         "DATE_TO" DATE
         );
    Statements in the INVOICE table should be like this:


    ........ The Bill... date_of_document... date_of_pay_day... date_of_payment_rec... value... value_deduct... Date_from... Date_to
    1......     1000...............1.1.2012.................1.3.2012................NULL............................ 5000... NULL... 1.3.2012...1.4.2012
    2......     1000...............1.4.2012.................NULL..................... 1.4.2012...1000... 4000... 2.4.2012... 1.5.2012
    3......     1000...............1.5.2012.................NULL..................... 1.5.2012...3000... 1000... 2.5.2012... 1.6.2012
    4......     1000...............1.6.2012.................NULL..................... 1.6.2012...1000


    Can someone help me with the sql statement that would insert data from table to table Bill temp_invoice as in the example?

    Thank you!

    PS

    I would try to explain.
    (1) the first statement that is to be inserted is original imply that at which is different DATE_OF_PAY_DAY to NULL.
    To this inserted negative of the original imply, we must add date_from that is exatly the same date_of_pay_day and date_to which is exactly the same as the date of the first payment. Payment which came first!
    (2) we have now in the second insert statement. It will be the first payment of lease with date_of_document and date_pf_payment_rec, which is the same as date_fo_document. Value field will be populated with the amount of payment received and value_deduct field will be the value of the original imply - value of the first payment. Date is date_of_document + 1 and date_to is the date of the next payment.
    (3) Insert us the next installment. Date_od_payment_rec is the same as date_of_document... value is the amount of the second payment and value_deduct's previous value_deduct which was of 4000 - value of this second payment. date_from date_of_payment_rec + 1 and date_to is the date of the next payment

    So we continue this same pattern until we reached the final payment when we finish insert with the statement:
    Date of the document (date of the last payment received) and even for date_of_payment_rec and field value with the amount of the payment receieved. The rest (value_deduct, date_from, date_to) is null.

    I really hope you understand what I'm trying to do here.

    If you have any other questions please.

    Published by: user13071990 on November 22, 2012 04:16

    Published by: user13071990 on November 22, 2012 04:16

    Hello

    user13071990 wrote:
    ... Here are the instructions for correct insertion. This time, I posted 2 examples with 2 numbers different otherwise.

    Ok!
    Be sure to post the results you want new data.

    You probably need to add "PARTITION BY the Bill" to all analytical clauses in my solution:

    INSERT INTO invoice
    ( invoice, date_of_document, date_of_pay_day, date_of_payment_rec
    , value,   value_deduct,     date_from,           date_to
    )
    SELECT       invoice
    ,       date_of_document
    ,       date_of_pay_day
    ,       CASE
               WHEN  k > 0
               THEN  date_of_document
           END          AS date_of_payment_rec
    ,       NVL (d, k)     AS value
    ,       NVL2 ( date_of_pay_day
                , NULL
                , SUM (d) OVER ( PARTITION BY  invoice
                                          ORDER BY      date_of_document
                         )
                - SUM (k) OVER ( PARTITION BY  invoice
                                          ORDER BY      date_of_document
                         )
                )     AS value_deduct
    ,       NVL ( date_of_pay_day
               , date_of_document + 1
               )          AS date_from
    ,       LEAD (date_of_document) OVER ( PARTITION BY  invoice
                                            ORDER BY      date_of_document
                               )
                          AS date_to
    FROM       temp_invoice
    ;
    

    Because I'm not an English speaker nativ, that I just posted what it should look like after the insert is successful.

    OK, so you can't explain as you want, but you still need to explain.

    ... @Frank Kulash: you are very close, but still not quite what I'm looking for.

    Point out where my solution is the production of incorrect results, and explain (as you can) how to get good results in these places.

  • On the insert statement

    Hi all

    I need to insert rows into a table, all the columns are have same value except a column that is to say


    insert into table values ('a', 'b', 'b', 'b');

    insert into table values ('b', 'b', 'b', 'b');

    Insert in the table values ('b', 'b', 'c', 'b');

    y at - there no shortcut for insert because there are thousands of records to insert

    Help, please

    Thank you

    If data are available in another table, you can use a select statement inside your insert statement.

    Incomplete example

    NSERT INTO TABLE (
      COL1,
      COL2,
      COL3,
      COL4
    
    )
    SELECT FROM OTHERTABLE WHERE...,
    'b'
    'b'
    'b'
    ...
    

    The doc show this as an example:

    INSERT INTO AIRPORTS (AIRPORT, CITY, COUNTRY)
      SELECT AIRPORT, CITY_NAME, COUNTRY FROM CITIES
      ORDER BY AIRPORT;
    

    SELECT yourvalue, 'b', 'b', 'b' of...

    Best regards

    mseberg

    Published by: mseberg on October 6, 2012 08:31

  • Question related to the INSERT statement

    Imagine this scenario:

    -table_a has 5 000 000 records at time t1

    -table_b is empty at time t1

    -At time t1, I execute the following statement:
              insert into table_b
                select * from table_a;
        
    -L' insert statement ends in time t2

    -Between t1 and t2, say 3 000 new records have been added to the table_a (by OLTP processes).
    Thus, at time t2, table_a has 5 003 000 records.

    My question is, at time t2, the number of records will be in table_b? Will it 5,000,000 or
    5 003 000 or somewhere between these two counts?

    I guess it will be 5,000,000 because that is the number when the insert statement
    has started to run.

    Any comment is appreciated.

    Syed Ullah says:
    Imagine this scenario:

    -table_a has 5 000 000 records at time t1

    -table_b is empty at time t1

    -At time t1, I execute the following statement:

    insert into table_b
    select * from table_a;
    

    -L' insert statement ends in time t2

    -Between t1 and t2, say 3 000 new records have been added to the table_a (by OLTP processes).
    Thus, at time t2, table_a has 5 003 000 records.

    My question is, at time t2, the number of records will be in table_b? Will it 5,000,000 or
    5 003 000 or somewhere between these two counts?

    I guess it will be 5,000,000 because that is the number when the insert statement
    has started to run.

    Any comment is appreciated.

    At time t2, it is possible that the answer is 0. Once the insert operation finishes (can be any time after t1 in your example, possibly before t2, possibly after) and assuming you checked in the same session where you run the insert, you would see 5 000 000. In other sessions you would continue to see 0 up to what the session who made the done insert one COMMIT.

    http://docs.Oracle.com/CD/E11882_01/server.112/e25789/consist.htm#CNCPT121

    Is something that you should read. He described these concepts much better than what you'll probably find in a few posts on the forum.

  • Ignore the duplicates on Insert statement

    I'm trying to create a script to import a CSV file into a MySQL database.   The script works very well.   However, it occurred to me that there could be duplicates to a certain point in time.

    How do I get this to only insert records that are not already in the database?    Please keep in mind that an excel sheet may have tens or hundreds of thousands of records when inserting.

    Any ideas?   Here is my code so far:

    <?php
    if(isset($_POST["Import"]))
    {
    $host="localhost";
    $db_user="***";
    $db_password="***";
    $db='test';
    $conn=mysql_connect($host,$db_user,$db_password) or die (mysql_error());
    mysql_select_db($db) or die (mysql_error());
    
    
    echo $filename=$_FILES["file"]["tmp_name"];
    //echo $ext=substr($filename,strrpos($filename,"."),(strlen($filename)-strrpos($filename,".")));
    
    
    
    
     if($_FILES["file"]["size"] > 0)
     {
    
    
      $file = fopen($filename, "r");
             while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
             {
                
                $sql = "INSERT into leads2(fname, lname, dog) values('$emapData[0]','$emapData[1]','$emapData[2]')";
                mysql_query($sql);
             }
             fclose($file);
             echo "SUCCESS!";
     }
     else
     echo "FAILED!";
    
    
    }
    ?>
    

    Two ways I can think of. First is to check if the primary key exists before executing the insert statement. This is going to be an expensive operation with 100K of records! A better solution would be to use a load operation into a temporary table and then use an INSERT INTO... SELECT FROM... Statement from the temporary table to the table live. You can use a where clause, group by clause clause or the DISTINCT keyword in select it remove all dupes.

    at http://www.mysqlfaqs.net/MySQL-FAQs/Data-back-up/Import-Data/How-to-use-LOAD-DATA-INFILE-s

  • Help! Using CFQUERYPARAM in INSERT statements causes NullPointerException?

    Hi all

    I've never used cfqueryparam with the INSERT statement in cfquery before, but now whenever I have it try, I have a NullPointerException.

    My code:

    < name cfquery = "insertDocEntry."
    result = "docEntry."
    DataSource = "#application. PrimaryDataSource #">"
    INSERT INTO tbl_conference_document
    (SessionID, DocTypeID, symbol, language, Title)
    VALUES)
    < cfqueryparam value = "" #Form.SessionID # "cfsqltype ="cf_sql_numeric">,"
    < cfqueryparam value = "" #Form.DocTypeID # "cfsqltype ="cf_sql_numeric">,"
    < cfqueryparam value = "" #Form.Symbol # "cfsqltype ="cf_sql_varchar">,"
    < cfqueryparam value = "" #Form.Language # "cfsqltype ="cf_sql_varchar">,"
    < cfqueryparam value = "" #Form.Title # "cfsqltype ="cf_sql_varchar">"
    )
    < / cfquery >

    I cfdump the form field and all values are defined, but I always get this error:

    The web site, you access has met an unexpected error.
    Please contact the site administrator.

    The following information is for the creation of Web sites for debugging purposes.
    Error occurred while processing request
    The system has attempted to use an undefined value, which usually indicates an error programming, either in your code or system code.

    NULL pointers are another name for undefined values.

    The error occurred in D:\ColdFusion9\wwwroot\Infobase\Document\execConferenceDocUpload.cfm: line 28

    26 :       <cfqueryparam value="#Form.Symbol#" cfsqltype="cf_sql_varchar">,
    27 :       <cfqueryparam value="#Form.Language#" cfsqltype="cf_sql_varchar">,
    28 :       <cfqueryparam value="#Form.Title#" cfsqltype="cf_sql_varchar">
    29 :     )
    30 :    </cfquery>

    Resources:

    BrowserMozilla/5.0 (Windows; U; Windows NT 5.1; en-US; RV:1.9.2.8) Gecko/20100722 Firefox/3.6.8
    Remote address127.0.0.1
    Referrerhttp://localhost:8501/Infobase/document/uploadConferenceDoc.cfm
    Date/time3 Aug 10 11:48
    Stack trace
    at cfexecConferenceDocUpload2ecfm1876641633.runPage (D:\ColdFusion9\wwwroot\Infobase\Document \execConferenceDocUpload.cfm:28) to cfApplication2ecfc1086350920$ funcONREQUEST.runFunction (D:\ColdFusion9\wwwroot\Infobase\Ap plication.cfc:230)

    java.lang.NullPointerException
         at coldfusion.sql.QueryTable.populate(QueryTable.java:325)
         at coldfusion.sql.QueryTable.populate(QueryTable.java:261)
         at coldfusion.sql.Executive.getRowSet(Executive.java:466)
         at coldfusion.sql.Executive.executeQuery(Executive.java:1248)
         at coldfusion.sql.Executive.executeQuery(Executive.java:1008)
         at coldfusion.sql.Executive.executeQuery(Executive.java:939)
         at coldfusion.sql.SqlImpl.execute(SqlImpl.java:341)
         at coldfusion.tagext.sql.QueryTag.executeQuery(QueryTag.java:843)
         at coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:533)
         at cfexecConferenceDocUpload2ecfm1876641633.runPage(D:\ColdFusion9\wwwroot\Infobase\Document\execConferenceDocUpload.cfm:28)
         at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:231)
         at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:416)
         at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2722)
         at cfApplication2ecfc1086350920$funcONREQUEST.runFunction(D:\ColdFusion9\wwwroot\Infobase\Application.cfc:230)
         at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
         at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
         at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
         at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
         at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
         at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
         at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:490)
         at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:336)
         at coldfusion.runtime.AppEventInvoker.invoke(AppEventInvoker.java:88)
         at coldfusion.runtime.AppEventInvoker.onRequest(AppEventInvoker.java:280)
         at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:338)
         at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
         at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
         at coldfusion.filter.PathFilter.invoke(PathFilter.java:87)
         at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
         at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
         at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
         at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
         at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
         at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
         at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
         at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:53)
         at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:126)
         at coldfusion.CfmServlet.service(CfmServlet.java:200)
         at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
         at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
         at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
         at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
         at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
         at jrun.servlet.FilterChain.service(FilterChain.java:101)
         at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
         at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
         at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
         at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
         at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
         at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
         at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
         at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
         at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

    This error does NOT occur when I don't use cfqueryparam, but my problem is, I need to insert a downloaded file in the database as a BLOB (code not shown above because it is a problem even without BLOB), so far the only way I know how is it to use CFQUERYPARAM.

    Am I the only one seeing this here? So far I only tried to use my CF9 local server (developer edition), the server of CF9 on my colleague has the same problem.

    Here we have a very tight schedule and I really wasn't expecting this kind of problems, so any help and advice is much appreciated!

    Thanks in advance!

    ZHU, Jia

    Yes, I don't think there was a data type mismatch. I was just trying to get more clues on the circumstances in which the error occurs. In other words, it happens every time cfqueryparam is used... or simply when certain types of data are used. Because surely it should not happen.  Maybe a level driver problem, what I do usually is set up a few test cases fast, ideally very simple.  Then use this to determine if there are exceptions to the main issue.  Thus, for example, things like the exception occurs even with a simple insert a column with a varchar column base

    INSERT INTO TestTable (VarcharCol) VALUES ( )

    Also, have you experienced the same results with the jtds driver?

  • Simple Insert statement does not

    This problem is just driving me crazy. I don't know what I'm doing wrong here. The code works fine on my localhost, but gives the problem on the site online. It's a simple insert like this:

    insert into tblSubImages (productid, title, subdescription, image, location) values (#form.productid #, ' #form.title #',' #form.subdescription #',' #uploadedimage # ", #form.place #")

    The error I m to looks like this:

    Syntax error in INSERT INTO statement.

    The error occurred in D:\Hosting\davedhillon\superprinters\admin\addaditional.cfm: line 11

    9: < cfset uploadedImage = cffile.serverfile >
    10: < cfquery name = "insertadditional" datasource = "#super.dsn #" >
    11: insertion in values(#form.productid#,'#form.title#','#form.subdescription#','#uploadedimage#') tblSubImages (productid, title, subdescription, image)
    12: < / cfquery >
    13:



    --------------------------------------------------------------------------------

    SQL insert into values(1,'ewr','werw','FamilyRoomBedroom.jpg') tblSubImages (productid, title, subdescription, image)
    Davedhillon_accesscf_super DATA source
    VENDORERRORCODE 3092

    You can see that it is the simple insert statement that I worked with so many times. Why he started giving problems all of a sudden?

    Thank you

    'Image' can be a reserved word. What happens if you do this?

    insert into tblSubImages (productid, title, subdescription, [image])
    values (...)

  • Decode in an insert statement

    Is it possible to use decode base on a pl/sql variable in the scope of an insert statement?

    For example:

    INSERT INTO emp_schedule
    (employe_id,
    schedule_date,
    destination,
    start_time,
    absent,
    towards the end,.
    entry_date_time,
    Decode (v_bucket_id,

    1,
    bucket1_class,
    2,
    bucket2_class,
    3,
    bucket3_class,
    4,
    bucket4_class,
    5,
    bucket5_class,
    6,
    bucket6_class,
    7,
    bucket7_class,
    8,
    bucket8_class,
    9,
    bucket9_class,
    10,
    bucket10_class,
    11,
    bucket11_class,
    12,
    bucket12_class,
    13,
    bucket13_class,
    14,
    bucket14_class,
    15,
    bucket15_class,
    16,
    bucket16_class,
    17,
    bucket17_class,
    18,
    bucket18_class,
    19,
    bucket19_class,
    20,
    bucke20_class,
    bucket1_class),
    bucket1_class_reghrs,
    bucket1_sched_hrs,
    actual_hours,
    actual_start_time,
    Shift,
    on_the_clock,
    end_of_shift_complete)
    VALUES
    (v_employee_id,
    v_payroll_date1,
    v_destination,
    v_start_punch,
    ' N ',
    ' N ',
    SYSDATE,
    v_class_number,
    v_actual_hrs,
    0,
    v_actual_hrs,
    v_start_punch,
    v_shift,
    v_on_clock,
    'N');

    You have the DECODING in the wrong place

    INSERT INTO emp_schedule
    (
         employee_id,
         schedule_date,
         destination,
         start_time,
         absent,
         late,
         entry_date_time,
         bucket1_class,
         bucket2_class,
         bucket3_class,
         bucket4_class,
         bucket5_class,
         bucket6_class,
         bucket7_class,
         bucket8_class,
         bucket9_class,
         bucket10_class,
         bucket11_class,
         bucket12_class,
         bucket13_class,
         bucket14_class,
         bucket15_class,
         bucket16_class,
         bucket17_class,
         bucket18_class,
         bucket19_class,
         bucket20_class,
         bucket21_class,
         bucket1_class_reghrs,
         bucket1_sched_hrs,
         actual_hours,
         actual_start_time,
         shift,
         on_the_clock,
         end_of_shift_complete
    )
    VALUES
    (
         v_employee_id,
         v_payroll_date1,
         v_destination,
         v_start_punch,
         'N',
         'N',
         SYSDATE,
         DECODE(v_bucket_id, 1,  v_class_number),
         DECODE(v_bucket_id, 2,  v_class_number),
         DECODE(v_bucket_id, 3,  v_class_number),
         DECODE(v_bucket_id, 4,  v_class_number),
         DECODE(v_bucket_id, 5,  v_class_number),
         DECODE(v_bucket_id, 6,  v_class_number),
         DECODE(v_bucket_id, 7,  v_class_number),
         DECODE(v_bucket_id, 8,  v_class_number),
         DECODE(v_bucket_id, 9,  v_class_number),
         DECODE(v_bucket_id, 10, v_class_number),
         DECODE(v_bucket_id, 11, v_class_number),
         DECODE(v_bucket_id, 12, v_class_number),
         DECODE(v_bucket_id, 13, v_class_number),
         DECODE(v_bucket_id, 14, v_class_number),
         DECODE(v_bucket_id, 15, v_class_number),
         DECODE(v_bucket_id, 16, v_class_number),
         DECODE(v_bucket_id, 17, v_class_number),
         DECODE(v_bucket_id, 18, v_class_number),
         DECODE(v_bucket_id, 19, v_class_number),
         DECODE(v_bucket_id, 20, v_class_number),
         DECODE(v_bucket_id, 21, v_class_number),
         v_actual_hrs,
         0,
         v_actual_hrs,
         v_start_punch,
         v_shift,
         v_on_clock,
         'N'
    );
    
  • Script Insert statement to extract data from Table in Oracle 7i

    Hi all, I have an old Oracle legacy system that works for more than 15 years. Every now and then, we need to extract data from this table @ ORacle 7i to import to Oracle 10 G.

    My thoughts are to create a script to Insert statements in oracle 7 and that, to be deployed to Oracle 10 G.

    I found cela scripts in Google and don't know exactly how it works. No explanation on these scripts, would be greatly appreciated. I find that this format can help to produce a set of insert statements in this table to the last table to 10G.

    < pre >
    -Step 1: create this procedure:
    create or replace function ExtractData (v_table_name varchar2) return varchar2 as
    Boolean b_found: = false;
    v_tempa varchar2 (8000);
    v_tempb varchar2 (8000);
    v_tempc VARCHAR2 (255);
    Start
    for tab_rec in (select table_name from user_tables where table_name = upper (v_table_name))
    loop
    b_found: = true;
    v_tempa: =' select ' insert into ' | tab_rec.table_name |' (';
    for col_rec in (select * from user_tab_columns)
    where
    table_name = tab_rec.table_name
    order by
    column_id)
    loop
    If col_rec.column_id = 1 then
    v_tempa: = v_tempa | " ' || Chr (10) | " ' ;
    on the other
    v_tempa: = v_tempa |', ". Chr (10) | " ' ;
    v_tempb: = v_tempb |', ". Chr (10) | " ' ;
    end if;
    v_tempa: = v_tempa | col_rec.column_name;
    If instr(col_rec.data_type,'CHAR') > 0 then
    v_tempc: = "' |' | col_rec.column_name |'| " ' ;
    elsif instr (col_rec.data_type, 'DATE') > 0 then
    v_tempc: = "' to_date ("'| to_char('|| col_rec.column_name||',''mm/DD/YYYY HH24 '') | ") (', "' dd/mm/yyyy hh24"') "';
    on the other
    v_tempc: = col_rec.column_name;
    end if;
    v_tempb: = v_tempb | " ' || Decode('|| col_rec.column_name||',''Null'','||v_tempc||') | " ' ;
    end loop;
    v_tempa: = v_tempa |') values ('| v_tempb |'); "from ' |" tab_rec.table_name | « ; » ;
    end loop;
    If not b_found then
    v_tempa: ='-Table ' | v_table_name | 'not found ';
    on the other
    v_tempa: = v_tempa | Chr (10) | "select"-commit; "double;';
    end if;
    Return v_tempa;
    end;
    /
    display errors

    -STEP 2: run the following code to extract the data.
    Go head
    set pages 0
    game of stripes on
    fixed lines 2000
    the feeding off value
    trigger the echo
    var retline varchar2 (4000)
    coil c:\t1.sql
    Select 'set echo off' from dual;
    Select 'spool c:\recreatedata.sql' from dual;
    Select ' select "-these data was extracted on" | TO_CHAR (sysdate, "mm/dd/yyyy hh24" ") double;' double.

    -The following two lines as repeat as many times as the tables that you want to extract
    exec: retline: = ExtractData ('dept');
    print: retline;

    exec: retline: = ExtractData ('emp');
    print: retline;

    Select 'off spool' from dual;
    spool off
    @c:\t1

    -Step 3: run the updated c:\recreatedata.sql waiting for output to recreate the data.

    Source: http://www.idevelopment.info/data/Oracle/DBA_tips/PL_SQL/PLSQL_5.shtml




    < / pre >

    Hello

    Well what this script do.
    You will pass a table name as input to the function that will return varchar2 (string - insert statement). It will generate 2 t1.sql of sql script that contains the output sequence.

    Will use the first passed the user_tables scipt to check if the input table name exists and if there is the will reterive user_table_columns column names and generate the following sql script.
    Now, this t1.sql will run to generate a final sript formally orders insert that will run you on the target schema (make sure that the table exists).

    * #t1.sql*

    set echo off
    spool recreatedata.sql
    select '-- This data was extracted on '||to_char(sysdate,'mm/dd/yyyy hh24:mi') from dual;
    select 'insert into MY_OBJECT1 ('||chr(10)||'OWNER,'||chr(10)||'TOTAL) values ('||decode(OWNER,Null,'Null',''''||OWNER||'''')||','||chr(10)||''||decode(TOTAL,Null,'Null',TOTAL)||');' from MY_OBJECT1;
    select '-- commit;' from dual;
    spool off
    

    Then @t1.sql runs, and the general insert for the infeed table table.

    -- This data was extracted on 03/09/2009 23:39
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('MDSYS', 92800);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('TSMSYS', 256);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('DMSYS', 15104);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('TESTME', 128);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('PUBLIC', 2571392);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('OUTLN', 768);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('CTXSYS', 21888);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('OLAPSYS', 78336);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('KLONDIKE', 2432);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('SYSTEM', 51328);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('EXFSYS', 21504);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('DBSNMP', 4096);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('ORDSYS', 216192);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('SYSMAN', 111744);
    
    -- commit;
    

    Hope this helps
    Concerning

  • INSERT statement executes before if statements

    Hi all

    I'm trying to validate some fields before their insertion in the table.
    for example:

    IF params ('txtID') IS NULL THEN
    "SOME MSG."
    ELSIF ('txtName') params IS NULL THEN
    "SOME MSG."
    END IF;

    INSERT INTO TABLE T1
    VALUES (params ('txtID'), params('txtName');

    What I want to do is: I want to validate two fields before inserting it.

    Can someone help me?

    Thank you
    H.

    Hello

    If you don't test NOT NULL you don't have to do anything because the database tells you the error. If you want to perform another validation if I were you, I'll create a package API to manage integration.

    Draught:

    DECLARE
        parameter_error EXCEPTION;
    BEGIN
    
        IF PAR1 IS NULL THEN
            RAISE parameter_error;
        END IF;
    
        IF PAR2 IS NULL THEN
            RAISE parameter_error;
        END IF;
    
        INSERT INTO TABLE TEST
            (col1,
             col2)
        VALUES
            (PAR1,
             PAR2);
    
        COMMIT;
    EXCEPTION
        WHEN parameter_error THEN
        -- Manage the exception here...
    END;
    /
    

    Kind regards

    Published by: Walter Fernández on February 2, 2009 17:52

  • Qosmio G50 PQG55A: remote control jumps two places in the list of the menu of WMC

    I have a version of the G50 (PQG55A-04J01Y) Aust and have just done a clean install of Windows 7 (64-bit).
    Everyone thinks that when using the provided Toshiba RC6 remote in Windows Media Center, it jumps two places in the list of the menu.

    I downloaded the driver Winbond CIR, Win7, but it makes no difference.

    Very annoying as it does on all manu lists and even ignores the channels while watching TV.

    Someone at - he seen elsewhere or have a possible solution?

    See you soon

    There is a package called Remote Control Manager.
    This driver is required to install the remote control of your computer.

    The package is only for Vista, but maybe you should try to install too

Maybe you are looking for

  • Operating system

    I tried to download a book on my shelf in the corner, but I was told that my OS was not the right one. It's never happened before. What's the story?

  • How to prevent the opening of new windows in firefox? I want ONE INSTANCE ONLY.

    I want to avoid the pop ups, pop unders, etc.. Literally not a single response was appropriate, so I rephrase the question. I want firefox even simply not acknowledge the request to open a new window or tab of the HTML, server, Web site, etc. I don't

  • Satellite Pro A300 random freezes

    I had this problem for the last few weeks. Started during the game Football Manager 2011 and Windows Media Player in the background.Blue screen crash is came and never recovered from that, so I have it restored to its original condition and installed

  • Pavilion dv9005us does not illuminate

    My Pavilion dv9005us does not light with or without the battery. I held the power to discharge remaining power, then plugged in the ac adapter shows blue light to the decision-making of the laptop, but none of the front lights light up. The motherboa

  • Connected to internet but not able to access Web sites

    Hello I have a Dell Latitude E5410 using Windows 7 ultimate with IE 8 The laptop seems to be connected to the internet but not able to browse any websites. I checked with IE, Google chrome, firefox as well. I disabled the proxy settings in the LAN to