Comparision Merge clause vs If not exists

Hi Team,
There exits various stored procedures, wherein developer has used if exists then update and if not then inserted records.
I would like to know, what is good option, considering with the fact that, stored procedure must be optimized and need to consume less resources.
Thanks  

Hi Team,
There exits various stored procedures, wherein developer has used if exists then update and if not then inserted records.
I would like to know, what is good option, considering with the fact that, stored procedure must be optimized and need to consume less resources.
Thanks  
see
http://www.mssqltips.com/sqlservertip/2651/comparing-performance-for-the-merge-statement-to-select-insert-update-or-delete/
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • Not able to migrate a query with not exist clause

    Hi all,
    I'm using Toplink 10.1.3 and I am trying to rewrite the following query with Expression Framework:
    select distinct r.e_ogg_oper_k_oggetto
    FROM regola_accettazione_oper_banc r, oggetto_operazione_bancaria o
    where not exists (
    select 1
    FROM limitaz_ogg_tipo_oper_banc l
    where nvl(l.d_fine_validita,trunc(sysdate)+1)>trunc(sysdate)
    and l.d_inizio_validita <= trunc(sysdate)
    and l.e_tpodv_k_tipo_operazione=:appoggio.tipo_operaz
    and l.e_ogg_oper_k_oggetto=r.e_ogg_oper_k_oggetto
    and l.e_uni_oper_k_unita_oper_util= :appoggio.e_uni_oper_k_unita_oper_esegui )
    and r.e_oper_ban_k_operaz_bancaria=:appoggio.form
    and r.e_ogg_oper_k_oggetto=o.k_oggetto
    and o.e_ogg_oper_k_oggetto is null
    and o.k_oggetto != nvl(:appoggio.oggetto_autom,,'0')
    and o.k_oggetto like substr(:appoggio.oggetto,1,2)||'%'
    and r.d_inizio_validita <= :appoggio.d_contab
    and to_date(nvl(to_char(r.d_fine_validita,DD/MM/YYYY'),31/12/3999'),'DD/MM/YYYY')> :appoggio.d_contab
    and o.f_natura_oggetto in ('G','P') and r.f_oggetto_automatizzato!='S'
    I'm not able to "attach" the not exist clause to the rest of query.
    How can I do it?
    Thank you very much.

    Not exists can be used in an expression through using a ReportQuery sub-query.
    i.e.
    ExpressionBuilder outerBuilder = new ExpressionBuilder();
    ReadAllQuery outerQuery = new ReadAllQuery(Employee.class, outerBuilder);
    ExpressionBuilder subBuilder = new ExpressionBuilder();
    ReportQuery subQuery = new ReportQuery(Address.class, subBuilder);
    subQuery.addAttribute("id");
    subQuery.setSelectionCriteria(
    subBuilder.get("city").equal(outerBuilder.get("address").get("city")
    .and(subBuilder.notEqual(outerBuilder.get("address")))));
    outerQuery.setSelectionCriteria(
    outerBuilder.notExists(subQuery));
    List results = (List) session.executeQuery(outerQuery);
    Refer to the documentation section on sub-queries for more information.
    I would suggest simlpifying the where clause until you get the sub-query working to start.
    You can also always use a custom SQL query in TopLink.

  • Problem in merge statement -ORA-27432 Step does not exist for chain

    Hi
    I m getting ORA-27432 Step does not exist for chain error in merge statement.Please explain the same.
    MERGE INTO fos.pe_td_hdr_sd B
    USING (
             SELECT ACTIVE, ADDUID, ADDUIDTIME,TDKEY         FROM pe.pe_td_hdr
              WHERE  (adduidtime like '20070104%' or edituidtime like '20070104%')
              AND NVL(legacy_td,'N')<>'Y'
              AND SUBSTR(adduidtime,1,4)='2007'
              AND AMENDMENT_NO=0)A ON ( B.TDKEY = A.TDKEY)
      WHEN MATCHED THEN
        UPDATE SET B.ACTIVE=A.ACTIVE,
    B.ADDUID=A.ADDUID,
            B.ADDUIDTIME=A.ADDUIDTIME
      WHEN NOT MATCHED THEN
                      INSERT
                              B.ACTIVE,
                              B.ADDUID,
                              B.ADDUIDTIME)
                        VALUES(
                              A.ACTIVE,
                              A.ADDUID,
                              A.ADDUIDTIME)This query is a short version of the main query.It is same but having 180 columns in original table.

    What version of Oracle are you using? This message does not appear in my 10.1 Error Messages document, but the other messages in that range seem to be about DBMS_SCHEDULER.
    Are you using scheduler somewhere around where you are getting the error message?
    John

  • Using SSIS 2012 - merge join component to transfer data to destination provided it does not exist

    HI Folks,
    I have a table - parts_amer and this table exists in source & destination server as well.
    CREATE TABLE [dbo].[Parts_AMER](
     [ServiceTag] [varchar](30) NOT NULL,
     [ComponentID] [decimal](18, 0) NOT NULL,
     [PartNumber] [varchar](20) NULL,
     [Description] [varchar](400) NULL,
     [Qty] [decimal](8, 0) NOT NULL,
     [SrcCommodityCod] [varchar](40) NULL,
     [PartShortDesc] [varchar](100) NULL,
     [SKU] [varchar](30) NULL,
     [SourceInsertUpdateDate] [datetime2](7) NOT NULL,
     CONSTRAINT [PK_Parts_AMER] PRIMARY KEY CLUSTERED
     [ServiceTag] ASC,
     [ComponentID] ASC
    I need to exec the following query using SSIS components so that only that data ,is transfered,which does not exist at destination -
    select source.*
    from parts_amer source left join parts_amer destination
    on source.ServiceTag = destination.ServiceTag
    and source.ComponentID=destination.ComponentID
    where destination.ServiceTag  is null and destination.ComponentID is null
    Question - Can Merge component help with this?
    Pl help out.
    Thanks.

    Hi Rvn_venky2605,
    The Merge Join Transformation is used to join two sorted datasets using a FULL, LEFT, or INNER join, hence, not suitable in your scenario. As James mentioned, you can use Lookup Transformation to redirect the not matched records to the destination table.
    Another option is to write a T-SQL script that makes use of
    Merge statement, and execute the script via Execute SQL Task.
    References:
    http://oakdome.com/programming/SSIS_Lookup.php 
    http://www.mssqltips.com/sqlservertip/1511/lookup-and-cache-transforms-in-sql-server-integration-services/ 
    Regards,
    Mike Yin
    TechNet Community Support

  • Wrong query is getting generated in WHERE NOT EXISTS  with group by clause

    Query is getting generated wrongly in where not exists section when i use group by function.Please prvoide me any clue to over come the problem.
    /* DETECTION_STRATEGY = NOT_EXISTS */
    INSERT /*+ APPEND */ INTO STG_ETL.I$_DCMT_TIMEZONE_LOOKUP
         TZ_OFFSET,
         ADT_CRT_DT,
         ADT_UPDT_DT,
         IND_UPDATE
    SELECT * FROM (
    SELECT      
         to_number(KOFAX.RECEIVED_TZ)     TZ_OFFSET,
         min(sysdate)     ADT_CRT_DT,
         min(sysdate)     ADT_UPDT_DT,
         'I' IND_UPDATE
    FROM     ESTG.FLAT_FIL_DMS_KOFAX KOFAX
    WHERE     (1=1)
    And (KOFAX.LD_DT = ( select MAX(LD_DT) from ESTG.FLAT_FIL_DMS_KOFAX INNER
    where INNER.ENGAGEMENT=KOFAX.ENGAGEMENT
                   and INNER.KOFAX_FILE_NM = KOFAX.KOFAX_FILE_NM
                   AND INNER.IM_CUST_ID = KOFAX.IM_CUST_ID
              and INNER.BATCH_ID=KOFAX.BATCH_ID)
    AND
    (TO_DATE(KOFAX.LD_DT)>=TO_DATE(SUBSTR('#WAREHOUSE.P_EDW_LAST_RUN',1,10),'YYYY-MM-DD'))
    And (substr(KOFAX.RECEIVED_TZ,1,1) <> '+')
    Group By to_number(KOFAX.RECEIVED_TZ)
    ) S
    WHERE NOT EXISTS (
         SELECT     'X'
         FROM     EDW.DCMT_TIMEZONE_LOOKUP T
         WHERE     T.TZ_OFFSET     = S.TZ_OFFSET AND
         )

    Easiest fix for you would be to change the detection_strategy on the IKM from NOT_EXISTS to either :
    MINUS
    -- Try this out, it should work, it will give the same data through the equiverlant steps.
    NONE
    -- This will load all incoming data into your I$ table, there will be more rows to crunch in the following 'Flag Rows for Update' step, it might give incorrect results potentially - you will have to test it.
    So try MINUS first, failing that, see if NONE gives you what you want in your target.
    Are you inserting only new data or updating existing data?

  • The constraints ddl clause does not exists in  indexfile using imp tools

    SQL> -- Create table
    SQL> create table TB_EXP_TEST
      2  (
      3    OWNER          VARCHAR2(30) not null,
      4    OBJECT_NAME    VARCHAR2(128) not null,
      5    SUBOBJECT_NAME VARCHAR2(30),
      6    OBJECT_ID      NUMBER not null,
      7    DATA_OBJECT_ID NUMBER,
      8    OBJECT_TYPE    VARCHAR2(19),
      9    CREATED        DATE,
    10    LAST_DDL_TIME  DATE,
    11    TIMESTAMP      VARCHAR2(19),
    12    STATUS         VARCHAR2(7),
    13    TEMPORARY      VARCHAR2(1),
    14    GENERATED      VARCHAR2(1),
    15    SECONDARY      VARCHAR2(1),
    16    NAMESPACE      NUMBER,
    17    EDITION_NAME   VARCHAR2(30)
    18  )
    19  tablespace USERS
    20    pctfree 10
    21    initrans 1
    22    maxtrans 255
    23    storage
    24    (
    25      initial 9M
    26      next 1M
    27      minextents 1
    28      maxextents unlimited
    29    );
    Table created.
    SQL> -- Create/Recreate primary, unique and foreign key constraints
    SQL> alter table TB_EXP_TEST
      2    add constraint  EXP_TEST_PK  primary key (OBJECT_ID)
      3    using index
      4    tablespace USERS
      5    pctfree 10
      6    initrans 2
      7    maxtrans 255
      8    storage
      9    (
    10      initial 2M
    11      next 1M
    12      minextents 1
    13      maxextents unlimited
    14    );
    Table altered.
    SQL> -- Create/Recreate indexes
    SQL> create index IDX_TB_EXP_TEST_N1 on TB_EXP_TEST (OBJECT_NAME)
      2    tablespace USERS
      3    pctfree 10
      4    initrans 2
      5    maxtrans 255
      6    storage
      7    (
      8      initial 4M
      9      next 1M
    10      minextents 1
    11      maxextents unlimited
    12    );
    Index created.
    SQL> Insert Into TB_EXP_TEST
      2  Select * From Dba_Objects Where object_id Is Not Null;
    76143 rows created.
    SQL>exit;
    exp hxl/hxl@orcl file=c:\exptest.dmp tables=(tb_exp_test);
    SQL>drop table tb_exp_test;
    imp hxl/hxl@orcl file=c:\exptest.dmp tables=(tb_exp_test) constraints=Y indexes=Y  indexfile=C:\index.txtThe index.txt contents is flowing,but the add constraint EXP_TEST_PK primary key not exists ,and it is remed,Why?
    REM CREATE TABLE "HXL"."TB_EXP_TEST" ("OWNER" VARCHAR2(30) NOT NULL
    REM ENABLE, "OBJECT_NAME" VARCHAR2(128) NOT NULL ENABLE, "SUBOBJECT_NAME"
    REM VARCHAR2(30), "OBJECT_ID" NUMBER, "DATA_OBJECT_ID" NUMBER,
    REM "OBJECT_TYPE" VARCHAR2(19), "CREATED" DATE, "LAST_DDL_TIME" DATE,
    REM "TIMESTAMP" VARCHAR2(19), "STATUS" VARCHAR2(7), "TEMPORARY"
    REM VARCHAR2(1), "GENERATED" VARCHAR2(1), "SECONDARY" VARCHAR2(1),
    REM "NAMESPACE" NUMBER, "EDITION_NAME" VARCHAR2(30)) PCTFREE 10 PCTUSED
    REM 40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 9437184 NEXT 1048576
    REM MINEXTENTS 1 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    REM TABLESPACE "USERS" LOGGING NOCOMPRESS ;
    REM ... 76141 rows
    CONNECT HXL;
    CREATE INDEX "HXL"."IDX_TB_EXP_TEST_N1" ON "TB_EXP_TEST" ("OBJECT_NAME" )
    PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 4194304 NEXT 1048576
    MINEXTENTS 1 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE
    "USERS" LOGGING ;
    CREATE UNIQUE INDEX "HXL"."EXP_TEST_PK" ON "TB_EXP_TEST" ("OBJECT_ID" )
    PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 2097152 NEXT 1048576
    MINEXTENTS 1 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE
    "USERS" LOGGING ;
    REM ALTER TABLE "HXL"."TB_EXP_TEST" ADD CONSTRAINT "*EXP_TEST_PK*" PRIMARY
    REM KEY ("OBJECT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
    REM STORAGE(INITIAL 2097152 NEXT 1048576 MINEXTENTS 1 FREELISTS 1
    REM FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "USERS" LOGGING
    REM ENABLE ;

    Pavan Kumar wrote:
    Hi,
    Are you sure on that - but we can able view from the text which you floated across here (or) else my understanding is wrong with respect your question across.
    - Pavan Kumar NI sure the code is not any problem.

  • Insert when not exists

    Is there anyway of getting owb to implement the following sql without
    resorting to using a insert update operation:
    insert into desttable
    (select * from myview where not exists (select null from b where desttable.emp_id=myview.emp_id)
    This sounds almost like the perfect application for an insert/update (or merge)
    operation. But in my case, I do not want to update the destination tables if I get
    a match, I am only interested in using the insert part of a merge operation. I could
    create a dummy update clause, but that would be a waste of resources.
    Any ideas?
    Graeme

    What I've done in this situation, and there might be a better way, is use an outer join. Essentially, I do this:
    insert into desttable (
    select a.*
    from mytable a, desttable b
    where a.emp_id = b.emp_id(+)
    and b.emp_id is null
    I believe this accomplishes the same thing as "not exists".
    Message was edited by:
    user631136

  • INSERT rows that do not exist

    I need to update (post) a table with summarized totals from another table. It is possible that the matching rows do not exist so I want to insert them before posting (UPDATE) to them. There is a table named BillingDetail that is summarized to insert into
    another table named BillingHistory when rows do not match on 4 different columns. Below is my first shot at doing this but am not sure if the NOT IN clause is correct or maybe there is another (better) way.
    INSERT INTO [dbo].[BillingHistory]
    ([entity]
    ,[plincd]
    ,[pgrpcd]
    ,[pitmcd]
    ,[hstyr]
    ,[corpnbr]
    SELECT @entity
    ,plincd
    ,pgrpcd
    ,pitmcd
    ,@hstyr
    ,corpnbr
    FROM (SELECT plincd
    ,pgrpcd
    ,pitmcd
    ,corpnbr
    ,SUM(qty) AS TotalQty
    ,SUM(extprc) AS TotalExtPrice
    FROM dbo.BillingDetail
    GROUP BY corpnbr, plincd, pgrpcd, pitmcd) AS DT
    WHERE pitmcd NOT IN(SELECT pitmcd FROM dbo.BillingHistory WHERE plincd = DT.plincd AND pgrpcd = DT.pgrpcd AND pitmcd = DT.pitmcd AND corpnbr = DT.corpnbr);

    Not knowing the keys of BillingHistory, it is difficult to say whether your INSERT is correct, but it does look funny. My guess is that all six columns constitute the key, in which case this would be better:
       INSERT INTO [dbo].[BillingHistory]
               ([entity]
               ,[plincd]
               ,[pgrpcd]
               ,[pitmcd]
               ,[hstyr]
               ,[corpnbr]
          SELECT @entity
               ,plincd
               ,pgrpcd
               ,pitmcd
               ,@hstyr
               ,corpnbr
          FROM (SELECT plincd
                  ,pgrpcd
                  ,pitmcd
                  ,corpnbr
                  ,SUM(qty) AS TotalQty
                  ,SUM(extprc) AS TotalExtPrice
               FROM  dbo.BillingDetail
             GROUP BY corpnbr, plincd, pgrpcd, pitmcd) AS DT
                  WHERE  NOT EXISTS (SELECT *
                                     FROM   dbo.BillingHistory BH
                                     WHERE  BH.entity = @entity
                                       AND  BH.plincd = DT.plincd
                                       AND  BH.pgrpcd = DT.prgpcd
                                       AND  BH.pitcmd = DT.pitcmd
                                       AND  BH.hstyr  = @hstyr
                                       AND  BH.corpnbr = DT.corpnbr)
    And even better may be to use MERGE as Ronen suggested, but I want to see the CREATE TABLE statements (including keys) for the table before I try that.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • If image file not exist in image path crystal report not open and give me exception error problem

    Hi guys my code below show pictures for all employees
    code is working but i have proplem
    if image not exist in path
    crystal report not open and give me exception error image file not exist in path
    although the employee no found in database but if image not exist in path when loop crystal report will not open
    how to ignore image files not exist in path and open report this is actually what i need
    my code below as following
    DataTable dt = new DataTable();
    string connString = "data source=192.168.1.105; initial catalog=hrdata;uid=sa; password=1234";
    using (SqlConnection con = new SqlConnection(connString))
    con.Open();
    SqlCommand cmd = new SqlCommand("ViewEmployeeNoRall", con);
    cmd.CommandType = CommandType.StoredProcedure;
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = cmd;
    da.Fill(dt);
    foreach (DataRow dr in dt.Rows)
    FileStream fs = null;
    fs = new FileStream("\\\\192.168.1.105\\Personal Pictures\\" + dr[0] + ".jpg", FileMode.Open);
    BinaryReader br = new BinaryReader(fs);
    byte[] imgbyte = new byte[fs.Length + 1];
    imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
    dr["Image"] = imgbyte;
    fs.Dispose();
    ReportDocument objRpt = new Reports.CrystalReportData2();
    objRpt.SetDataSource(dt);
    crystalReportViewer1.ReportSource = objRpt;
    crystalReportViewer1.Refresh();
    and exception error as below

    First: I created a New Column ("Image") in a datatable of the dataset and change the DataType to System.Byte()
    Second : Drag And drop this image Filed Where I want.
    private void LoadReport()
    frmCheckWeigher rpt = new frmCheckWeigher();
    CryRe_DailyBatch report = new CryRe_DailyBatch();
    DataSet1TableAdapters.DataTable_DailyBatch1TableAdapter ta = new CheckWeigherReportViewer.DataSet1TableAdapters.DataTable_DailyBatch1TableAdapter();
    DataSet1.DataTable_DailyBatch1DataTable table = ta.GetData(clsLogs.strStartDate_rpt, clsLogs.strBatchno_Rpt, clsLogs.cmdeviceid); // Data from Database
    DataTable dt = GetImageRow(table, "Footer.Jpg");
    report.SetDataSource(dt);
    crv1.ReportSource = report;
    crv1.Refresh();
    By this Function I merge My Image data into dataTable
    private DataTable GetImageRow(DataTable dt, string ImageName)
    try
    FileStream fs;
    BinaryReader br;
    if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + ImageName))
    fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageName, FileMode.Open);
    else
    // if photo does not exist show the nophoto.jpg file
    fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageName, FileMode.Open);
    // initialise the binary reader from file streamobject
    br = new BinaryReader(fs);
    // define the byte array of filelength
    byte[] imgbyte = new byte[fs.Length + 1];
    // read the bytes from the binary reader
    imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
    dt.Rows[0]["Image"] = imgbyte;
    br.Close();
    // close the binary reader
    fs.Close();
    // close the file stream
    catch (Exception ex)
    // error handling
    MessageBox.Show("Missing " + ImageName + "or nophoto.jpg in application folder");
    return dt;
    // Return Datatable After Image Row Insertion
    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

  • Short dump 'Table does not exist in database'

    Hello All,
    When a report is executing it is going to short dump by saying 'Table does not exist in database'. As per the short dump analysis this issue is happening because of the following   Native SQL statement statement :
    Program :  %_T050N0 (This is a dynamic  program generating by SAP )
    Form Name :  DYN_LIC_SEL_TOT
    exec sql performing LOOP_MOVE_WRITE_ISAP.
    select single_plate, itm_num, ctry_code, model_lot,
    lic_hold_flg, qty into :dcat-lplate, :dcat-matnr,
    :dcat-werks, :dcat-charg, :dcat-holdflag,
    :dcat-qty from ZLICENSE_R2 where itm_num   = :p_matnr and
                    model_lot = :p_charg
    endexec.
    As per the customer this issue occurring since they migrated the SAP  back-end data base from Oralce to DB6. Here I felt that ZLICENSE_R2 is not migrated from the  Oracle to DB6. But as per the BASIS Team, even this table was not maintained in Oracle also. If the table was not maintained in the Oracle, this issue should have been there even before migration also.
    Following is the short dump details:
    Short text
        Table does not exist in database.
    What happened?
        The table or view name used does not
        exist in the database.
        The error occurred in the current database connection "DEFAULT".
    What can you do?
        Check the spelling of the table names in your report.
        Note down which actions and inputs caused the error.
        To process the problem further, contact you SAP system
        administrator.
        Using Transaction ST22 for ABAP Dump Analysis, you can look
        at and manage termination messages, and you can also
        keep them for a long time.
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_NATIVE_SQL_ERROR', was not
         caught in
       procedure "DYN_LIC_SEL_TOT" "(FORM)", nor was it propagated by a RAISING
    clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    Triggering SQL statement: "select single_plate, itm_num, ctry_code, model_lot,
    lic_hold_flg, qty from ZLICENSE_R2 where itm_num = ? and model_lot = ? "
    Database error code: "-204"
    Could you please  let me know what might be the reason for this issue.
    Many Thanks in Advance.

    Transaction SE11, input ZLICENSE_R2 for table name, and display the table. Did the table display? If not, that is the main problem.
    If the table displays, go to menu item Utilities -> Database Object -> Database Utility
    In the resulting screen, under the "Status" fields, you should see text "Exists in the database." If you don't, then the table exists in the dictionary, but doesn't exist in the database system. Click the "Create database table" button and then you should be able to run the program.
    You may need basis team's help to carryout some of these actions.

  • Not in and Not Exists

    Hi everyone,
    I need some explanation on why the index is not being used in one of my queries.
    Here are the queries:
    SELECT COUNT (1)
    FROM (SELECT hdr.ALLOC_HDR_SEQ_NBR hdrnbr
    FROM sm_vda_allocation_header hdr
    INNER JOIN
    sm_vda_type vdatype
    ON hdr.vda_typ_cd = vdatype.vda_typ_cd
    WHERE
    vdatype.SAP_POST_TYP_CD = 'JE'
    AND vdatype.vda_alloc_flg = 'Y'
    AND hdr.vda_liab_flg IS NULL
    AND hdr.sap_extrct_dt IS NULL
    AND hdr.ALLOC_HDR_SEQ_NBR NOT IN
    (SELECT alloc_hdr_seq_nbr
    FROM sm_vda_allocation_detail));
    return 0 rows.
    explain plan::
    Plan
    SELECT STATEMENT CHOOSECost: 671 Bytes: 26 Cardinality: 1                          
         8 SORT AGGREGATE Bytes: 26 Cardinality: 1                     
              7 HASH JOIN Cost: 671 Bytes: 293,254 Cardinality: 11,279                
                   1 TABLE ACCESS FULL SM_APPL.SM_VDA_TYPE Cost: 5 Bytes: 56 Cardinality: 7           
                   6 MERGE JOIN ANTI Cost: 665 Bytes: 281,106 Cardinality: 15,617           
                        3 TABLE ACCESS BY INDEX ROWID SM_APPL.SM_VDA_ALLOCATION_HEADER Cost: 496 Bytes: 241,860 Cardinality: 20,155      
                             2 INDEX FULL SCAN UNIQUE SM_APPL.SM_VDA_ALLOCATION_HEADER_PK Cost: 438 Cardinality: 20,450
                        5 SORT UNIQUE Cost: 169 Bytes: 417,480 Cardinality: 69,580      
                             4 INDEX FAST FULL SCAN NON-UNIQUE SM_APPL.SM_VDA_ALLOCATION_DETAIL_FK_I Cost: 86 Bytes: 417,480 Cardinality: 69,580
    2nd query::
    SELECT COUNT (1)
    FROM (SELECT hdr.ALLOC_HDR_SEQ_NBR hdrnbr
    FROM sm_vda_allocation_header hdr
    INNER JOIN
    sm_vda_type vdatype
    ON hdr.vda_typ_cd = vdatype.vda_typ_cd
    WHERE
    vdatype.SAP_POST_TYP_CD = 'JE'
    AND vdatype.vda_alloc_flg = 'Y'
    AND hdr.vda_liab_flg IS NULL
    AND hdr.sap_extrct_dt IS NULL
    AND NOT exists
    (SELECT 1
    FROM sm_vda_allocation_detail b where
    hdr.ALLOC_HDR_SEQ_NBR = b.ALLOC_HDR_SEQ_NBR));
    explain plan:::
    Plan
    SELECT STATEMENT CHOOSECost: 831 Bytes: 20 Cardinality: 1                     
         6 SORT AGGREGATE Bytes: 20 Cardinality: 1                
              5 FILTER           
                   3 HASH JOIN Cost: 828 Bytes: 14,560 Cardinality: 728      
                        1 TABLE ACCESS FULL SM_APPL.SM_VDA_TYPE Cost: 5 Bytes: 56 Cardinality: 7
                        2 TABLE ACCESS FULL SM_APPL.SM_VDA_ALLOCATION_HEADER Cost: 822 Bytes: 12,096 Cardinality: 1,008
                   4 INDEX RANGE SCAN NON-UNIQUE SM_APPL.SM_VDA_ALLOCATION_DETAIL_FK_I Cost: 3 Bytes: 90 Cardinality: 15      
    In the 2nd query with NOT EXISTS, I see FULL table scan for SM_APPL.SM_VDA_ALLOCATION_HEADER
    In the first query, the index is used in the same place:
    2 INDEX FULL SCAN UNIQUE SM_APPL.SM_VDA_ALLOCATION_HEADER_PK Cost: 438 Cardinality: 20,450
    ALLOC_HDR_SEQ_NBR is a primary key column.
    Actually NOT IN and NOT EXISTS both used index for the second inner table (SM_APPL.SM_VDA_ALLOCATION_DETAIL).
    But NOT exists is not using the index for the first table but not in is using.
    how come.

    872605 wrote:
    Hi everyone,
    I need some explanation on why the index is not being used in one of my queries.
    Here are the queries:
    SELECT COUNT (1)
    FROM (SELECT hdr.ALLOC_HDR_SEQ_NBR hdrnbr
    FROM sm_vda_allocation_header hdr
    INNER JOIN
    sm_vda_type vdatype
    ON hdr.vda_typ_cd = vdatype.vda_typ_cd
    WHERE
    vdatype.SAP_POST_TYP_CD = 'JE'
    AND vdatype.vda_alloc_flg = 'Y'
    AND hdr.vda_liab_flg IS NULL
    AND hdr.sap_extrct_dt IS NULL
    AND hdr.ALLOC_HDR_SEQ_NBR NOT IN
    (SELECT alloc_hdr_seq_nbr
    FROM sm_vda_allocation_detail));
    return 0 rows.
    explain plan::
    Plan
    SELECT STATEMENT CHOOSECost: 671 Bytes: 26 Cardinality: 1                          
         8 SORT AGGREGATE Bytes: 26 Cardinality: 1                     
              7 HASH JOIN Cost: 671 Bytes: 293,254 Cardinality: 11,279                
                   1 TABLE ACCESS FULL SM_APPL.SM_VDA_TYPE Cost: 5 Bytes: 56 Cardinality: 7           
                   6 MERGE JOIN ANTI Cost: 665 Bytes: 281,106 Cardinality: 15,617           
                        3 TABLE ACCESS BY INDEX ROWID SM_APPL.SM_VDA_ALLOCATION_HEADER Cost: 496 Bytes: 241,860 Cardinality: 20,155      
                             2 INDEX FULL SCAN UNIQUE SM_APPL.SM_VDA_ALLOCATION_HEADER_PK Cost: 438 Cardinality: 20,450
                        5 SORT UNIQUE Cost: 169 Bytes: 417,480 Cardinality: 69,580      
                             4 INDEX FAST FULL SCAN NON-UNIQUE SM_APPL.SM_VDA_ALLOCATION_DETAIL_FK_I Cost: 86 Bytes: 417,480 Cardinality: 69,580
    2nd query::
    SELECT COUNT (1)
    FROM (SELECT hdr.ALLOC_HDR_SEQ_NBR hdrnbr
    FROM sm_vda_allocation_header hdr
    INNER JOIN
    sm_vda_type vdatype
    ON hdr.vda_typ_cd = vdatype.vda_typ_cd
    WHERE
    vdatype.SAP_POST_TYP_CD = 'JE'
    AND vdatype.vda_alloc_flg = 'Y'
    AND hdr.vda_liab_flg IS NULL
    AND hdr.sap_extrct_dt IS NULL
    AND NOT exists
    (SELECT 1
    FROM sm_vda_allocation_detail b where
    hdr.ALLOC_HDR_SEQ_NBR = b.ALLOC_HDR_SEQ_NBR));
    explain plan:::
    Plan
    SELECT STATEMENT CHOOSECost: 831 Bytes: 20 Cardinality: 1                     
         6 SORT AGGREGATE Bytes: 20 Cardinality: 1                
              5 FILTER           
                   3 HASH JOIN Cost: 828 Bytes: 14,560 Cardinality: 728      
                        1 TABLE ACCESS FULL SM_APPL.SM_VDA_TYPE Cost: 5 Bytes: 56 Cardinality: 7
                        2 TABLE ACCESS FULL SM_APPL.SM_VDA_ALLOCATION_HEADER Cost: 822 Bytes: 12,096 Cardinality: 1,008
                   4 INDEX RANGE SCAN NON-UNIQUE SM_APPL.SM_VDA_ALLOCATION_DETAIL_FK_I Cost: 3 Bytes: 90 Cardinality: 15      
    In the 2nd query with NOT EXISTS, I see FULL table scan for SM_APPL.SM_VDA_ALLOCATION_HEADER
    In the first query, the index is used in the same place:
    2 INDEX FULL SCAN UNIQUE SM_APPL.SM_VDA_ALLOCATION_HEADER_PK Cost: 438 Cardinality: 20,450
    ALLOC_HDR_SEQ_NBR is a primary key column.
    Actually NOT IN and NOT EXISTS both used index for the second inner table (SM_APPL.SM_VDA_ALLOCATION_DETAIL).
    But NOT exists is not using the index for the first table but not in is using.
    how come.WHY MY INDEX IS NOT BEING USED
    http://communities.bmc.com/communities/docs/DOC-10031
    http://searchoracle.techtarget.com/tip/Why-isn-t-my-index-getting-used
    http://www.orafaq.com/tuningguide/not%20using%20index.html

  • I have an "old" Apple ID set up 13 years ago.  Apple has now gone to using email address as the apple ID.  I have apps to update and they ask for old ID.  it does not exist.  How can I get the ID on the app changed to the new apple ID

    I set up an apple id many years ago when itunes was established.  Within the past year or so, Apple has changed to using email address as user id.  My problem is that I have many applications that I can not update due to the fact that it is asking for the password of the old ID.  It does not exist anymore.  Any ideas on how to get the new apple id associated with the application without deleting the application.  Several of these apps I purchased.

    You can not merge accounts.
    Apps are tied to the Apple ID used to download them, you can not transfer them.

  • Primary index does not exist in database but shows in SE14?

    I added a couple of key fields to a Z table and activated it. Every thing went well - adjusted it with SE14 also.
    When I checked the Runtime object - it is OK.
    When I checked Database Object, it is showing that the Primary Index does not exist in Database but SE14 says that the Priamry Index exists in Database.
    Please advise how to correct this. I saw another psoting when I searched per this error message: "Indexes: Inconsistent with DDIC source" . It tells to create this index at Database but need to know the steps.
    pl advise.
    (reposting here)
    Edited by: Venkatabby on Mar 26, 2008 4:05 PM

    hi,
    To create a index for a table,
    go to se11->click on Indexes tab and create  a primary index.
    Indexes speed up data selection from the database. They consist of selected fields of a table, of which a copy is then made in sorted order. If you specify the index fields correctly in a condition in the WHERE or HAVING clause, the system only searches part of the index (index range scan).
    The system automatically creates the primary index. It consists of the primary key fields of the database table. This means that for each combination of fields in the index, there is a maximum of one line in the table. This kind of index is also known as UNIQUE.
    If you cannot use the primary index to determine the result set because, for example, none of the primary index fields occur in the WHERE or HAVINGclauses, the system searches through the entire table (full table scan). For this case, you can create secondary indexes, which can restrict the number of table entries searched to form the result set.
    You create secondary indexes using the ABAP Dictionary. There you can create its columns and define it as UNIQUE.
    reward points if useful.
    regards
    sandhya

  • The contained field name "ADTAGR" does not exist in any of the database tab

    hı all
    how can l  solved thıs problem
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
    not caught in
    procedure "PUT_QMFECAT" "(FORM)", nor was it propagated by a RAISING clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    An Open SQL clause was specified dynamically. The contained field name
    "ADTAGR" does not exist in any of the database tables from the FROM clause.
    Information on where terminated
        Termination occurred in the ABAP program "SAPDBZQNQ" - in "PUT_QMFECAT".
        The main program was "ZQMR_BILDIRIM ".
        In the source code you have the termination point in line 732
        of the (Include) program "SAPDBZQNQ".
    Error occurred during batch input processing
        The termination is caused because exception "CX_SY_DYNAMIC_OSQL_SEMANTICS"
         occurred in
        procedure "PUT_QMFECAT" "(FORM)", but it was neither handled locally nor
         declared
        in the RAISING clause of its signature.
        The procedure is in program "SAPDBZQNQ "; its source code begins in line
        715 of the (Include program "SAPDBZQNQ ".
    FORM put_qmfecat.
      DATA: l_tab_fields  TYPE  rsfs_tab_fields.
      DATA: l_ds_clauses  TYPE  rsds_where.
    Dynamische Feldselektion
      MOVE 'QMFECAT_C' TO l_tab_fields-tablename.
      READ TABLE select_fields WITH KEY l_tab_fields-tablename
                                    INTO l_tab_fields.
      IF sy-subrc <> c_rc00.
        CLEAR l_tab_fields.
      ENDIF.
    Dynamische Selektionskriterien
      MOVE 'QMFECAT' TO l_ds_clauses-tablename.
      READ TABLE dyn_sel-clauses WITH KEY l_ds_clauses-tablename
                                 INTO l_ds_clauses.
    DB-Zugriff
      >>>>> SELECT (l_tab_fields-fields) FROM qmfe
      INTO CORRESPONDING FIELDS OF TABLE qmfecat_tab
       WHERE qmnum  =  rqmqmel-qmnum
       AND kzloesch =  space
       AND (l_ds_clauses-where_tab)
       ORDER BY PRIMARY KEY.
    regard sinan
    Edited by: eyup_sinan on Jan 6, 2012 3:21 PM
    Edited by: eyup_sinan on Jan 6, 2012 3:30 PM

    You seem to have made a copy of the standard program. You'll have to make sure that you are handling this field correctly in your code.
    Rob

  • Function Module Does not exist

    Hello Experts,
    I am trying to run the initialization for the Billing conditions 2lis_13_vdkon datasource.
    Job is getting cancelled and the following error messages are coming when i check the job log in source system
    Job started
    Step 001 started (program SBIE0001, variant &0000000006238, user ID BASIS
    Asynchronous transmission of info IDoc 2 in task 0001 (0 parallel tasks)
    DATASOURCE = 2LIS_13_VDKON
    RLOGSYS    = BWDCLNT900
    REQUNR     = REQU_DHKONXGA1B82HZ49O94KQ03C4
    UPDMODE    = C
    LANGUAGES  = *
    *          Current Values for Selected Profile Parameters               *
    * abap/heap_area_nondia......... 2000683008
    * abap/heap_area_total.......... 2000683008
    * abap/heaplimit................ 40894464
    * zcsa/installed_languages...... ED
    * zcsa/system_language.......... E
    * ztta/max_memreq_MB............ 2047
    * ztta/roll_area................ 3000320
    * ztta/roll_extension........... 2000683008
    Function module /BI0/QI2LIS_13_VDKON does not exist
    You can only use LIKE and TYPE to specify types in RFC
    Internal session terminated with a runtime error (see ST22)
    Job cancelled
    even when i check in ST22
    Category         
    ABAP Programming Error
    Runtime Errors   
    IMPORT_ALIGNMENT_MISMATCH
    Except.          
    CX_SY_IMPORT_MISMATCH_ERROR
    ABAP Program     
    SAPLMCEX
    Application Component  LO-LIS
    Date and Time    
    06.05.2014 12:30:28
    Error analysis
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_IMPORT_MISMATCH_ERROR', was
    not caught in
    procedure "MCEX_BW_LO_API" "(FUNCTION)", nor was it propagated by a RAISING
    clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    When importing object "MC13VD0KON_TAB", the structure did not match the
    structure of the target object. The error occurred in component
    no. 21.
    This may be due to one of the following reasons:
    - the structure is actually different (the next field has, for
    example, a different data type) or
    - the same sequence of components were exported and imported,
    but the fields were from other include units.
    How to correct the error
    There is a probably a new version of the program active that does
    not match the dataset. The data may not have been converted.
    It is also possible that the field type of the imported field
    has been changed in the Data Dictionary.
    Try to eliminate the error by regenerating the program "SAPLMCEX". To
    do this, proceed as follows:
    Call Transaction SE38 in the R/3 System, enter the program
    name "SAPLMCEX" and then choose "Generate".
    If the error occurred in your own ABAP program or in an SAP
    program you modified, try to remove the error.
    If the error occures in a non-modified SAP program, you may be able to
    find an interim solution in an SAP Note.
    If you have access to SAP Notes, carry out a search with the following
    keywords:
    "IMPORT_ALIGNMENT_MISMATCH" "CX_SY_IMPORT_MISMATCH_ERROR"
    "SAPLMCEX" or "LMCEXU06"
    "MCEX_BW_LO_API"
    If you cannot solve the problem yourself and want to send an error
    please help me in this regards
    Quick response will be appreciated.
    Thanks in advance

    Hi Ram,
    no upgrades recently
    they have taken backup from production server.
    now i am facing this prob in development server.
    when i am trying to check in RSA3 it is throwing same short dump
    as u said i did all the re activations still i am facing the same issue.
    please give me some other sol...
    thanks,
    srikanth Putta'

Maybe you are looking for

  • Importing P2 .mxf files with audio into AE CS4

    I hope this isn't the ultimate newbie question but, I have been working with After Effects for a few months but haven't need audio until now. Is there a different process for importing/exporting with audio? I have brought in the P2 video file but I d

  • Payment on Account and dunning run

    One of our customers demands some changes within the Business One. The support in Ireland advised us to post these requirements in this Forum. Payments on Account will not be considered in dunning runs. The customers opinion is, that these Payments h

  • Querying a Supersession Table for an HTML5/Javascript Windows Store App

    Hi Guys, I'm fairly new to SQL and am just setting up a Windows 8 app using an Azure SQL server. The issue I have is looking up a part number supersession and getting the latest number. One part number can have multiple supersessions (ie (oldest numb

  • Can't find my purchased songs anywhere

    I downloaded an album and a handful of songs this past summer, and they're no longer available to me.  Itunes shows them in my purchase history, but they're no longer on my phone or on my computer.  Thoughts?

  • Stuck in gray screen

    Im stuck in gray screen at startup with a spinning gear. Dont have a os disk, worried because i have tons of pics that are not backed up. :"O(