Insert several lines of table1 from table2

$selectSQL = sprintf ("SELECT * FROM 'completetransaction'")

WHERE "merchant_id" = %s

(AND "com_tran_date" = %s", GetSQLValueString ($merchantid,"text"), GetSQLValueString ($tran_com_date, 'date'));

$Result1 = mysql_query ($selectSQL, $conn) or die (mysql_error ());

for example, the above query returns two rows

How can I insert it to table (deposit_transaction) another

How should I fetch the data from the query above and insert it into deposit_transaction.

If I need to use the loop... How should I build it

$insertSQL = sprintf ("INSERT INTO ' deposit_transaction'('transactionid', 'merchantid', 'quantité', 'rolling_reserve', 'tdr', 'merchant_money', 'depositdate') VALUES (%s, %s, %s, %s, %s, %s %s)", GetSQLValueString ($transactionid, "int"), ")

GetSQLValueString ($merchantid, "text"),

GetSQLValueString ($amount, "int"),

GetSQLValueString ($rr, "int"),

GetSQLValueString ($tdr, "int"),

GetSQLValueString ($mm, "int"),

GetSQLValueString ($depositdate, 'date'));

$Result1 = mysql_query ($insertSQL, $conn) or die (mysql_error ());

Looks good except that your SELECT statement does not include the column 'depositdate' the insertion fails. Fix that and it should work.

I also ask you to standardize on your database table and column name conventions. You have some with underscores and other free features. It should be consistent. Also, make sure that your column names clearly have their meaning. That means "tdr"?

Tags: Dreamweaver

Similar Questions

  • Insert several lines in trigger?

    can someone tell me how can I insert several lines in a trigger. I tried several ways, and so far nothing works.

    create or replace

    USER_GROUPS_TRIG RELAXATION

    before INSERT ON USER_GROUPS

    FOR EACH LINE

    DECLARE

    number of max_id;

    BEGIN

    SELECT TO_NUMBER (new_id) + 1 as new_id in max_id OF NEW_ID_VW;

    INSERT THE TBL1

    (USER NAME)  VALUES

    (max_id,: NEW.) (NEW); -It works very well and needs no adjustment, 1 inserted row.

    MERGE INTO GROUP_MAPPING HAS

    USING (SELECT USER_ID, GROUP_ID ADMIN_GROUPS_VW) B

    ON (A.USER_ID = B.USER_ID)

    WHEN NOT MATCHED THEN

    INSERT (A.USER_ID, A.GROUP_ID)

    values (b.user_id, b.group_id);

    -FOR V IN 1.10 IN LOOP

    -INSERTION IN GROUP_MAPPING (user_id, group_id)

    -(select user_id, group_id from admin_groups_vw);

    -END LOOP;

    -INSERT IN GROUP_MAPPING

    --(USER_ID, GROUP_ID) VALUES

    -(max_id, (select group_id from admin_groups_vw));

    -None of these POPs an error, just does not have the insert (there are several records, so there should be several inserted rows), I tried to insert, loop and fusion.

    END;

    Thanks for any help.

    Hello

    Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.

    Also post the exact results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.

    If you ask on a DML statement, such as CREATE TABLE, INSERT, INSERT statements must re-create the tables as they are to the DML, and the results will be the content of the or a modified tables when it's all over.

    In this case, after complete relaxation and a DML statement that triggers, too.

    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?

    Is admin_groups_vw a notice?  This it is, and the view depends on the table you are inserting (user_groups), then you will get a runtime error because the picture is changing.  A FOR EACH ROW trigger on user_groups can't question user_groups.  You said: "none of these POPs an error", but are you sure you're not getting a runtime error and just hide?

  • Procedure to insert several lines

    create or replace procedure relevent_doc_after_insert (JOBNUMBER IN varchar2,
    DOCNAME IN VARCHAR2)
    IS
    PRAGMA AUTONOMOUS_TRANSACTION;
    vDocName VARCHAR2 (80);

    CURSOR insertAfterdata
    IS
    SELECT mnd_doc_name
    OF clm_min_doc_to_process
    WHERE mnd_doc_name! = DOCNAME;


    BEGIN
    OPEN insertAfterdata.
    LOOP
    EXTRACTION insertAfterdata
    IN
    vDocName;

    EXIT WHEN insertAfterdata % NOTFOUND;

    INSERT INTO clm_relevent_doc (rd_id,
    rd_job_no,
    rd_doc_name,
    rd_created_user,
    rd_created_date,
    rd_status)
    VALUES (relevant_doc_sequence. NEXTVAL,
    JOBNUMBER,
    vDocName,
    'system ', he said.
    To_char (SYSDATE, "yyyy-mm-dd HH12:MI:SS"),
    'pending');

    COMMIT;
    END LOOP;
    CLOSE InsertAfterdata;

    EXCEPTION
    WHILE OTHERS THEN
    NULL;

    END;



    Above is my procedure

    I pass below the settings during the execution
    JOBNUMBER = 123
    DOCNAME = driving licence



    When the CURSOR query get the 3rows as a result but insert several rows in the clm_relevent_doc table, why did this happen.

    It does not work properly, is it not? If this isn't the case, then please point where.

    Also as knani questioned, and so I did (although not confirmed), you really need the independent transaction? can you justify using autonomous transactions, in this procedure?

    select *
      from clm_min_doc_to_process;
    
    MND_ID                 MND_DOC_NAME       MND_DOC_CODE
    ---------------------- ------------------ --------------------
    1                      Driving Licence    DL
    2                      SA Report          SARPT
    3                      Estimate           EST
    4                      Photos             PHOT    
    
    select *
      from clm_relevent_doc;
    
    RD_ID                  RD_JOB_NO       RD_DOC_NAME    RD_CREATED_USER   RD_CREATED_DATE  RD_ADD_DOC_NAME  RD_UPDATE_USER   RD_REQUEST RD_REQUEST_METHOD RD_STATUS RD_RECEIVED_DATE_TIME
    ---------------------- --------------- -------------- ----------------- ---------------- ---------------- ---------------- ---------- ----------------- --------- --------------------- 
    
    set serveroutput on;
    begin
      relevent_doc_after_insert(123, 'Photos');
    end;
    
    anonymous block completed
    3 rows inserted
    
    select *
      from clm_relevent_doc;
    
    RD_ID                  RD_JOB_NO       RD_DOC_NAME     RD_CREATED_USER RD_CREATED_DATE     RD_ADD_DOC_NAME RD_UPDATE_USER RD_REQUEST RD_REQUEST_METHOD RD_STATUS RD_RECEIVED_DATE_TIME
    ---------------------- --------------- --------------- --------------- ------------------- --------------- -------------- ---------- ----------------- --------- ---------------------
    1                      123             Driving Licence system          2013-01-21 06:43:23                                                             pending
    2                      123             SA Report       system          2013-01-21 06:43:23                                                             pending
    3                      123             Estimate        system          2013-01-21 06:43:23                                                             pending                        
    
  • Insert several lines with dynamic data

    Hello
    When I do an insert into a table that has several lines of dynamic information. on
    a page, it inserts all rows that are dynamically filled. I want only what he
    to insert the lines that I choose the initials on. How can I do? Let's say I
    have 5 items that are displayed on a page and I want to insert only original
    the first 2 because the last 3 are left blank, how should I do this? I tried
    implementation of an if statement that says:

    < cfif "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".

    Then make the insertion in the table

    < cfelse >
    < / cfif >

    I have this game were also up in a loop that says:

    < cfloop index = "help" list = "" #form.listofids # "delimiters =",">"

    Here is the code for just the insertion. I also have a code here
    Update another table. I got this to work, so I just try to get the insertion
    works fine for the moment. I can not use this where the query statement:
    Where ItemID = #id # because I'm trying to insert into the table of approval, not
    the items table. The table is just updated with some other info. in
    a few other input boxes.

    < cfloop index = "help" list = "" #form.listofids # "delimiters =",">"
    < cfif "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".

    < cfquery Datasource = '#application. DataSource #">"
    Insert into accreditation (APV_ItemID,
    APV_ECID,
    Document_Type,
    Approval_Initials)

    Values (' #Evaluate ("form.) (' ItemID # help # ") #',
    ' #Evaluate ("form. ("ECID # help #") #',
    < cfif isDefined (form '. ') ("Help of # PNR_Doc_Type # ') and
    "form. "Help of # PNR_Doc_Type #" NEQ "" > "".
    ' #Evaluate ("form. ("Help of # PNR_Doc_Type # ') #',
    < cfelse >
    NULL,
    < / cfif >

    < cfif isDefined (form '. ') ("Help of # PNR_Approval_Initials # ') and
    "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".
    ' #Evaluate ("form. (Aide de # PNR_Approval_Initials #») #
    < cfelse >
    Null value
    (< / cfif >)

    < / cfquery >

    < / cfif >
    < / cfloop >

    On the page display, just a table of dynamic info. Here are the 4
    things that I have on this page that needs to be inserted to the database.

    < input type = "hidden" name = "' ECID #ItemID #" value = "#ECID #" > "
    < input type = "hidden" name = "' ItemID #ItemID #" value = "#ItemID #" > "
    < input type = "hidden" name = "" PNR_Doc_Type #ItemID # ' value = "PNR Req" > "

    < td align = "center" >
    < cfif Approval_Initials is not "" > "".
    #Approval_Initials #.
    < cfelse >

    < select name = "PNR_Approval_Initials #ItemID #" >
    < option value = "" > select initials < / option >
    < cfloop query = "ShowInitials" >
    < Cfif Engineer_Initials EQ 1 >
    < option value = "#Initials #" > #Initials # < / option >
    < / cfif >
    < / cfloop >
    < / select >

    < / cfif >
    < table >

    Can someone help me please on just the insertion in the database so that it
    will insert on the lines that I chose the initials on and not others? Thank you.

    Andy

    You almost managed, but I see that you have commented.

    (" The help of # PNR_Approval_Initials # ') AND form ["PNR_Approval_Initials # help #" ""] NEQ "" >

    Do things here

  • Insert several lines of Radio button

    I need to do multiple inserts in an Access table from a form her you choose multiple of any number of questions answers. As the fields of the form are radio buttons I can't loop through a list to process inserts. I'm struggling with the creating a loop to do inserts since each form field response boxes each has a different/unique name. Any suggestions on how to configure the loop would be appreciated. Here is a code example.

    The solution that solved the problem is the code "["Answer"& loop] #orm # I initially tried "#form." Answer ' & loop # ", but once I applied your code, the loop worked fine.
    Thanks for the help.

  • Insert the statement with the subquery to insert several lines

    Hi friends,

    Please find below mentioned query and error. Also suggest me to go forward.

    SQL > INSERT INTO FM_TRAN_DOC_NO (TDOC_COMP_CODE,

    2 TDOC_TRAN_CODE,

    TDOC_ACNT_YEAR 3,.

    TDOC_CUR_NO 4,.

    TDOC_MAX_NO 5,.

    TDOC_CAL_YEAR 6,.

    TDOC_PERIOD 7,.

    TDOC_DIVN_CODE 8,.

    TDOC_DEPT_CODE 9,.

    TDOC_CR_UID 10,

    TDOC_CR_DT 11,

    TDOC_UPD_UID 12,

    13 TDOC_UPD_DT)

    14 SELECT '001',

    15 (SELECT DISTINCT FM_TRAN_DOC_NO TDOC_TRAN_CODE

    16               '6',

    17               '0',

    18 '9999',

    19 NULL,

    20 NULL,

    21 NULL,

    22 NULL,

    23 "AGT,"

    24 TO_DATE (SYSDATE),

    25 NULL,

    26 TO_DATE (SYSDATE) FROM DUAL;

    (SELECT DISTINCT FM_TRAN_DOC_NO TDOC_TRAN_CODE),

    *

    ERROR on line 15:

    ORA-01427: einreihig subquery returns multiple rows

    +Untested.

    When values except 'TDOC_TRAN_CODE' are hardcoded, there is no need to select double.

    Something like that?

    INSERT INTO FM_TRAN_DOC_NO)

    TDOC_COMP_CODE,

    TDOC_TRAN_CODE,

    TDOC_ACNT_YEAR,

    TDOC_CUR_NO,

    TDOC_MAX_NO,

    TDOC_CAL_YEAR,

    TDOC_PERIOD,

    TDOC_DIVN_CODE,

    TDOC_DEPT_CODE,

    TDOC_CR_UID,

    TDOC_CR_DT,

    TDOC_UPD_UID,

    TDOC_UPD_DT

    )

    SELECT DISTINCT

    '001',

    TDOC_TRAN_CODE,

    « 6 »,

    '0',

    "9999",

    NULL,

    NULL,

    NULL,

    NULL,

    "AGT,"

    TO_DATE (SYSDATE),

    NULL,

    TO_DATE (SYSDATE)

    OF FM_TRAN_DOC_NO;

  • Need help to insert several lines using PL/SQL

    Hi gurus,

    I wrote a simple PL/SQL to insert the recrods in a table. It works fine if the sql script that is stored in the column to the table TEST_VALIDATION SCRIPT returns a single line. Can you get it someone please let me know a better way to insert multiple results returned by the script? Rest columns can be duplicated.

    DECLARE

    p_rows default NUMBER of 0;

    CURSOR C1_TV
    IS
    SELECT ID, DESCRIPTION, TEST_VALIDATION SCRIPT;

    BEGIN

    FOR C1_TV_REC in C1_TV
    LOOP

    Run immediate C1_TV_REC. SCRIPT in p_rows;

    INSERT INTO THE VALIDATION
    (END_DATE,
    VALIDATION_ID,
    VALIDATION_DESCN,
    VALIDATION_COUNT
    )
    VALUES
    (
    (select sysdate to DOUBLE),
    C1_TV_REC.ID,
    C1_TV_REC. DESCRIPTION,
    p_rows
    );

    COMMIT;

    END LOOP;

    END;
    /

    Please let me know if this isn't clear.

    Thank you
    Shash

    You need something like that

    declare
      p_rows dbms_sql.number_table;
      i pls_integer;
    begin
      execute immediate SCRIPT bulk collect into p_rows;
      i:=1;
      loop
        exit when i>p_rows.count;
        insert... p_rows(i)....
        i:=i+1;
      end loop;
    end;  
    

    or the much faster method (if it works in your case)

    declare
      p_rows dbms_sql.number_table;
      i pls_integer;
    begin
      execute immediate SCRIPT bulk collect into p_rows;
      forall i in p_rows.first..p_rows.last
         insert into table (field) values (p_rows(i));
    end;  
    

    And why you use

    (select sysdate from DUAL)
    

    Just use

    sysdate
    

    Published by: Oleg Gorskin the 12.01.2010 06:51
    Add method with forall

  • Database Connectivity Toolkit (insert multi line)

    Hi all. I recently got the toolkit of connectivity (DBCT) database on LabVIEW 2016 and I try to insert several rows in a database.

    Using a sine signal input I tried to insert 50 rows in an iteration, but each method I tried returned 50 values in a line. The end of the constant of the line and table using chain worksheet, returned what looked like 50 lines, but when I questioned "SELECT COUNT (*) FROM... "the number of rows equals the number of iterations.

    On another post on the forum, someone suggested that it is not possible to insert several lines using the DBCT. Can anyone confirm this?

    I wrote a code that allows me to insert 3 rows in an iteration, under a single connection. However, this method is very time consuming and would not work for large amounts of data.

    Can anyone think of a better way to do it?

    Thanks in advance,

    Lisa

    Create your own query, and use the query execute VI.

  • How to insert multiple lines using a single query

    Hi all

    How to insert multiple lines using a single query to the emp table?
    I have the number of rows to insert into table x. consumes a lot of time. I tried to insert several lines using a single query, but get errors. I know exactly the query to do this.


    Thank you
    Sunil

    Like this?

    SQL> create table test(id number , dt date);
    
    Table created.
    
    SQL> insert into test values(&a,&b);
    Enter value for a: 1   --- It asked me and I entered 1
    Enter value for b: sysdate  --- It asked me and I entered sysdate
    old   1: insert into test values(&a,&b)
    new   1: insert into test values(1,sysdate)
    
    1 row created.
    
    SQL> 
    

    g.

  • How to insert a line checked several

    Hi friends,

    IM facing a scenario. Let me explain.

    I have a page with a report and a button (these two in a homepage).

    I have a tabular presentation based on a table that opens in a pop-up window by pressing a button located on the home page. In this sick in tabular form be select several lines and if I press Add button in the pop - up, then all the lines checked must insert in the table report located in the home page.

    How can I achieve this.

    Can someone help me with this problem.

    Brgds,
    Mini

    Mini,

    I've updated my example for you.

    There are several ways to accomplish what you're looking for, here are two options:
    1. make an ajax call on beforerefresh pop-up report.
    2 persists the values checked in a page element and use it instead of an array.

    In my example, I used the second option. Instead of using an item hidden, I used a text field you can see the selected values. Here are the changes I made:

    1. Add a new region and an article about her, I called my article "P33_SELECTED_WIDGETS".
    2. in the declarations of global variables in your definition of the page, add the following text:

        var pkArray = [];
    

    3. change the report query to refer to the element on the page and ensure that the State of the check box reflects the values that you have seaved in your page element.

    select
        SEQ,
        APEX_ITEM.CHECKBOX2(
          2,
          SEQ,
          'class="pk-selector" ' || SEQ_CHECK
        ) SEQ_CHECK,
        NAME,
        READY_DATE,
        COMMENTS
      from(
          select
              SEQ,
              case
                 when instr(':' || :P33_SELECTED_WIDGETS || ':',
                            ':' || SEQ || ':') > 0 then
                     'checked="checked"'
                 else ''
              end SEQ_CHECK,
              NAME,
              READY_DATE,
              COMMENTS
            from widgets_broken
    )
    

    4. create a dynamic action to manage the persistence the checked values.

    * Name: * bind_click_handler
    * Event: * after refresh
    * Type selection *: region
    * Region: *
    Real actions:
    * Seq *: 10
    * Fire on Page Load *: Yes
    * Execute JavaScript Code *:

    $('.pk-selector').bind('click',function(){
      $this = $(this);
      var checkVal = $this.val();
    
      if($this.prop("checked")){
        pkArray.push(checkVal); //save checked value
      }else{
        pkArray.splice( $.inArray(checkVal, pkArray), 1 ); //remove unchecked value
      }
      $s('P33_SELECTED_WIDGETS',pkArray.join(':')); //update page item with new values
    });
    

    Edit
    I left a decisive step. In your background report, ensure that this partial page refresh is enabled and P33_SELECTED_WIDGETS builds page elements to present the attribute.

    Finally, change the proceudure files add to refer to the page instead of globl table element.

    BEGIN
    
        insert into widgets(NAME,READY_DATE,COMMENTS)
        select name, ready_date, comments
          from widgets_broken
         where instr(':' || :P33_SELECTED_WIDGETS || ':', ':' || SEQ || ':') > 0;
    
        delete from widgets_broken
          where instr(':' || :P33_SELECTED_WIDGETS || ':', ':' || SEQ || ':') > 0;
    
        :P33_REC_CNT := SQL%ROWCOUNT;
    END;
    

    See you soon,.
    Janet Tyson

    Published by: Tyson Janet January 3, 2012 13:13

  • Hyperion Financial Reporting: Recover data from several lines of another grid

    Hey geniuses,.

    Don't know if this is the right place to ask questions on HFR...

    I have two grids: welcome and support. I tried to recover data supporting the grid, where there are 10 children report derived from a line of HFR lines. I intended to show all children of 10 lines in the report. I tried ".row grid [X] [X]" to recover data and < < MemberName > > to retrieve the name of the project, but only one line is presented in the main with the first name of line project (grid support) and report data sum of the total 10 rows (grid support).

    All good ideas?

    Thanks to a bouquet.

    Instead of the formula line insert a line of text and add the function

    >
    >
    >
    .....................................................

    The problem should be solved

    Concerning

    Celvin

    http://www.orahyplabs.com

  • Several lines to a format of columns from two tables

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production

    The difficulty to return several lines simple lines/columns in two tables.

    Table 1:

    ID BOOK_NBR
    1 1001
    1 2001
    2 1010
    3 1020

    Table 2:

    AUTHOR BOOK_NBR
    1001 JOHN_1
    2001 JOHN_2
    MARY 1010
    1020 JUNE


    Desired output:

    ID BOOK_NBR AUTHOR BOOK_NBR AUTHOR
    1 1001 JOHN_1 2001 JOHN_2
    2 MARY 1010
    3-1020 JUNE


    There are an unknown number of BOOK_NBR to one ID.

    Any guidance would be appreciated.
  • View the information from the related table instead of the ID in several line datablock

    Hello

    I searched on the web, the forum and the documentation, but I have not found a solution to this problem:

    I have two tabs with a relationship of the master / detail of one-to-many. Block detail data shows several lines such that it can be several associations table of mater in the details and I want to display the description of the master data block instead of the field with the ID for each line in the block of retail.

    I tried to place an item with the option 'copy value', but then I lose the relationship of master / detail, because that is what forms wih the field id for linking blocks.

    Also, I've seen in other posts that I can use a view, but I can't understand how would I update or remove data then.

    The only thing that I realized is to the description field in its own datablock in the same tab, a relationship master / detail-detail (or master-detail-master). BTW, I don't think it's beautiful "formulas"programming"and it does too much for my needs."

    I guess it must be a trivial thing, but I don't know what to try next. Thanks in advance!

    Published by: user10278211 on Sep 17, 2008 20:13

    AAH, I think now I got your management!

    You have 1 Deptno and dname "XYZ" in the master and you want to display:

    EmpNo Ename DName
    1     User1 XYZ
    2     User2 XYZ
    

    -What?

    If so:

    1 create a new element in the retail block, let's call it DSP_DNAME, set database property to point to 'no '.
    2. create a POST-QUERY-Trigger on detail-block with the code: DETAILBLOCKNAME. DSP_DNAME: =: MASTERBLOCKNAME. DNAME;
    3. create WHEN-CREATE-RECORD-Trigger with the same code.

    That's all

  • Update Field1.Table1 based on a compound join between Table1 and Table2

    Hello

    I want to run the update on Oracle 11 g, but it fails with the following error:

    SQL error: ORA-01427: einreihig subquery returns multiple rows
    01427 00000 - "einreihig subquery returns several lines.

    Here's what I'm trying to do in pseudo-code:

    Update Table1
    Set Flag_Column = 1
    Where
    Table1.ColumnX = table2. ColumnX
    and
    Table1.ColumnY = table2. ColumunY

    Is there a way to do this in SQL?

    Try1 *.
    Update Table1
    Set Flag_Column = 1
    where ColumnX =
    select (separate Table1.ColumnX
    from Table1, Table2
    where Table1.ColumnX = Table2.ColumnX
    and Table1.ColumnY = Table2.ColumnY)
    and ColumnY =
    select (separate Table1.ColumnY
    from Table1, Table2
    where Table1.ColumnX = Table2.ColumnX
    and Table1.ColumnY = Table2.ColumnY)

    Try2 *.
    Update Table1
    Set Flag_Column =
    (select 1
    from Table1, Table2
    where Table1.ColumnX = Table2.ColumnX
    and Table1.ColumnY = Table2.ColumnY)


    Any help is appreciated

    Published by: 977424 on March 8, 2013 12:13

    Hello

    Maybe:

    UPDATE     table1     t1
    SET     flag_column     = 1
    WHERE     EXISTS (
                    SELECT  1
                 FROM        table2
                 WHERE   columnX     = t1.columnX
                 AND        columnY     = t1.columnY
                )
    ;
    

    Depending on your needs, the MERGER could be better than the UPDATE.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
    Explain, using specific examples, how you get these results from these data.
    See the FAQ forum {message identifier: = 9360002}

  • Difference of dates with conditions and several lines

    Hello, I need to make a difference in the dates (seconds) from several lines of the eve of string comparison. FEA
    CREATE TABLE     evtmsg
    (       evt_date             DATE,
         message          VARCHAR2 (50)
    );
     
    INSERT INTO evtmsg (evt_date, message) VALUES (TO_DATE ('22/09/2010 8:39:05', 'DD/MM/YYYY HH24:MI:SS'), 'UTR 02MCD-1 fail');
    INSERT INTO evtmsg (evt_date, message) VALUES (TO_DATE ('22/09/2010 8:39:05', 'DD/MM/YYYY HH24:MI:SS'), 'UTR 02MAD-1 return');
    INSERT INTO evtmsg (evt_date, message) VALUES (TO_DATE ('22/09/2010 8:39:05', 'DD/MM/YYYY HH24:MI:SS'), 'UTR 02MCD-1 return');
    INSERT INTO evtmsg (evt_date, message) VALUES (TO_DATE ('22/09/2010 8:38:50', 'DD/MM/YYYY HH24:MI:SS'), 'UTR 02ZPD-1 fail');
    INSERT INTO evtmsg (evt_date, message) VALUES (TO_DATE ('22/09/2010 8:38:50', 'DD/MM/YYYY HH24:MI:SS'), 'UTR 02MAD-1 fail');
    INSERT INTO evtmsg (evt_date, message) VALUES (TO_DATE ('22/09/2010 8:38:38', 'DD/MM/YYYY HH24:MI:SS'), 'UTR 02MCD-1 fail');
    INSERT INTO evtmsg (evt_date, message) VALUES (TO_DATE ('22/09/2010 5:40:36', 'DD/MM/YYYY HH24:MI:SS'), 'UTR 02MCD-1 return');
    INSERT INTO evtmsg (evt_date, message) VALUES (TO_DATE ('22/09/2010 5:40:22', 'DD/MM/YYYY HH24:MI:SS'), 'UTR 02MCD-1 fail');
    "I need to complete the following table with time for each difference '"UTR 02XXXXXX"between the failure and return substr (message, 1, 11) I think * UTR 02MCD-1 *.

    {code}
    CREATE TABLE test
    (DATE date1,
    date2 DATE,
    VARCHAR2 (50) MSG
    );
    {code}

    And accurate data, that I need to get and to insert in the test tables are as follows:
    {code}
    2010-09-22 05:40:22-2010-09-21 05:40:36 UTR 02MCD-1 time of failure = 14 seconds
    22/09/2010 08:38:38-21/09/2010 08:39:05 UTR 02MCD-1 time of failure = 27 seconds
    22/09/2010 08:38:50-2010-09-21 08:39:05 UTR 02MAD-1 hour of default = 15 seconds
    22/09/2010 08:38:50 - UTR 02ZPD-1 time of failure =
    22/09/2010 08:39:05 - UTR 02MCD-1 time of failure =

    {code}

    I'll do this task every morning for the eve and UTR returns always but sometimes for the next day (not usually, but sometimes it happens). I managed to do something like that, but I don't know how to do for multiple lines and get you substr UTR 02XXXXX for each of them.

    {code}
    DECLARE
    date of the value of start_time;
    date of finish_time;
    elapsed_time number (20);

    BEGIN

    Select evt_date
    in start_time
    of evtmsg
    "where message like ' % UTR % MAD % % of failure."

    Select evt_date
    in finish_time
    of evtmsg
    where message like ' % UTR % MAD % % return ';

    elapsed_time: = (finish_time - start_time) * 24 * 60 * 60;
    dbms_output.put_line (elapsed_time);
    END;
    {code}

    If I can replace MAD MCD I get several lines and does not work.

    Thank you.

    All you have to do is shared in the first select statement into its separate elements:

    SELECT   evt_date_fail
             evt_date_return,
             id,
             TO_CHAR(TO_CHAR(evt_date_return, 'SSSSS') - TO_CHAR(evt_date_fail, 'SSSSS') seconds
    FROM    (SELECT evt_date evt_date_fail,
                    LEAD(evt_date) OVER (partition by id ORDER BY id||TO_CHAR(evt_date, 'yyyymmddhh24miss')||CASE status WHEN 'return' THEN 1 ELSE 2 END) evt_date_return,
                    id,
                    status
             FROM  (SELECT evt_date,
                           SUBSTR(message, 1, 11) id,
                           SUBSTR(message, 13) status
                    FROM   evtmsg
                    WHERE  message LIKE 'UTR%'
                    AND    categ = 1
                    AND    TRUNC(evt_date) = TRUNC(SYSDATE - 1)))
    WHERE    status like '%fall%'
    ORDER BY evt_date_fail
    

    Also, you may need to change the CASE statement in the column that uses the LEAD function to replace the 'return' with its Spanish equivalent

Maybe you are looking for

EditEditCopyCopyDeleteDelete4005Leaseinfo2100003007002014 01-02
EditCopycopyDeleteDelete4006Leaseinfo250001503502014 01-02