Delete records from tableA which are not in tableB

Table A contains milions of records which is the best way to delete records from tableA which are not in tableB
delete from tableA where empno not in (select empno from tableb)
or
delete from tableA where empno not exists (select empno from tableb
where b.empno=a.empno)
any help

Hi
If you can do this, do with this:
create table tableC
as select a.*
from tableA a,
(select empno from tableA
minus
select empno from tableB) b
where a.empno = b.empno;
drop table tableA;
rename table tableC to tableA;
Ott Karesz
http://www.trendo-kft.hu

Similar Messages

  • Delete Rows from T1 which are Not in T2

    Hi
    I've 2 Tables like below
    T1
    N1
    N2
    2
    11
    2
    22
    3
    33
    8
    44
    8
    88
    T2
    N1
    N2
    2
    22
    8
    88
    If I Run Delete query, I must delete Rows from T1 which are Not in T2
    For example, I must delete Rows 1,3,4 from T1
    So how to write that delete query? Please advice

    Delete from T1
    Where not Exists (select * from T2 Where t1.N1=t2.N1 and t1.N2=t2.N2)
    --or
    Delete t
    From t1 t
    left JOIN t2 m
    ON m.N1=t.N1 and m.N2=t.N2
    WHERE m.N1 is null and m.N2 is null
    --Or
    ;With mycte as
    select N1,N2 from T1
    Except
    select N1,N2 from T2
    Delete t
    From t1 t
    INNER JOIN mycte m
    ON m.N1=t.N1 and m.N2=t.N2

  • How to delete images from folder which are not in the database

    I am created windows form
    i wont to delete images from the folder where i have stored images but i only want to delete those images which are not in the data base.
    i don't know how it is possible . i have written some code
    private void button1_Click(object sender, EventArgs e)
    string connectionString = "Data Source";
    conn = new SqlConnection(connectionString);
    DataTable dt = new DataTable();
    cmd.Connection = conn;
    cmd.CommandText = "select * from tbl_pro";
    conn.Open();
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    da.Fill(dt);
    int count = Convert.ToInt32( dt.Rows.Count);
    string[] image1 = new string[count];
    for (int i = 0; i < count; i++)
    image1[i] = dt.Rows[i]["Image1"].ToString();
    string[] image2 = new string[count];
    for (int i = 0; i < count; i++)
    image2[i] = dt.Rows[i]["Image2"].ToString();
    var arr = image1.Union(image2).ToArray();
    string[] arrays;
    String dirPath = "G:\\Proj\\";
    arrays = Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories).Select(x => Path.GetFileName(x)).ToArray();
    int b= arrays.Count();
    for (int j = 1; j <= b; j++)
    if (arrays[j].ToString() != arr[j].ToString())
    var del = arrays[j].ToString();
    else
    foreach (var value in del) // ERROR DEL IS NOT IN THE CURRENT CONTEXT
    string filePath = "G:\\Projects\\Images\\"+value;
    File.Delete(filePath);
    here error coming "DEL IS NOT IN THE CURRENT CONTEXT"
    I have to change anything .Will It work alright?
    pls help me
    Sms

    Hi Fresherss,
    Your del is Local Variable, it can't be accessed out of the if statement. you need to declare it as global variable like below. And if you want to collect the string, you could use the List to collect, not a string.  the string will be split to chars
    one by one.
    List<string> del=new List<string>();
    for (int j = 1; j <= b; j++)
    if (arrays[j].ToString() != arr[j].ToString())
    del.Add(arrays[j].ToString());
    else
    foreach (var value in del)
    string filePath = "G:\\Projects\\Images\\" + value;
    File.Delete(filePath);
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Join 2 tables which are not related with any primary-foriegn key constraint

    Hello,
    How to join 2 tables which are not related with any primary key foreign key constraint.
    Ex.Consider Table A has 5 columns->A_ID,A_Name,A_Address,A_City,A_Pin(Total 10 rows)
    Table B has 5 columns->B_ID,B_Name,B_Adress,B_City,B_City(Total 30 rows)
    From both the table i want the data,which i need to use in curosr to display finally as "Address Label".
    Both the table are entirely different,but there can be some names of Table A which may come in Table B also,if the name,address and city is also same.That means same person in both the table.
    So finally i want total number of distinct records(distinct data of Table A which is not in B+all the data of table B) to come under Address Label.
    How can i write the select query for this condition?
    Thanks
    Swapna

    Hi, Swapna,
    user11018268 wrote:
    Hello,
    How to join 2 tables which are not related with any primary key foreign key constraint.
    Ex.Consider Table A has 5 columns->A_ID,A_Name,A_Address,A_City,A_Pin(Total 10 rows)
    Table B has 5 columns->B_ID,B_Name,B_Adress,B_City,B_City(Total 30 rows)
    Both the table are entirely different,but there can be some names of Table A which may come in Table B also,if the name,address and city is also same.That means same person in both the table.I think you want a UNION, not a join.
    If you have 10 rows in table_a, and 30 rows in table_b, then
    SELECT       A_ID,          A_Name,     A_Address,     A_City,     A_Pin
    FROM      table_a
    UNION
    SELECT       B_ID,          B_Name,     B_Adress,     B_City,     B_City
    FROM      table_b
    ORDER BY            2,               4          
    ;will produce up to 40 rows; 40 if there are no duplicates. (UNION implies DISTINCT.)
    The corresponding column types should be similar, if not exactly the same.
    There's no problem if A_Name is VARCHAR2 (50) and B_Name is CHAR (30).
    However, there will be a problem if A_ID is a NUMBER and B_ID is a TIMESTAMP.
    You must have the same number of columns in all branches of the UNION.
    If you want an ORDER BY clause, put it at the very end, after the last branch of the UNION.
    You can use positional notation (where 2 means the 2nd column) like I did, or you can use names from the first prong of the UNION (such as A_Name).
    From both the table i want the data,which i need to use in curosr to display finally as "Address Label".
    So finally i want total number of distinct records(distinct data of Table A which is not in B+all the data of table B) to come under Address Label.I'm not sure what your mean about "Address Label".
    Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables, and the exact results (formatted) that you want from that data.
    You can concatenate all 5 columns into one VARCHAR2 column, if you want to.
    You'll probably want to use RPAD (or simillar functions) to make the output line up nicely.
    If any of the columns are not strings, use TO_CHAR to make string versions of them.
    For example:
    SELECT  TO_CHAR (A_ID, '9999999')
         || '   '          -- leave a little space between the left-justified a_id and the right-justified a_name
         || RPAD (A_Name, 25)
         || RPAD (A_Address, 50)
         ...Edited by: Frank Kulash on Nov 14, 2009 10:11 AM

  • How do you delete records from table with data in a select option

    how do you delete records from table with relevant to data in a select option..how to write coding

    Hi,
    Try
    if not s_select_option [ ] is initial.
    delete * from table
    where field in s_select_option.
    endif.
    commit work.
    Be careful though. If select option is emty, you will delete the entire table.
    Regards,
    Arek

  • Sp_who2 -need only active sessions from users which are not the background sessions

    Hello,
    sp_who2 -need only active sessions from users which are not the background  sessions
    Please assist.
    Best regards,
    Vishal

    Its better to use DMV's to view only active sessions from users (spid>50) as mentioned by Shanky.
    You can do that using sp_who2 but it requires a bit of programming to list only user sessions.
    SELECT
    S.SESSION_ID,
    S.STATUS,
    S.HOST_NAME,
    C.CLIENT_NET_ADDRESS,
    CASE WHEN S.LOGIN_NAME = S.ORIGINAL_LOGIN_NAME THEN S.LOGIN_NAME ELSE S.LOGIN_NAME END LOGIN_NAME,
    S.PROGRAM_NAME,
    C.CONNECT_TIME,
    S.LOGIN_TIME,
    CASE S.TRANSACTION_ISOLATION_LEVEL
    WHEN 0 THEN 'UNSPECIFIED'
    WHEN 1 THEN 'READUNCOMITTED'
    WHEN 2 THEN 'READCOMMITTED'
    WHEN 3 THEN 'REPEATABLE'
    WHEN 4 THEN 'SERIALIZABLE'
    WHEN 5 THEN 'SNAPSHOT'
    ELSE CAST(S.TRANSACTION_ISOLATION_LEVEL AS VARCHAR(32))
    END AS TRANSACTION_ISOLATION_LEVEL_NAME,
    S.LAST_SUCCESSFUL_LOGON,
    S.LAST_UNSUCCESSFUL_LOGON,
    S.UNSUCCESSFUL_LOGONS,
    S.CPU_TIME AS CPU_TIME_MS,
    S.MEMORY_USAGE AS MEMORY_USAGE_PAGES,
    S.ROW_COUNT,
    S.PREV_ERROR,
    S.LAST_REQUEST_START_TIME,
    S.LAST_REQUEST_END_TIME,
    C.NET_TRANSPORT,
    C.PROTOCOL_TYPE,
    S.LANGUAGE,
    S.DATE_FORMAT,
    ST.TEXT AS QUERY_TEXT
    FROM
    SYS.DM_EXEC_SESSIONS S
    FULL OUTER JOIN SYS.DM_EXEC_CONNECTIONS C ON C.SESSION_ID = S.SESSION_ID
    CROSS APPLY SYS.DM_EXEC_SQL_TEXT(C.MOST_RECENT_SQL_HANDLE) ST
    WHERE
    S.SESSION_ID IS NULL
    OR S.SESSION_ID > 50
    ORDER BY
    S.SESSION_ID
    -Prashanth

  • While deleting project from CJ20N entries are not deleted from table PRPS

    Hi,
    I am deleting project from CJ20N then from PROJ table entries are getting deleted but WBS element entries are not deleted from table PRPS.
    Any deletion Flag should also be checked?
    Thanks in advance!
    Regards,
    Jyoti

    Hello,
    Thanks for reply !
    My problem is I am deleting project and WBS Elements from CJ20N but WBS element entries are not deleted from PRPS table.
    Why they are appearing in PRPS table and how it can be deleted?
    Thanks !

  • Deleting records from table MVER

    We are experiencing performance issues when adding data to table MVER.  We have data on there that is over 5 years old which could be deleted.  As we have not been able to find any standard program or process that carries out housekeeping on MVER we are considering writing an ABAP program to delete the records.   Has anyone had any problems when deleting records from MVER or does anyone know of any reason why we should not delete these records in this way ?

    Well, I wouldn't delet data from a standard SAP table based on information from the internete. I'd look at other alternatives.
    Are you maintaining custom indexes on this table?
    Are your database statistics up to date?
    Consider a databse re-org.
    I don't think simple inserts should cause a problem.
    Rob

  • RFC fetching data from table which is not commited

    Hi Experts,
                   I have a query regarding commit work.Below is the RFC that i have written
    FUNCTION ZBAPI_CREATE.
    *"*"Local Interface:
    *"  TABLES
    *"      IT_ZABAP_RFC STRUCTURE  ZBAPI_RFC_STR OPTIONAL
    *"      RETURN STRUCTURE  BAPIRET2 OPTIONAL
    CALL FUNCTION 'ZBO_BAPI_CREATE'
    TABLES
       IT_ZABAP_RFC       = IT_ZABAP_RFC
       RETURN             = return
    Break-point.
    DATA lt TYPE TABLE OF ZBAPI_RFC_STR_MAIN.
    CALL FUNCTION 'ZBAPI_SEARCH_RANGE'
    * EXPORTING
    *   IS_STR        =
    TABLES
       ET_TAB        = lt
    *   RETURN        =
    ENDFUNCTION.
    here in first RFC call i am creating a record in ZTABLE , and then at break-point
    i check the ZTABLE where it does not create any record because data is not commited into ZTABLE upto this point, but just after it i have written code for fetching data from ZTABLE but i am able to get this new record in lt.
    Can anybody please explain that from where this serach RFC is providing data because inside serach i am simply selecting data from ZTABLE.
    Regards,
    Abhishek Bajpai
    Edited by: ABHISHEK BAJPAI on Jan 28, 2009 1:12 PM

    Hi Thomas,
                     Thanks for reply , i checked in ZTABLE ,before search RFC call data is not there but if i commit explicitly only then it is showing data in ZTABLE. Actually my requirement is different -
    I have two RFCs 1. Create 2. Search , Now  from web dynpro user will call first Create RFCs but at this point it should not insert record in ZTABLE and just after it user will call another search RFC and in this search he should be able to get these newly created records.
    I want to have the functionality which a user gets when working with normal database front end like SQLPLus for Oracle. In these scenarios we see that whenever user does any insert or update the data sits in the table but still it is not committed. So there he fires Select query he sees the inserted data. But if he logs off from SQL PLUS and then logs in again, and fires Select query he does not see the data as it was not committed. I want a similiar functionalty in which if user inserts the data through Create RFC and fires the Select query through Search RFC then he can see the newly Created data also even though this data is not committed.
    Although if i call create RFC in update task it will not update ZTABLE but in this situation , if user will call search RFC he will not be able to get newly created records.
    So my requirement is that i should be able to get those records which are not commited in ZTABLE .If you have still any doubt regarding my question then please let me know.
    Regards,
    Abhishek

  • Open HUB ( SAP BW ) to SAP HANA through DB Connection data loading , Delete data from table option is not working Please help any one from this forum

    Issue:
    I have SAP BW system and SAP HANA System
    SAP BW to SAP HANA connecting through a DB Connection (named HANA)
    Whenever I created any Open Hub as Destination like DB Table with the help of DB Connection, table will be created at HANA Schema level ( L_F50800_D )
    Executed the Open Hub service without checking DELETING Data from table option
    Data loaded with 16 Records from BW to HANA same
    Second time again executed from BW to HANA now 32 records came ( it is going to append )
    Executed the Open Hub service with checking DELETING Data from table option
    Now am getting short Dump DBIF_RSQL_TABLE_KNOWN getting
    If checking in SAP BW system tio SAP BW system it is working fine ..
    will this option supports through DB Connection or not ?
    Please follow the attachemnet along with this discussion and help me to resolve how ?
    From
    Santhosh Kumar

    Hi Ramanjaneyulu ,
    First of all thanks for the reply ,
    Here the issue is At OH level ( Definition Level - DESTINATION TAB and FIELD DEFINITION )
    in that there is check box i have selected already that is what my issue even though selected also
    not performing the deletion from target level .
    SAP BW - to SAP HANA via DBC connection
    1. first time from BW suppose 16 records - Dtp Executed -loaded up to HANA - 16 same
    2. second time again executed from BW - now hana side appaended means 16+16 = 32
    3. so that i used to select the check box at OH level like Deleting data from table
    4. Now excuted the DTP it throws an Short Dump - DBIF_RSQL_TABLE_KNOWN
    Now please tell me how to resolve this ? will this option is applicable for HANA mean to say like , deleting data from table option ...
    Thanks
    Santhosh Kumar

  • Identify tables which are not used in any access seq.

    Hi
    Need to identify those tables (A500 - A999) which are NOT used in any access sequence (table T682I).
    Not sure how to do this.
    Thanks for the help

    Hi Karen,
    if you don't want to use SE11 and see it on one glance, you could use the following coding:
    DATA: it_t682i TYPE TABLE OF t682i,
          wa_t682i TYPE t682i,
          it_missing TYPE TABLE OF t682i,
          wa_count TYPE kotabnr VALUE 499.
    SELECT * FROM t682i INTO TABLE it_t682i
                  WHERE kvewe = 'A'
                  AND  kotabnr BETWEEN 500 AND 999.
    DO.
      ADD 1 TO wa_count.
      READ TABLE it_t682i INTO wa_t682i
                 WITH KEY kotabnr = wa_count.
      IF sy-subrc <> 0.
        CLEAR wa_t682i.
        MOVE wa_count TO wa_t682i-kotabnr.
        APPEND wa_t682i TO it_missing.
      ENDIF.
      IF wa_count = 999.
        EXIT.
      ENDIF.
    ENDDO.
    BREAK 'your user'.
    The table it_missing is just a quicky solution, you could use a table with just one field or use write to print the result.
    Hope that helps!
    Regards
    Nicola

  • We have the invoices in staging table which are not posting to EBIZ

    We have some invoices in RFM fm_ap_staging* tables from past month, which are not getting posted to EBIZ.
    The invoices are in FP status and the invoices should picked up and posted to EBIZ.
    We are not sure, why this was happening.
    But , when we have changed the sequence number of the invoices to the maximum sequence number and ran the batch , the invoices got picked up and posted to EBIZ.
    This doesn't make sense to me.
    Is it the correct functionality, or whatever is in the staging table evry thing should be picked up by the batch and post to EBIZ.
    Kindly verify.

    Hi Henry,
    From your description, I would like to verify the following things:
    1. If you can receive emails from ExQuilla account via OWA? If yes, the Exchange Server is ok.
    2. If other users can receive emails from ExQuilla account?
    3. When you use Outlook Anywhere, can you receive emails from Outlook client? If yes, there are some problems with the third-party software ExQuilla.
    If there are any problems with Exchange Server, please feel free to let me know.
    Best regards,
    Amy
    Amy Wang
    TechNet Community Support

  • SQL Query to fetch records from tables which have 75+ million records

    Hi,
    I have the explain plan for a sql stmt.Require your suggestions to improve this.
    PLAN_TABLE_OUTPUT
    | Id  | Operation                            | Name                         | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT                     |                              |   340 |   175K| 19075 |
    |   1 |  TEMP TABLE TRANSFORMATION           |                              |       |       |       |
    |   2 |   LOAD AS SELECT                     |                              |       |       |       |
    |   3 |    SORT GROUP BY                     |                              |    32M|  1183M|   799K|
    |   4 |     TABLE ACCESS FULL                | CLM_DETAIL_PRESTG            |   135M|  4911M|   464K|
    |   5 |   LOAD AS SELECT                     |                              |       |       |       |
    |   6 |    TABLE ACCESS FULL                 | CLM_HEADER_PRESTG            |     1 |   274 |   246K|
    PLAN_TABLE_OUTPUT
    |   7 |   LOAD AS SELECT                     |                              |       |       |       |
    |   8 |    SORT UNIQUE                       |                              |   744K|    85M|  8100 |
    |   9 |     TABLE ACCESS FULL                | DAILY_PROV_PRESTG            |   744K|    85M|  1007 |
    |  10 |   UNION-ALL                          |                              |       |       |       |
    |  11 |    SORT UNIQUE                       |                              |   177 | 97350 |  9539 |
    |  12 |     HASH JOIN                        |                              |   177 | 97350 |  9538 |
    |  13 |      HASH JOIN OUTER                 |                              |     3 |  1518 |  9533 |
    |  14 |       HASH JOIN                      |                              |     1 |   391 |  8966 |
    |  15 |        TABLE ACCESS BY INDEX ROWID   | CLM_DETAIL_PRESTG            |     1 |    27 |     3 |
    |  16 |         NESTED LOOPS                 |                              |     1 |   361 |    10 |
    |  17 |          NESTED LOOPS OUTER          |                              |     1 |   334 |     7 |
    PLAN_TABLE_OUTPUT
    |  18 |           NESTED LOOPS OUTER         |                              |     1 |   291 |     4 |
    |  19 |            VIEW                      |                              |     1 |   259 |     2 |
    |  20 |             TABLE ACCESS FULL        | SYS_TEMP_0FD9D66C9_DA2D01AD  |     1 |   269 |     2 |
    |  21 |            INDEX RANGE SCAN          | CLM_PAYMNT_CLMEXT_PRESTG_IDX |     1 |    32 |     2 |
    |  22 |           TABLE ACCESS BY INDEX ROWID| CLM_PAYMNT_CHKEXT_PRESTG     |     1 |    43 |     3 |
    |  23 |            INDEX RANGE SCAN          | CLM_PAYMNT_CHKEXT_PRESTG_IDX |     1 |       |     2 |
    |  24 |          INDEX RANGE SCAN            | CLM_DETAIL_PRESTG_IDX        |     6 |       |     2 |
    |  25 |        VIEW                          |                              |    32M|   934M|  8235 |
    |  26 |         TABLE ACCESS FULL            | SYS_TEMP_0FD9D66C8_DA2D01AD  |    32M|   934M|  8235 |
    |  27 |       VIEW                           |                              |   744K|    81M|   550 |
    |  28 |        TABLE ACCESS FULL             | SYS_TEMP_0FD9D66CA_DA2D01AD  |   744K|    81M|   550 |
    PLAN_TABLE_OUTPUT
    |  29 |      TABLE ACCESS FULL               | CCP_MBRSHP_XREF              |  5288 |   227K|     5 |
    |  30 |    SORT UNIQUE                       |                              |   163 | 82804 |  9536 |
    |  31 |     HASH JOIN                        |                              |   163 | 82804 |  9535 |
    |  32 |      HASH JOIN OUTER                 |                              |     3 |  1437 |  9530 |
    |  33 |       HASH JOIN                      |                              |     1 |   364 |  8963 |
    |  34 |        NESTED LOOPS OUTER            |                              |     1 |   334 |     7 |
    |  35 |         NESTED LOOPS OUTER           |                              |     1 |   291 |     4 |
    |  36 |          VIEW                        |                              |     1 |   259 |     2 |
    |  37 |           TABLE ACCESS FULL          | SYS_TEMP_0FD9D66C9_DA2D01AD  |     1 |   269 |     2 |
    |  38 |          INDEX RANGE SCAN            | CLM_PAYMNT_CLMEXT_PRESTG_IDX |     1 |    32 |     2 |
    |  39 |         TABLE ACCESS BY INDEX ROWID  | CLM_PAYMNT_CHKEXT_PRESTG     |     1 |    43 |     3 |
    PLAN_TABLE_OUTPUT
    |  40 |          INDEX RANGE SCAN            | CLM_PAYMNT_CHKEXT_PRESTG_IDX |     1 |       |     2 |
    |  41 |        VIEW                          |                              |    32M|   934M|  8235 |
    |  42 |         TABLE ACCESS FULL            | SYS_TEMP_0FD9D66C8_DA2D01AD  |    32M|   934M|  8235 |
    |  43 |       VIEW                           |                              |   744K|    81M|   550 |
    |  44 |        TABLE ACCESS FULL             | SYS_TEMP_0FD9D66CA_DA2D01AD  |   744K|    81M|   550 |
    |  45 |      TABLE ACCESS FULL               | CCP_MBRSHP_XREF              |  5288 |   149K|     5 |
    The CLM_DETAIL_PRESTG table has 100 million records and the CLM_HEADER_PRESTG table has 75 million records.
    Any gussestions on how to getch huge records from tables of this size will help.
    Regards,
    Narayan

    WITH CLAIM_DTL
         AS (  SELECT
                      ICN_NUM,
    MIN (FIRST_SRVC_DT) AS FIRST_SRVC_DT,
    MAX (LAST_SRVC_DT) AS LAST_SRVC_DT,
    MIN (PLC_OF_SRVC_CD) AS PLC_OF_SRVC_CD
    FROM CCP_STG.CLM_DETAIL_PRESTG  CD WHERE ACT_CD <>'D'
    GROUP BY ICN_NUM),
    CLAIM_HDR
         AS (SELECT
                    ICN_NUM,
    SBCR_ID,
    MBR_ID,
    MBR_FIRST_NAME,
    MBR_MI,
    MBR_LAST_NAME,
    MBR_BIRTH_DATE,
    GENDER_TYPE_CD,
    SBCR_RLTNSHP_TYPE_CD,
    SBCR_FIRST_NAME,
    SBCR_MI,
    SBCR_LAST_NAME,
    SBCR_ADDR_LINE_1,
    SBCR_ADDR_LINE2,
    SBCR_ADDR_CITY,
    SBCR_ADDR_STATE,
    SBCR_ZIP_CD,
    PRVDR_NUM,
    CLM_PRCSSD_DT,
    CLM_TYPE_CLASS_CD,
    AUTHO_NUM,
    TOT_BILLED_AMT,
    HCFA_DRG_TYPE_CD,
    FCLTY_ADMIT_DT,
    ADMIT_TYPE,
    DSCHRG_STATUS_CD,
    FILE_BILLING_NPI,
    CLAIM_LOCATION_CD,
    CLM_RELATED_ICN_1,
    SBCR_ID||0
    || MBR_ID
    || GENDER_TYPE_CD
    || SBCR_RLTNSHP_TYPE_CD
    || MBR_BIRTH_DATE
    AS MBR_ENROLL_ID,
    SUBSCR_INSGRP_NM ,
    CAC,
    PRVDR_PTNT_ACC_ID,
    BILL_TYPE,
      PAYEE_ASSGN_CODE,
    CREAT_RUN_CYC_EXEC_SK,
    PRESTG_INSRT_DT
    FROM CCP_STG.CLM_HEADER_PRESTG P WHERE ACT_CD <>'D' AND SUBSTR(CLM_PRCSS_TYPE_CD,4,1) NOT IN  ('1','2','3','4','5','6')  ),
    PROV AS ( SELECT DISTINCT
    PROV_ID,
    PROV_FST_NM,
    PROV_MD_NM,
    PROV_LST_NM,
    PROV_BILL_ADR1,
    PROV_BILL_CITY,
    PROV_BILL_STATE,
    PROV_BILL_ZIP,
    CASE WHEN PROV_SEC_ID_QL='E' THEN PROV_SEC_ID
    ELSE NULL
    END AS PROV_SEC_ID,
    PROV_ADR1,
    PROV_CITY,
    PROV_STATE,
    PROV_ZIP
    FROM CCP_STG.DAILY_PROV_PRESTG),
    MBR_XREF AS (SELECT SUBSTR(MBR_ENROLL_ID,1,17)||DECODE ((SUBSTR(MBR_ENROLL_ID,18,1)),'E','1','S','2','D','3')||SUBSTR(MBR_ENROLL_ID,19) AS MBR_ENROLLL_ID,
      NEW_MBR_FLG
    FROM CCP_STG.CCP_MBRSHP_XREF)
    SELECT DISTINCT CLAIM_HDR.ICN_NUM AS ICN_NUM,
    CLAIM_HDR.SBCR_ID AS SBCR_ID,
    CLAIM_HDR.MBR_ID AS MBR_ID,
    CLAIM_HDR.MBR_FIRST_NAME AS MBR_FIRST_NAME,
    CLAIM_HDR.MBR_MI AS MBR_MI,
    CLAIM_HDR.MBR_LAST_NAME AS MBR_LAST_NAME,
    CLAIM_HDR.MBR_BIRTH_DATE AS MBR_BIRTH_DATE,
    CLAIM_HDR.GENDER_TYPE_CD AS GENDER_TYPE_CD,
    CLAIM_HDR.SBCR_RLTNSHP_TYPE_CD AS SBCR_RLTNSHP_TYPE_CD,
    CLAIM_HDR.SBCR_FIRST_NAME AS SBCR_FIRST_NAME,
    CLAIM_HDR.SBCR_MI AS SBCR_MI,
    CLAIM_HDR.SBCR_LAST_NAME AS SBCR_LAST_NAME,
    CLAIM_HDR.SBCR_ADDR_LINE_1 AS SBCR_ADDR_LINE_1,
    CLAIM_HDR.SBCR_ADDR_LINE2 AS SBCR_ADDR_LINE2,
    CLAIM_HDR.SBCR_ADDR_CITY AS SBCR_ADDR_CITY,
    CLAIM_HDR.SBCR_ADDR_STATE AS SBCR_ADDR_STATE,
    CLAIM_HDR.SBCR_ZIP_CD AS SBCR_ZIP_CD,
    CLAIM_HDR.PRVDR_NUM AS PRVDR_NUM,
    CLAIM_HDR.CLM_PRCSSD_DT AS CLM_PRCSSD_DT,
    CLAIM_HDR.CLM_TYPE_CLASS_CD AS CLM_TYPE_CLASS_CD,
    CLAIM_HDR.AUTHO_NUM AS AUTHO_NUM,
    CLAIM_HDR.TOT_BILLED_AMT AS TOT_BILLED_AMT,
    CLAIM_HDR.HCFA_DRG_TYPE_CD AS HCFA_DRG_TYPE_CD,
    CLAIM_HDR.FCLTY_ADMIT_DT AS FCLTY_ADMIT_DT,
    CLAIM_HDR.ADMIT_TYPE AS ADMIT_TYPE,
    CLAIM_HDR.DSCHRG_STATUS_CD AS DSCHRG_STATUS_CD,
    CLAIM_HDR.FILE_BILLING_NPI AS FILE_BILLING_NPI,
    CLAIM_HDR.CLAIM_LOCATION_CD AS CLAIM_LOCATION_CD,
    CLAIM_HDR.CLM_RELATED_ICN_1 AS CLM_RELATED_ICN_1,
    CLAIM_HDR.SUBSCR_INSGRP_NM,
    CLAIM_HDR.CAC,
    CLAIM_HDR.PRVDR_PTNT_ACC_ID,
    CLAIM_HDR.BILL_TYPE,
    CLAIM_DTL.FIRST_SRVC_DT AS FIRST_SRVC_DT,
    CLAIM_DTL.LAST_SRVC_DT AS LAST_SRVC_DT,
    CLAIM_DTL.PLC_OF_SRVC_CD AS PLC_OF_SRVC_CD,
    PROV.PROV_LST_NM AS BILL_PROV_LST_NM,
    PROV.PROV_FST_NM AS BILL_PROV_FST_NM,
    PROV.PROV_MD_NM AS BILL_PROV_MID_NM,
    PROV.PROV_BILL_ADR1 AS BILL_PROV_ADDR1,
    PROV.PROV_BILL_CITY AS BILL_PROV_CITY,
    PROV.PROV_BILL_STATE AS BILL_PROV_STATE,
    PROV.PROV_BILL_ZIP AS BILL_PROV_ZIP,
    PROV.PROV_SEC_ID AS BILL_PROV_EIN,
    PROV.PROV_ID AS SERV_FAC_ID    ,
    PROV.PROV_ADR1 AS SERV_FAC_ADDR1          ,
    PROV.PROV_CITY AS SERV_FAC_CITY ,
    PROV.PROV_STATE AS SERV_FAC_STATE          ,
    PROV.PROV_ZIP AS     SERV_FAC_ZIP  ,
    CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_1,
    CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_2,
    CHK_PAYMNT.CLM_PMT_PAYEE_CITY,
    CHK_PAYMNT.CLM_PMT_PAYEE_STATE_CD,
      CHK_PAYMNT.CLM_PMT_PAYEE_POSTAL_CD,
    CLAIM_HDR.CREAT_RUN_CYC_EXEC_SK
      FROM CLAIM_DTL,(select * FROM CCP_STG.CLM_DETAIL_PRESTG WHERE ACT_CD <>'D') CLM_DETAIL_PRESTG, CLAIM_HDR,CCP_STG.MBR_XREF,PROV,CCP_STG.CLM_PAYMNT_CLMEXT_PRESTG CLM_PAYMNT,CCP_STG.CLM_PAYMNT_CHKEXT_PRESTG CHK_PAYMNT
    WHERE    
    CLAIM_HDR.ICN_NUM = CLM_DETAIL_PRESTG.ICN_NUM
    AND       CLAIM_HDR.ICN_NUM = CLAIM_DTL.ICN_NUM
    AND CLAIM_HDR.ICN_NUM=CLM_PAYMNT.ICN_NUM(+)
    AND CLM_PAYMNT.CLM_PMT_CHCK_ACCT=CHK_PAYMNT.CLM_PMT_CHCK_ACCT
    AND CLM_PAYMNT.CLM_PMT_CHCK_NUM=CHK_PAYMNT.CLM_PMT_CHCK_NUM
    AND CLAIM_HDR.MBR_ENROLL_ID = MBR_XREF.MBR_ENROLLL_ID
    AND CLM_DETAIL_PRESTG.FIRST_SRVC_DT >= 20110101
    AND MBR_XREF.NEW_MBR_FLG = 'Y'
    AND PROV.PROV_ID(+)=SUBSTR(CLAIM_HDR.PRVDR_NUM,6)
    AND MOD(SUBSTR(CLAIM_HDR.ICN_NUM,14,2),2)=0
    UNION ALL
    SELECT DISTINCT CLAIM_HDR.ICN_NUM AS ICN_NUM,
    CLAIM_HDR.SBCR_ID AS SBCR_ID,
    CLAIM_HDR.MBR_ID AS MBR_ID,
    CLAIM_HDR.MBR_FIRST_NAME AS MBR_FIRST_NAME,
    CLAIM_HDR.MBR_MI AS MBR_MI,
    CLAIM_HDR.MBR_LAST_NAME AS MBR_LAST_NAME,
    CLAIM_HDR.MBR_BIRTH_DATE AS MBR_BIRTH_DATE,
    CLAIM_HDR.GENDER_TYPE_CD AS GENDER_TYPE_CD,
    CLAIM_HDR.SBCR_RLTNSHP_TYPE_CD AS SBCR_RLTNSHP_TYPE_CD,
    CLAIM_HDR.SBCR_FIRST_NAME AS SBCR_FIRST_NAME,
    CLAIM_HDR.SBCR_MI AS SBCR_MI,
    CLAIM_HDR.SBCR_LAST_NAME AS SBCR_LAST_NAME,
    CLAIM_HDR.SBCR_ADDR_LINE_1 AS SBCR_ADDR_LINE_1,
    CLAIM_HDR.SBCR_ADDR_LINE2 AS SBCR_ADDR_LINE2,
    CLAIM_HDR.SBCR_ADDR_CITY AS SBCR_ADDR_CITY,
    CLAIM_HDR.SBCR_ADDR_STATE AS SBCR_ADDR_STATE,
    CLAIM_HDR.SBCR_ZIP_CD AS SBCR_ZIP_CD,
    CLAIM_HDR.PRVDR_NUM AS PRVDR_NUM,
    CLAIM_HDR.CLM_PRCSSD_DT AS CLM_PRCSSD_DT,
    CLAIM_HDR.CLM_TYPE_CLASS_CD AS CLM_TYPE_CLASS_CD,
    CLAIM_HDR.AUTHO_NUM AS AUTHO_NUM,
    CLAIM_HDR.TOT_BILLED_AMT AS TOT_BILLED_AMT,
    CLAIM_HDR.HCFA_DRG_TYPE_CD AS HCFA_DRG_TYPE_CD,
    CLAIM_HDR.FCLTY_ADMIT_DT AS FCLTY_ADMIT_DT,
    CLAIM_HDR.ADMIT_TYPE AS ADMIT_TYPE,
    CLAIM_HDR.DSCHRG_STATUS_CD AS DSCHRG_STATUS_CD,
    CLAIM_HDR.FILE_BILLING_NPI AS FILE_BILLING_NPI,
    CLAIM_HDR.CLAIM_LOCATION_CD AS CLAIM_LOCATION_CD,
    CLAIM_HDR.CLM_RELATED_ICN_1 AS CLM_RELATED_ICN_1,
    CLAIM_HDR.SUBSCR_INSGRP_NM,
    CLAIM_HDR.CAC,
    CLAIM_HDR.PRVDR_PTNT_ACC_ID,
    CLAIM_HDR.BILL_TYPE,
    CLAIM_DTL.FIRST_SRVC_DT AS FIRST_SRVC_DT,
    CLAIM_DTL.LAST_SRVC_DT AS LAST_SRVC_DT,
    CLAIM_DTL.PLC_OF_SRVC_CD AS PLC_OF_SRVC_CD,
    PROV.PROV_LST_NM AS BILL_PROV_LST_NM,
    PROV.PROV_FST_NM AS BILL_PROV_FST_NM,
    PROV.PROV_MD_NM AS BILL_PROV_MID_NM,
    PROV.PROV_BILL_ADR1 AS BILL_PROV_ADDR1,
    PROV.PROV_BILL_CITY AS BILL_PROV_CITY,
    PROV.PROV_BILL_STATE AS BILL_PROV_STATE,
    PROV.PROV_BILL_ZIP AS BILL_PROV_ZIP,
    PROV.PROV_SEC_ID AS BILL_PROV_EIN,
    PROV.PROV_ID AS SERV_FAC_ID    ,
    PROV.PROV_ADR1 AS SERV_FAC_ADDR1          ,
    PROV.PROV_CITY AS SERV_FAC_CITY ,
    PROV.PROV_STATE AS SERV_FAC_STATE          ,
    PROV.PROV_ZIP AS     SERV_FAC_ZIP  ,
    CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_1,
    CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_2,
    CHK_PAYMNT.CLM_PMT_PAYEE_CITY,
    CHK_PAYMNT.CLM_PMT_PAYEE_STATE_CD,
    CHK_PAYMNT.CLM_PMT_PAYEE_POSTAL_CD,
    CLAIM_HDR.CREAT_RUN_CYC_EXEC_SK  
      FROM CLAIM_DTL, CLAIM_HDR,MBR_XREF,PROV,CCP_STG.CLM_PAYMNT_CLMEXT_PRESTG CLM_PAYMNT,CCP_STG.CLM_PAYMNT_CHKEXT_PRESTG CHK_PAYMNT
    WHERE CLAIM_HDR.ICN_NUM = CLAIM_DTL.ICN_NUM
    AND CLAIM_HDR.ICN_NUM=CLM_PAYMNT.ICN_NUM(+)
    AND CLM_PAYMNT.CLM_PMT_CHCK_ACCT=CHK_PAYMNT.CLM_PMT_CHCK_ACCT
    AND CLM_PAYMNT.CLM_PMT_CHCK_NUM=CHK_PAYMNT.CLM_PMT_CHCK_NUM
    AND CLAIM_HDR.MBR_ENROLL_ID = MBR_XREF.MBR_ENROLLL_ID
    -- AND TRUNC(CLAIM_HDR.PRESTG_INSRT_DT) = TRUNC(SYSDATE)
    AND CLAIM_HDR.CREAT_RUN_CYC_EXEC_SK = 123638.000000000000000
    AND MBR_XREF.NEW_MBR_FLG = 'N'
    AND PROV.PROV_ID(+)=SUBSTR(CLAIM_HDR.PRVDR_NUM,6)
    AND MOD(SUBSTR(CLAIM_HDR.ICN_NUM,14,2),2)=0;

  • Can not delete data from table which is queried in my stored procedure

    Hi,
    Anyone knows how to fix it:
    I have a table. In a stored procedure, I have a simple query running on this table.
    When I want to delete one record from that table, I got error message:
    ORA-04091: table *** is mutating, trigger/function may not see it.
    Thanks first.

    Rick, the only time you should get a mutating table error is when a trigger is involved. FK problems have separate error codes (and would be a different problem than the one that started this thread). Using a DBA id check all the tables subject to DML by your function and by whatever calls your function for triggers. Only the owner or a DBA can see the existence of triggers on a non-owned table. This has caused some of the developers I work with to think tables that had triggers do not have them since they do not work under the owning or a DBA ID.
    By your description of what you are trying to do in the function we do that all the time without problem.
    How large is the function? How/When is it called?
    Mark D Powell

  • Deleting items from R/3 are not reflected into BW

    Hi all,
    We are facing an issue in the extraction of sales data. (2lis_11_vascl)
    If the items in a sales document are deleted in R/3 through the transaction VA02 then these changes are reflected into BW system.
    But if the items in a sales document are deleted through a background job in R/3 system then these changes are not triggering any delta records and are not transferred to BW system.
    How to enable the R/3 system to capture the change even when the records are deleted using a background job?

    The delta is not that simple....
    The delta is based on certain fields being changed. These fields are controlled by change pointers set into the tables..
    It is a long process but then the summary is :
    1. You have change pointers set for each table to capture changes... these change pointers write back to your dellta queue whenever these fields change. If you change a field which does not have a change pointer attached to it then the delta is not recognized..
    2. Also it depends on how you do the deletion in the background job - if you are just deleting from VBAP then this is not right - there will be a standard SAP function module for deletion which has to be used - the reason being that when you delete sales orders then the stock , allocations etc for the same have to be adjusted...
    3. You will have to find out the change pointers in place currently for the sales extractor ( I think it is ROOSOURCE ) and then identify the fields which are linked to this change pointer. You will then have to create either a new change pointer or change the existing one to capture these fields also and then the delta should start flowing...
    You can ask an ABAPER or a R/3 functional person about the way these change pointers are configured and setup in R/3

Maybe you are looking for

  • BI Publisher Report Build - XML view

    Hi Experts, I am trying to build the BI publisher report. During the process, I am defining the SQL query structure in the 'Query Builder' once after that I have saved the report. As part of the next step , I have clicked on 'view' link to view the r

  • How do I install new fonts on my MBA?

    I'm trying to match a font. I've found one on a free web site that's close. I have downloaded it but not sure how to install it in my system. TIA for any pointers.

  • How to fix 'An Unknown error has occurred" when trying to save an  illustrator CS5 doc

    Hi I have just upgraded to a new iMac late 2013. After running a migration from my old mac to the new. I now have the following error: "Unknown error has occurred" when trying to save an illustrator CS5 doc. How do you  fix 'An Unknown error has occu

  • How you Prepare and Pass 1Z0-051,007 or 047 Needs Sugesstion

    Hello, I want to know how, all you people who have passed any of above three exams; Prepared for them . Please share your experience regarding your preparation techniques, your plan regarding solving the exam question and what were your expectation b

  • Attendee confirmation now showing in some events

    Some events in our iCal server are not showing the confirmation or declination by an attendee of an event to the other attendees of the event. The only person who can see the status on these events is the creator of the event. What is happening on th