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...

Tags: Oracle Development

Similar Questions

  • Looking for a better style or a way to write the INSERT statement, possible with brand of continuation

    Honestly, I really looked everywhere for this.

    The problem is that, while tinkering in SQL Developer and knowing that in the spreadsheet I can just execute individual instructions by placing the cursor on the SQL statement I want to run I tried to do an INSERT query that would allow me to run an INSERT statement for... Well many inserts.

    I thought I could use a brand of continuation but nothing I've tried has worked.

    INSERT INTO

    HF_easy_drinks

    VALUES

    ("Blackthorn", "tonic water", 1.5, 1.0, "pineapple juice", "mix with ice").

    ("Blue Moon", "soda", 1.5 "Blueberry Juice",. 75, "mix with ice, strain")

    ;


    I ended up doing just individual INSERT statements, which was not as convenient.

    INSERT INTO HF_easy_drinks

    VALUES ('Blackthorn', 'tonic water', 1.5, 1.0, "pineapple juice", "mix with ice");

    INSERT INTO HF_easy_drinks

    VALUES ('Blue Moon', 'soda', 1.5, 'Blueberry Juice',. 75, "mix with ice");

    Hello

    Perhaps you might prefer "an" insert like this:

    INSERT INTO hf_easy_drinks (x, y, z,...)
    SELECT "Blackthorn", "tonic water", 1.5, 1.0, "pineapple juice", "mix with ice" OF THE double
    UNION ALL SELECT 'Blue Moon', 'soda', 1.5, 'Blueberry Juice',. 75, "mix with ice, strain ' FROM dual
    SELECT UNION ALL... OF the double
    SELECT UNION ALL... OF the double
    ;

    Best regards

    Bruno Vroman.

  • 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.

  • 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?

  • Reg: Insertion of > 4 k characters clob data

    Hi Experts,

    I have a text that is more than 4K characters, so I'm not able to store it in a CLOB table column using a simple INSERT statement.

    Read this technique by Solomon and have tried it, but do not get the result:

    DECLARE
    query_txt CLOB: = to_clob (q '[my_text_goes_here]');

    I have SEVERAL;
    j NUMBER;

    CLOB x;

    BEGIN

    I: = 4000;
    j: = 1;

    -dbms_output.put_line (Dbms_Lob.getlength (query_txt));
    -ALL-IN (DBMS_LOB. SUBSTR (query_txt, i, j) IS NOT NULL)

    x: = "insert into query_master values (q 3," [';]) "

    LOOP
    -Dbms_Output.put_line (j: ' * ' | i |' * ' |) DBMS_LOB. SUBSTR (query_txt, i, j));

    x : = x || DBMS_LOB. SUBSTR (query_txt, i, j);

    j: = i + 1;
    i: = i + 4000;

    WHEN THE EXIT DBMS_LOB. SUBSTR (query_txt, i, j) is null;
    END LOOP;

    x : = x ||'] ("," aaa,"bb", "Y", "BK FILED")';

    EXECUTE IMMEDIATE x; -USING: query_txt.

    -Dbms_Output.put_line (x);
    -Dbms_Output.put_line (Dbms_Lob.SubStr(x,1000,1));

    EXCEPTION
    WHILE OTHERS then
    Dbms_Output.put_line (Dbms_Utility.format_error_backtrace |) SQLERRM);
    END;

    My idea was to make pieces of 4000 characters and then pass it to the Insert statement.

    SQL > query_master desc;

    Name                                      Null?    Type

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

    QID                                                NUMBER

    QUERY_TEXT CLOB

    QUERY_COLS VARCHAR2 (3500)

    IS_ACTIVE CHAR (1)

    WORKSHEET_NAME VARCHAR2 (50)

    Could if it you please let me know where I am doing wrong?

    Thank you and best regards,

    -Nordine

    (on Oracle 11.2.0.3.0 - Exadata )

    Not sure what you are talking.
    
    SQL> create table t (id integer, str clob);
    
    Table created.
    
    SQL> declare
      2    l_clob clob := rpad('karthick', 20000, 'x');
      3  begin
      4    insert into t (id, str) values (1, l_clob);
      5  end;
      6  /
    
    PL/SQL procedure successfully completed.
    
    SQL> select id, dbms_lob.getlength(str) str_len
      2    from t;
    
            ID    STR_LEN
    ---------- ----------
             1      20000
    
  • 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

  • Need help with the insert statement

    Hello

    I have a question on how to write a SQL statement.

    This is the table of "base":
    CREATE TABLE TEMP_TBL
    (
    id_nr NUMBER,
    DATE_DOK DATE,
    DATE_DUE DATE,
    DATE_DOK_PAY DATE,
    DEB NUMBER,
    KRD NUMBER
    );
    
    insert into temp_tbl (ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('1',TO_DATE('11.01.2011','DD.MM.YYYY'),TO_DATE('25.02.2011','DD.MM.YYYY'),NULL,'423,24','0');
    insert into temp_tbl(ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('2',TO_DATE('16.12.2011','DD.MM.YYYY'),TO_DATE('13.06.2011','DD.MM.YYYY'),NULL,'91270,15','0');
    insert into temp_tbl(ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('3',TO_DATE('27.09.2011','DD.MM.YYYY'),TO_DATE('27.09.2011','DD.MM.YYYY'),NULL,'0','2000');
    and it comes to resoult in the target table. SQL statement must take care of the insert in a base of the target table table (example below is already provided with test data).
    create table table_sod
    (
    
          id_nr number
         ,date_from date
         ,date_to date
         ,deb_krd number
    
    );
    
    One thing to note here :  values in column deb_krd under insert 1 and 4 must be summarized in insert 4.
    
    insert into table_sod (id_nr,date_from,date_to,deb_krd) values('1',null,to_date('25.02.2011','dd.mm.yyyy'),'423,24');
    insert into table_sod(id_nr,date_from,date_to,deb_krd) values('2',to_date('26.02.2011','dd.mm.yyyy'),to_date('13.06.2011','dd.mm.yyyy'),'423,24');
    insert into table_sod(id_nr,date_from,date_to,deb_krd)values('3',null,to_date('13.06.2011','dd.mm.yyyy'),'91270,15');
    insert into table_sod(id_nr,date_from,date_to,deb_krd)values('4',to_date('14.06.2011','dd.mm.yyyy')to_date('27.09.2011','dd.mm.yyyy'),'91693,39');
    insert into table_sod(id_nr,date_from,date_to,deb_krd)values('5',null,to_date('27.09.2011','dd.mm.yyyy'),'2000');
    If someone could give me a helping hand how write correct insert statement I would be really gratefull.

    Thank you for your time!

    I came here with my own assumptions with this

    SQL> select rownum id_nr
      2       , date_from
      3       , date_to
      4       , case when date_from is null then deb
      5              else sum(case when date_from is not null then deb else 0end) over(order by id_nr, no)
      6         end deb_krd
      7    from (
      8            select id_nr
      9                 , case when lg_dt is null or ld_dt = date_due then  null else lg_dt+1 end date_from
     10                 , ld_dt date_to
     11                 , case when deb = 0 then krd else deb end deb
     12                 , no
     13              from (
     14                      select t1.*
     15                           , lead(t1.date_due) over(order by t1.id_nr, t2.no) ld_dt
     16                           , lag(t1.date_due) over(order by t1.id_nr, t2.no) lg_dt
     17                           , t2.no
     18                        from temp_tbl t1
     19                       cross
     20                       join (select 1 no from dual union all select 2 no from dual) t2
     21                       order by id_nr, no
     22                   )
     23             where ld_dt is not null
     24         )
     25  /
    
         ID_NR DATE_FROM DATE_TO      DEB_KRD
    ---------- --------- --------- ----------
             1           25-FEB-11      42324
             2 26-FEB-11 13-JUN-11      42324
             3           13-JUN-11    9127015
             4 14-JUN-11 27-SEP-11    9169339
             5           27-SEP-11       2000
     
    
  • Insert statement error

    Hello

    I have to write an insert statement. in which I want to promt user to enter values.

    Here's the app_name column varchar2 data type.

    INSERT INTO GSM_APP_INFO
    (APP_NAME)
    values
    (& app_name);

    but make a mistake:
    ORA-00984: column not allowed here


    Please suggest me.

    Thank you

    Use single quotes

    insert into gsm_app_info
    (app_name)
    values
    ('&app_name');
    
  • 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;
    
  • 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

  • trigger for the insert statement

    Hello.
    I have a table, say, with 3 columns: ID, NAME, NAME_LENGTH.
    I am trying to create a trigger that fires when a record is inserted in the table.
    I send values for the ID and NAME columns per INSERT statement. and I need the trigger to write the LENGTH OF THE NAME INSERTED in the 3rd column

    CREATE OR REPLACE TRIGGER schema_name. GENERATE_length
    AFTER INSERT ON table_name
    FOR EACH LINE
    DECLARE
    F NVARCHAR2 (200);
    L NUMBER (5);
    NL NUMBER (5);
    NUMBER OF ID_LENGTH (5): = 5;
    BEGIN
    F: =:New.Name;

    L: = LENGTH (F);

    UPDATE HR_ORG_TREE

    SET name_length = NL;

    END;


    but does not work. error occurres as...

    ORA-04091: table schema_name.table_name is changing, the function of triggering/can not see
    ORA-06512: at the 'schema_name '. GENERATE_length', line 13
    ORA-04088: error during execution of trigger ' schema_name. GENERATE_length'

    Thank you.
    Sara
    CREATE OR REPLACE TRIGGER schema_name.GENERATE_length
        -- is "table_name" real name of your table?
        AFTER INSERT ON table_name
        FOR EACH ROW
    BEGIN
        -- this update will change all rows in HR_ORG_TREE table
        -- specify WHERE for this update
        UPDATE HR_ORG_TREE
           SET name_length = LENGTH(:NEW.name);
    END;
    

    Suppose your table_name is HR_ORG_TREE and you need to calculate the length of the name for just inserted row
    After maybe the code will be useful (not tested)

    CREATE OR REPLACE TRIGGER schema_name.GENERATE_length
        BEFORE INSERT ON HR_ORG_TREE
        FOR EACH ROW
    BEGIN
        :new.name_length := LENGTH(:NEW.name);
    END;
    

    Good luck

  • 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

  • marks insert statement

    Hello
    RDBMS: 102 Standard Edition

    I have to calculate the load (CPU, DISK, memory, etc.) of my insert statements. What is the best practice to achieve this?

    I have to select computer too, I am currently using explain plan to analyze the performance of the select query. Is there a better alternative?

    Trace/Tkprof with wait events (10046 level).
    And if you're a true die-hard: a level 10053 trace ;)

    See examples here:
    http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:6020271977738 #7417489961326

    And of course the Performance Tuning Guide:
    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14211/TOC.htm
    from: http://www.oracle.com/pls/db102/homepage

    Edit
    Also very practical: Tom Kyte Runstats
    http://asktom.Oracle.com/pls/asktom/asktom.download_file?p_file=6551378329289980701

    Published by: hoek on December 23, 2010 13:28

Maybe you are looking for

  • Roll of photos in the mess in the iOS 10

    I just got my new iPhone 7 and after successfully it restore a backup from my iPhone 6, I noticed that all my photos in the film are out of sync. I realize they're supposed to be in chronological order of when they were taken, but they are very mixed

  • Red brand and burning sensation on the wrist band sport - Apple Watch

    After all 3-4 months to have Apple Watch and wear while exercising, I have developed a small red mark and burning inside the wrist. Anyone with problems and tips on how to combat this similar problem. Do not wear the watch is not an option for me.

  • If you have XP service pack 3, you still have to have sp 2 on your pc?

    Original title: windows xp If you have xp service pack 3 do you still have to have sp 2 on your pc or can I remove sp 2

  • Rotuer security issue

    I don't really know the difference between the different router security modes.  Currently mine is set too personal WPA.  What is the best configuration for my home network, so someone can use my internet. My options are WEP WPA Personal WPA2 Persona

  • is the driver for win 8 for the printer photosmart D7360 RGB or CMYK?

    Hello I'll use Lightroom 4.2 (under win 8 64) and will have calibrated the monitor and the printer (HP Photosmart D7360) by colormunki photo. When the printer profile is generated by colormunki, according to the real printer driver, they will be RGB