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;

Tags: Database

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?

  • How to use the checkbox to select several lines of af: table

    Hi all
    I want to use the checkbox to select several lines of af: table

    Kind regards
    Tom

    Hello

    look at this link
    http://Sameh-Nassar.blogspot.com/2009/12/use-checkbox-for-selecting-multiple.html

    Kind regards
    Felix

  • 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

  • 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                        
    
  • Remove the statement with a subquery

    Hi Experts,
    I currently have a select query with subquerys, I want to turn it into a deletion request.
    select cy.lmp, cy.dt from 
    
    (SELECT LMP, CHANGE_SD, ADD_MONTHS(DT,12) AS DT 
    FROM FORECAST WHERE EVENT = 'GROWTH RATE') ny --next year,
    
    (SELECT LMP, CHANGE_SD,  DT 
    FROM FORECAST WHERE EVENT = 'GROWTH RATE') cy -- current year
    
    where ny.change_sd = cy.change_sd and ny.dt = cy.dt and ny.lmp = cy.lmp
    order by cy.lmp;
    Here, I want to delete rows from the table the forecasts which are the result of the select query above.

    Your help is appreciated.

    Hello

    Will there be matching columns in the forecast table?
    If so, you can do this:

    DELETE  forecast
    WHERE   (column_a, column_b) IN
    (SELECT  cy.lmp,   cy.dt
     FROM    ...     -- rest of query (except ORDER BY clause) goes here
    );
    
  • Update with the Lead feature and several lines

    I have a table such as:

    Table1:

    OrderNumber EFFECTIVE_DATE EFFECTIVE_END_DATE FileName

    123 11/5/2015-12/31/2099 File5.txt

    123, 7/11/2015-12/31/2099 File7.txt

    or it can look like:

    Table2

    OrderNumber EFFECTIVE_DATE EFFECTIVE_END_DATE FileName

    123 11/5/2015-11/7/2015 File5.txt

    123, 7/11/2015-11/9/2015 File7.txt

    123 11/9/2015-12/31/2099 File9.txt

    123 11/15/2015-12/31/2099 File15.txt

    I want to take the 2nd to the last EndDate and update with the previous value.

    So in fact, it would look like this.

    Table1:

    OrderNumber EFFECTIVE_DATE EFFECTIVE_END_DATE FileName

    123 11/5/2015-11/7/2015 File5.txt

    123, 7/11/2015-12/31/2099 File7.txt

    or

    Table2

    OrderNumber EFFECTIVE_DATE EndDate FileName

    123 11/5/2015-11/7/2015 File5.txt

    123, 7/11/2015-11/9/2015 File7.txt

    123-11/9/11/15 to 2015/2015 File9.txt

    123 11/15/2015-12/31/2099 File15.txt

    I got it work in a select statement to a single value. now I just need help it enter an UPDATE statement and update all records.

    SELECT W.EFFECTIVE_DATE, W.EFFECTIVE_END_DATE,

    NVL (LEAD (W.EFFECTIVE_DATE, 1) (ORDER implementation W.EFFECTIVE_DATE), December 31, 99 ') AS 'EFFECTIVE_DATE_NEW '.

    OF WH_ORDERS_REPORT W

    WHERE ORDERNUMBER = '10460992';

    It did not work:

    UPDATE WH_ORDERS_REPORT WH

    SET EFFECTIVE_END_DATE = (SELECT NVL (LEAD (WH2. EFFECTIVE_DATE, 1) (ORDER of WH2. (EFFECTIVE_DATE), DECEMBER 31, 99 ')

    OF WH_ORDERS_REPORT WH2

    WHERE WH. ORDERNUMBER = WH2. ORDERNUMBER)

    I appreciate your help in the creation of an update statement to do this.

    Rap, but it's working now.  I'll confirm with a few other records before I mark as correct, but what I see so far, it is beautiful, thank you!

    merge into WH_LIFELINE_ORDERS_REPORT D

    a_l'_aide_de)

    Select

    DISTINCT ORDERNUMBER,

    CURRENTSTATUSDATETIME,

    NVL (LEAD(EFFECTIVE_DATE, 1) ON (ORDERNUMBER partition

    (EFFECTIVE_DATE order), December 31, 99 ') as EFFECTIVE_END_DATE

    of WH_LIFELINE_ORDERS_REPORT

    ) S

    WE (D.ORDERNUMBER = S.ORDERNUMBER

    AND D.CURRENTSTATUSDATETIME = S.CURRENTSTATUSDATETIME

    )

    When matched then

    setting a day of set D.EFFECTIVE_END_DATE = S.EFFECTIVE_END_DATE;

  • Update statement with a subquery

    Hello gurus,

    I am having trouble with an Update query.  Basically, I want to just update some documents in my DB Oracle (version 11.2.0.2) according to certain criteria in my WHERE clause.  That's what I have below.

    Select count (*)

    From Table_1 a, b Table_2

    Where a.unique_id = b.unique_id and b.Doc_Type = 'AP' and a.Doc_Title is null;  < == returns 540 records

    Update Table_1

    Define Doc_Title = 'data '.

    Where Doc_Title = (select a.Doc_Title

    from Table_1 a, b Table_2

    where a.unique_id = b.unique_id and b.Doc_Type = 'AP' and a.Doc_Title is null

    A.Doc_Title group);  < == lines updates 0 (I expect it, updated the 540 chronogram my query earlier than I used to check)

    Any ideas?  Thank you!

    Update Table_1 one

    Define Doc_Title = 'data '.

    When there is)

    Select 1

    in Table_2 b

    where a.unique_id = b.unique_id

    and b.Doc_Type = 'AP '.

    and a.Doc_Title is null

    )

    /

    SY.

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

  • 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

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

  • Separate the phone numbers on several lines

    Hello

    I have a list of phone numbers in a single column. Some cells have 1 phone number, some have 2, and some have 0. Cells with 2 phone numbers are separated by semicolons.

    I need all the phone numbers in a single column with 1 phone number in each row. The order does not matter, so I'll "Sort Ascending" once completed to get rid of the empty cells with no phone number.

    I need a function that takes the numbers after the comma and puts them on their own line in the same column.

    Note that the numbers are in the format: + 1-xxx-xxx-xxxx so if please be aware formatting as text and not as a mathematical equation.

    Thank you in advance.

    Hi B,

    Easy enough, as long as all entries are accurate according to the format you described. Here are two examples, all tous deux two on the same table. The selected cells are part of the first example and are not used in the second.

    End of flag: The two examples use the flag to end on the A11 to indicate when the formulas have reached the end of the list. As entered flag consists of eight occurrences of the text "end" (including the trailing space), with the final space deleted. This will be assimilated by the formula two phone numbers, provide an indicator of the end of each list.


    Example 1:

    Separates the first phone number in column B using this formula in B2, filled up to the last line containing a phone number in column A (or the line beyond if you want that the flag of the 'end').

    B2: = IF (LEN (A) < 1", LEFT(A,15))

    Len (A) checks no entry in its ranks. If that is found, IF put a string NULL. If there is an entry, LEFT out the first 15 characters.

    The second n phone number each line is copied into column C with this similar formula in C2 and filled up to the last line containing an entry in column A.

    C2: is equal to IF (LEN (A) < 16", RIGHT(A,15))

    If there are two numbers in this line from A cell, the semi colon will be the 16th character.

    After having extracted the numbers in two columns:

    Select all the cells in column B of B2 on the last containing a B10 number in this example). Copy.

    Go menu Edition > paste formula results

    Select all the cells in column C of C2 on the last containing a number C10). Copy.

    Click once on the empty cell in column B, following the list of the "first numbers" (B11 in this example).

    Go to edit > paste the results of the formulas.

    You can now sort the table according to the values (telephone numbers) in column B.

    Example 2:

    Separates the first phone number in column B using this formula in B2, filled up to the last line containing a phone number in column A (or the line beyond if you want that the flag of the 'end').

    B2: = IF (LEN (A) < 1", LEFT(A,15))

    Len (A) checks no entry in its ranks. If that is found, IF put a string NULL. If there is an entry, LEFT out the first 15 characters.

    The second phone number n that each line is copied into column B, starting after the cell containing the flag of the 'end '.

    Enter the following formula in the marketing of cells (B12 in the example) and fill down until the formula produces another flag to end.

    B12: = IF (LEN (A2) < 16", RIGHT(A2,15))

    Note that because this version of the formula is not on the same line as the EMF of the cell that is copied the phone number, it must the line included in the references.

    When the terminator is reached:

    Click on each of the cells that contain the end flags, and then press DELETE to remove the flags from the list.

    Select all THE cells B2 at the end of the list of telephone numbers. Copy.

    Go menu Edition > paste formula results

    With replaced by their latest results calculated formulas, you can now sort the table on column B.

    Kind regards

    Barry

  • calculate the time difference between several lines

    Hello

    I have a table as below:

    create table select TEST_CASETBL (ID, CASE_NUM, CASE_STATUS, CASE_SUB_STATUS, LAST_UPD_DTTM)

    112, 123-456', 'open', 'Work', TO_DATE (11 March 2015 13:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    113, 123-456', 'Open', 'pending on the admin', TO_DATE (10 January 2015 15:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    114, 123-456', 'Open', 'client expectation', TO_DATE (10 July 2015 09:00 ',' hh24:mi:ss' of dd/mm/yyyy) of the DUAL union all select them

    315, 123-456', 'open', 'Work', TO_DATE (September 15, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    219, 123-456', 'Open', 'pending on the admin', TO_DATE (January 9, 2015 08:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    651, 123-456', 'open', 'Work', TO_DATE (August 20, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') from DUAL;

    I would like to calculate the duration total (days ideally) to CASE_SUB_STATUS, so have a set of lines:

    CASE_NUM of work waiting on admin waiting on customer

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

    123-456 70days 6 hours

    Here is the explanation of the pattern:

    ex: for everyday business computing (timestamp timestamp of ID:651 - ID:219) +(timestamp of ID:315-timestamp of ID:114) + (ID:112 stamp - current_time) = 11 days + 21 days 22hrs 23hrs 36 days 9 hours

    still waiting on admin

    (ID:219 timestamp - timestamp of ID:315) + (ID:113 timestamp - timestamp of ID:112)

    still waiting on the client

    (ID:114 timestamp - timestamp of ID:113)

    I would appreciate any idea how to solve this, ideally as an SQL

    Thank you

    Should he not?...

    with test_casetbl (id, case_num, case_status, case_sub_status, last_upd_dttm) as)

    Select 112, 123-456', 'Open', 'Work', TO_DATE (11 March 2015 13:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 113, 123-456', 'Open', 'pending on the admin', TO_DATE (10 January 2015 15:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 114, 123-456', 'Open', 'client expectation', TO_DATE (10 July 2015 09:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 315, 123-456', 'Open', 'Work', TO_DATE (September 15, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 219, 123-456', 'Open', 'pending on the admin', TO_DATE (January 9, 2015 08:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 651, 123-456', 'Open', 'Work', TO_DATE (August 20, 2015 10:00 ',' the hh24: mi: ss' dd/mm/yyyy) double

    ),

    t like)

    Select case_num,

    case_sub_status,

    (last_upd_dttm, 1, sysdate) ahead of diff last_upd_dttm (partition by order of last_upd_dttm case_num).

    of test_casetbl

    )

    Select case_num,

    trunc (a) | "day (s). TO_CHAR (date ' 1-1-1' + a, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") "work."

    trunc (b) | "day (s). TO_CHAR (day 1-1-1' + b, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") 'Waiting on admin',

    trunc (c) | "day (s). TO_CHAR (day 1-1-1' + c, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") "waiting on customer."

    t

    pivot)

    Sum (diff)

    for case_sub_status in)

    'Work' is.

    B "waiting on admin',

    C "customer expectation."

    )

    )

  • EditEditCopyCopyDeleteDelete4005Leaseinfo2100003007002014 01-02
    EditCopycopyDeleteDelete4006Leaseinfo250001503502014 01-02
    CASE_NUM Working Waiting on admin Waiting on customer
    123-456 63 day (s) 22 hour (s) (s) 50 minute 49 second (s) 19 day (s) on 20 (s) hour 0 minute 0 second (s) 27 day (s) on 4 hour (s) 0 minute 0 second (s)
  • How to use the checkbox to update several lines

    Hi all

    I'm new to apex and I have a problem now. I find this code somewhere:

    BEGIN

    FOR I IN 1... APEX_APPLICATION. G_F01. COUNTING LOOP

    REMOVE FROM THE ASER

    WHERE ID = TO_NUMBER (APEX_APPLICATION. G_F01 (I));

    END LOOP;

    END;

    It can remove selected items, now I want to make some modifications to it.

    I want to update some columns when I ticked the box. How to make this change? I mean, like this:

    UPDATE ASER SET STATUS = '1' when I selected items

    Can you help me? Thank you!

    Hello

    I don't know exactly what you want to do, but if I am guessing right then of course you want updated also based on the elements of the selected check box.

    
    BEGIN
     FOR I IN 1 .. APEX_APPLICATION.G_F01.COUNT LOOP
    
       DELETE FROM ASER
      WHERE ID=TO_NUMBER(APEX_APPLICATION.G_F01(I)) ;
    UPDATE APSER
    SET STATUS = 1
    WHERE ID=TO_NUMBER(APEX_APPLICATION.G_F01(I)) ;
       END LOOP;
    
      END;
    

    But if not and you try rather to use these values to update another table after Session State is the way to go.

    Kind regards

    Benjamin.

  • Split the cell enclosed in several lines using REGEXP_SUBSTR - Performance?

    Hello

    I have a table that has about 20,000 lines. There is a column called key word which has values like below:

    File_id Keyword
    1SMITH; ALLEN; WARD; JONES; BRADY
    2S & P500; TOPIX
    3SMALL; LARGE; MEDIUM

    I want to display the data like this:

    File_id KEYWORD
    1SMITH
    1ALLEN
    1WARD
    1BRADY
    2S & P500
    2TOPIX
    etc.

    I use this application and it works:

    SELECT STG. FILE_ID, REGEXP_SUBSTR (STG. KEYWORD ' [^;] +', 1, LEVEL) AS A KEYWORD OF STG STG_TABLE

    CONNECT REGEXP_SUBSTR (STG. KEYWORD ' [^;] +', 1, LEVEL) IS NOT NULL

    But its so slow its unusable.

    Is there a faster way to return this output?

    Other info:

    KEY Word is varchar2 (4000), but rarely more than 100 bytes are used

    Oracle 11g 2

    Thank you!

    Wrong approach, there are too many lines that are generated

    Apart from replacing regexp with substr/instr, try the first slot

    SELECT

    STG. FILE_ID

    REGEXP_SUBSTR (STG. KEYWORD ' [^;] +', 1, LEVEL) AS KEYWORD

    OF STG STG_TABLE

    CONNECT

    level<= regexp_count(stg.keyword,';')="" +="">

    and prior STG. FILE_ID = STG. FILE_ID

    and prior sys_guid() is not null

Maybe you are looking for

  • How can I make the add-on from the norton toolbar appear in the list of Add-ons?

    Try to get norton toolbar visible id. It is present and active in the list of modules; but I does not appear in the list of toolbars. Therefore, it cannot make it visible on the screen.

  • iMac - 10.11.4 - Bluetooth problem

    Hello I have 27 "iMac end of 2015 and it used to work great, but last month after put 10.11.4 at level, bluetooth does not work. I need to connect the cable to the keyboard on the first that I need to force restart of the keyboard and bluetooth back

  • How do I know the laptop model and my product number

    I want to know a shortcut to find the model of my laptop of HP, knowing that the laptop is not written by any number of model and product specific on the background data, and there is only one word «Pavilion dv6» Please do not delay in this response,

  • There FCPX effects like photo booth to deform the faces?

    Hi, I have filmed a scene soon and want to have 2 faces peoples tripling resembling effects of Photo Booth, but I would need to add effects in FCPX. Does anyone know any available effect? Or is there a way to manage my images by photo booth or someth

  • Info - change album version

    Hello I am running the latest version of iTunes for Windows and run worm Windows 10 1511. I ripped a CD and iTunes uses the order of songs for the international version of it, not the Australian version which is what I have. How to import the correct