[CORRECTION] Optional clause in the DELETE statements.

Hello

I have always used the FROM clause in a delete statement.

Delete * from TableName.

Now I'm confused, is optional FROM?

Delete TableName is equivalent to Delete * from Tablename?

user12022313 wrote:
Hello

I have always used the FROM clause in a delete statement.

Delete * from TableName.

Now I'm confused, is optional FROM?

Yes, it is not compulsory.
>

Delete TableName is equivalent to Delete * from Tablename?

It is equivalent, but would be better coded as

TRUNCATE TABLE TableName

Tags: Database

Similar Questions

  • After updating Firefox, most of my search engine options have changed, the United States, the United Kingdom and I am unable to get the USA those back. Of course, Google does not change.

    After updating Firefox, most of my available search engines top right changed the United States to the UK (except Google I'd rather not use) versions. I'm unable to retrieve Yahoo USA or Amazon or Ebay search engines.

    The sounds that you got the version of Firefox GB with the update.

    You can download en version and uninstall the current version of en - us and install the US version.

    Download a new copy of Firefox and save the file to the desktop.

    Do NOT remove the data personal when you uninstall your current version of Firefox, because all profile files will be deleted and you will also lose your personal data such as bookmarks and passwords from other versions of Firefox profiles.

    Your bookmarks and other profile data stored in the Firefox profile folder and will not be affected by a relocation, but make sure that you do not select delete data of a personal nature if you uninstall Firefox.

  • Using arrary associative as parameter and passing then to the place where the clause of the select statement

    Hello

    I have this scenario where I have to pass multiple values to a parameter of a procedure of monkey and then collect in another variable (the lines can be multiple).

    The parameter must be used in the where clause of the statement select here I create a sample table for the problem.

    Create table test_tab (number of trans_id, cmts varchar2 (50));

    insert into test_tab values (568890112115, ' wnlb-CMTS-11-04' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-11-04' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-12-02' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-12-02' ");

    This is so all cmts have same trans_id but different name

    This query gives the result as -

    Select the cmts, count (1)

    of test_tab

    where cmts ("wnlb-cmts-11-04','wnlb-cmts-11-01", "wnlb-CMTS-11-02'")

    and trans_id = 568890112115

    Cmts group;

    COUNTY OF CMTS

    WNLB-CMTS-11-04 2

    3 WNLB-CMTS-11-01

    Now, I want to use this query in a PLSQL block like where I can spend the CMTS collection and trans_id as a scalar variable and once again an OUTPUT parameter that holds the result of the query.

    I use OUT parameter because it will be called to the JAVA program.

    Here, I write a PACKAGE for it but it gives me compilation error!

    create or replace package CMTS_SUCCESS_FAILED_API

    is

    type t_item_name is table of index varchar2 (50) by pls_integer;

    TYPE t_cmts_count () IS RENDERING

    CMTS VARCHAR2 (30),

    number of NUMBER

    );

    type t_reseg_dtl is table of index t_cmts_count by pls_integer;

    procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl);

    end CMTS_SUCCESS_FAILED_API;

    /

    Now that I have created a different PACKAGE BODY, but none don't work!

    1.

    create or replace package CMTS_SUCCESS_FAILED_API

    is

    type t_item_name is table of index varchar2 (50) by pls_integer;

    TYPE t_cmts_count () IS RENDERING

    CMTS VARCHAR2 (30),

    number of NUMBER

    );

    type t_reseg_dtl is table of index t_cmts_count by pls_integer;

    procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl);

    end;

    /

    create or replace package CMTS_SUCCESS_FAILED_API body

    is

    procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl)

    is

    Start

    I'm in p_item_name.first... p_item_name. Last

    loop

    Select the cmts, count (1)

    bulk collect into p_reseg_dtl (i)

    of test_tab

    where cmts = p_item_name (i)

    and trans_id = p_trans_id

    Cmts group;

    end loop;

    for r in p_reseg_dtl.first... p_reseg_dtl. Last

    loop

    dbms_output.put_line (p_reseg_dtl (r). TRANSACTION_ID | » '|| p_reseg_dtl (r). JOB_STATUS | » '|| p_reseg_dtl (r). CMTS);

    end loop;

    end CMTS_SUCCESS_FAILED_RESEG_ORDR;

    end CMTS_SUCCESS_FAILED_API;

    While I run this procedure it is said TOO_MANY LINES.

    2.

    create or replace package CMTS_SUCCESS_FAILED_API body

    is

    procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl)

    is

    cursor c_dtl is

    Select the cmts, count (1)

    of test_tab

    where cmts = p_item_name < < error

    and trans_id = p_trans_id

    Cmts group;

    Start

    Open c_dtl;

    collect the fetch c_dtl in bulk in p_reseg_dtl;

    close c_dtl;

    -for i in p_item_name.first... p_item_name. Last

    -loop

    -end loop;

    end;

    end;

    THIS error GIVES BODY as EXPRESSION IS OF TYPE INCORRECT for where clause where I mark it as "BOLD".

    I think Miss me a small detail to add here, but I can't do even now it seems for me that I'm working on it since the morning and SQL are a little complex in real time who also write.


    I use-

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

    Please suggest me!

    Until then I'm also working on this issue hope will find a solution.

    In the database (we show it with a standalone function, you should put it in a package):

    create or replace function CMTS_SUCCESS_FAILED_RESEG_ORDR (
      p_item_name IN SYS.DBMS_DEBUG_VC2COLL,
      p_trans_id IN number
    )
    return sys_refcursor is
      l_refcur sys_refcursor;
    begin
      open l_refcur for
        SELECT cmts , COUNT(*)
          FROM test_tab
        WHERE cmts member of p_item_name
           AND trans_id = p_trans_id
        GROUP BY cmts;
      return l_refcur;
    end CMTS_SUCCESS_FAILED_RESEG_ORDR;
    /
    

    In Java:

    import java.math.BigDecimal;
    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    import oracle.jdbc.OracleCallableStatement;
    import oracle.jdbc.OracleTypes;
    import oracle.jdbc.pool.OracleDataSource;
    import oracle.sql.ARRAY;
    import oracle.sql.ArrayDescriptor;
    
    public class SQLCollection {
    
        public static void main(String[] args) throws SQLException {
    
            System.out.println("Class SQLCollection started.");
    
            OracleDataSource ods = null;
            Connection conn = null;
            CallableStatement cs = null;
            ResultSet rset = null;
    
            try {
                ods = new OracleDataSource();
                String url = "jdbc:oracle:thin:@//127.0.0.1:1522/orcl.localdomain";
                ods.setURL(url);
                ods.setUser("stew");
                ods.setPassword("stew");
                conn = ods.getConnection();
                conn.setAutoCommit(false);
    
                ArrayDescriptor oracleVarchar2Collection =
                    ArrayDescriptor.createDescriptor("SYS.DBMS_DEBUG_VC2COLL", conn);
                String[] inset = new String[2];
                inset[0] = "wnlb-cmts-11-04";
                inset[1] = "wnlb-cmts-11-01";
                ARRAY ora_inset = new ARRAY(oracleVarchar2Collection, conn, inset);
    
                cs = conn.prepareCall("begin ? := CMTS_SUCCESS_FAILED_RESEG_ORDR(?, ?); end;");
                cs.registerOutParameter(1, OracleTypes.CURSOR);
                cs.setArray(2, ora_inset);
                cs.setBigDecimal(3, new BigDecimal("568890112115"));
                cs.execute();
    
                // Dump the cursor
                rset = ((OracleCallableStatement)cs).getCursor(1);
                while (rset.next())
                    System.out.println(rset.getString(1) + ": " + rset.getInt(2));
    
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (rset != null) {
                    rset.close();
                }
                if (cs != null) {
                    cs.close();
                }
                if (conn != null) {
                    conn.close();
                }
                System.out.println("Class SQLCollection ended.");
            }
        }
    }
    
  • How to split string separated by commas and pass to the clause of the select statement

    Referring to article How to divide string separated by commas, then pass to clause of a select statement, tquery that there the following plan:

    Query1:

    select * from emp where ename in (
        select regexp_substr('SMITH,ALLEN,WARD,JONES','[^,]+', 1, level) from dual
        connect by regexp_substr('SMITH,ALLEN,WARD,JONES', '[^,]+', 1, level) is not null );
    

    Base1:

    Plan hash value: 4242290184
    
    
    --------------------------------------------------------------------------------------------
    | Id  | Operation                       | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                |          |     1 |   133 |     7  (29)| 00:00:01 |
    |*  1 |  HASH JOIN                      |          |     1 |   133 |     7  (29)| 00:00:01 |
    |   2 |   VIEW                          | VW_NSO_1 |     1 |    46 |     3  (34)| 00:00:01 |
    |   3 |    HASH UNIQUE                  |          |     1 |       |     3  (34)| 00:00:01 |
    |*  4 |     CONNECT BY WITHOUT FILTERING|          |       |       |            |          |
    |   5 |      FAST DUAL                  |          |     1 |       |     2   (0)| 00:00:01 |
    |   6 |   TABLE ACCESS FULL             | EMP      |    14 |  1218 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------
    
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    
       1 - access("ENAME"="$nso_col_1")
       4 - filter( REGEXP_SUBSTR ('SMITH,ALLEN,WARD,JONES','[^,]+',1,LEVEL) IS NOT NULL)
    

    However, the following query generates the plan I want:

    Query2:

    select * from emp where ename in ('SMITH','ALLEN','WARD','JONES');
    

    Plan2:

    Plan hash value: 3956160932
    
    
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |     4 |   348 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |     4 |   348 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------
    
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    
       1 - filter("ENAME"='ALLEN' OR "ENAME"='JONES' OR "ENAME"='SMITH' OR
                  "ENAME"='WARD')
    

    Can I change the query1 query for plan2?

    As Juliet was mentioned in the first SQL that you generate from the ENAME list that you must pass in the IN clause when executing. But in the second SQL, it passed as a static value. So first SQL must do more work. So you see a different execution plan.

    But this is a work around to get what you are looking for. But I can't say it's a foolproof method. But anyway here you go.

    SQL > var ename_list varchar2 (100)
    SQL > exec: ename_list: = 'SMITH, ALLEN, WARD, JONES ';

    PL/SQL procedure successfully completed.

    SQL > select *.
    2 of PEM
    where the 3 «,» | : ename_list | ',' like '%', | Ename | ',%';

    EMPNO, ENAME, JOB HIREDATE DEPTNO ID COM SAL MGR
    ---------- ------ --------- ---------- --------- ---------- ---------- ---------- ----------
    7369 SMITH COMMITTED 7902 2975 2 APRIL 81 0 20
    7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30
    7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30
    7566 JONES MANAGER 7839 2975 2 APRIL 81 0 20

    SQL > select * from table (dbms_xplan.display_cursor);

    PLAN_TABLE_OUTPUT
    -------------------------------------------------------------------------------------------------------
    SQL_ID, 848zhvbvgf7d6, number of children 0
    -------------------------------------
    Select * from emp where «,» | : ename_list | ',' like '%', | Ename
    || ',%'

    Hash value of plan: 2872589290

    --------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      |       |       |     2 (100) |          |
    |*  1 |  TABLE ACCESS FULL | EMP |     1.    38.     2 (0) | 00:00:01 |
    --------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    1 - filter(','||:ENAME_LIST||',' LIKE '%,'||") ENAME "|", %')

    19 selected lines.

    SQL >

  • Session variable in the WHERE clause of the SQL statement

    Hey all,.

    I was wonering just if there is a way to set the WHERE clause of the query that the session variable?  I have the following so far and have tried to go through a ton of tutorials, but it doesn't seem to work.  Is it still possible?  I don't know what follows is wrong, but can someone help me with changing the following code, or pointing me to a good tutorial?  (I write it with PHP)

    $query = "SELECT * from members where user_id = ' $_SESSION ['members']";

    Thanks for your help.

    $member = "-1";
    If (isset($_SESSION['members'])) {}
    $member = $_SESSION ['members'];

    }
    $query = "SELECT * from members where user_id = $member;

  • How to use FOLLOW-UP and COMPRESS the clause of the CREATE statement TABLE?

    my oracle's 10g and the statement of create table below:

    CREATE TABLE S005.q100

    (

    Q1 tank (1)

    )

    NOMONITORING;

    After you create this table, I ask USER_TABLES, but the value of the follow-up column is YES.

    I think there should be no how is? and also I have the same problem with the COMPRESS.

    Thank you very much


    Hello

    Heap - organized tables are your usual routine tables. It is created using the BUNCH of the ORGANIZATION of the CREATE TABLE statement clause. This is the default value.

    The other variant of this clause is ORGANIZATION INDEX, which means that you will create an organized Index of Table. In other words, it is a table that is stored in a B-tree, like an index.

    You also have an EXTERNAL BODY, which means that you will create an external table. Here is generally flat files outside of the database that you can order the database to see tabular to use SQL (read only) against. You will also need the settings on how the data are presented on the file, so that your database knows which column will match that of the data.

    The COMPRESS on 10G is known as the "basic compression" and it works on ordinary table segment blocks, which are organized by a bunch of tables.

  • Optional parameter in the Select statement.

    Hello

    Could you let me know on below, I want to make the optional parameter, the user could pass a value or not.

    Select *.

    of dovur_ert

    where model_line_number =: model

    and item = nvl (:, 1 );

    Thank you

    Select *.

    of dovur_ert

    where model_line_number =: model

    and item = nvl (:, point);

  • Conditional clause in the select statement

    Hi all
    Suppose for example of diagram of HR that I have the following query where it counts the number of Department based on their identity papers and the total number of jobs:
    SQL> select decode(grouping(job_id),1,'total_job',job_id) as JobID, decode(group
    ing(department_id),1,'all_department',department_id) as DepartmentID, count(*) f
    rom employees group by rollup(job_id,department_id) order by job_id,department_i
    d;
    
    JOBID      DEPARTMENTID                               COUNT(*)
    ---------- ---------------------------------------- ----------
    AC_ACCOUNT 110                                               1
    AC_ACCOUNT all_department                                    1
    AC_MGR     110                                               1
    AC_MGR     all_department                                    1
    AD_ASST    10                                                1
    AD_ASST    all_department                                    1
    AD_PRES    90                                                1
    AD_PRES    all_department                                    1
    AD_VP      90                                                2
    AD_VP      all_department                                    2
    FI_ACCOUNT 100                                               5
    
    JOBID      DEPARTMENTID                               COUNT(*)
    ---------- ---------------------------------------- ----------
    FI_ACCOUNT all_department                                    5
    FI_MGR     100                                               1
    FI_MGR     all_department                                    1
    HR_REP     40                                                1
    HR_REP     all_department                                    1
    IT_PROG    60                                                5
    IT_PROG    all_department                                    5
    MK_MAN     20                                                1
    MK_MAN     all_department                                    1
    MK_REP     20                                                1
    MK_REP     all_department                                    1
    
    JOBID      DEPARTMENTID                               COUNT(*)
    ---------- ---------------------------------------- ----------
    PR_REP     70                                                1
    PR_REP     all_department                                    1
    PU_CLERK   30                                                5
    PU_CLERK   all_department                                    5
    PU_MAN     30                                                1
    PU_MAN     all_department                                    1
    SA_MAN     80                                                5
    SA_MAN     all_department                                    5
    SA_REP     80                                               29
    SA_REP                                                       1
    SA_REP     all_department                                   30
    
    JOBID      DEPARTMENTID                               COUNT(*)
    ---------- ---------------------------------------- ----------
    SH_CLERK   50                                               20
    SH_CLERK   all_department                                   20
    ST_CLERK   50                                               20
    ST_CLERK   all_department                                   20
    ST_MAN     50                                                5
    ST_MAN     all_department                                    5
    total_job  all_department                                  107
    
    40 rows selected.
    The total number of global jobs regardless of which Department is 107. Question: How to make a query that displays the result above and makes the JOBID and DEPARTMENTID column value to two TotalAgregate where the count indicates 107? Like this:
    JOBID      DEPARTMENTID                               COUNT(*)
    ---------- ---------------------------------------- ----------
    AC_ACCOUNT 110                                               1
    AC_ACCOUNT all_department                                    1
    AC_MGR     110                                               1
    AC_MGR     all_department                                    1
    AD_ASST    10                                                1
    AD_ASST    all_department                                    1
    AD_PRES    90                                                1
    AD_PRES    all_department                                    1
    AD_VP      90                                                2
    AD_VP      all_department                                    2
    FI_ACCOUNT 100                                               5
    
    JOBID      DEPARTMENTID                               COUNT(*)
    ---------- ---------------------------------------- ----------
    FI_ACCOUNT all_department                                    5
    FI_MGR     100                                               1
    FI_MGR     all_department                                    1
    HR_REP     40                                                1
    HR_REP     all_department                                    1
    IT_PROG    60                                                5
    IT_PROG    all_department                                    5
    MK_MAN     20                                                1
    MK_MAN     all_department                                    1
    MK_REP     20                                                1
    MK_REP     all_department                                    1
    
    JOBID      DEPARTMENTID                               COUNT(*)
    ---------- ---------------------------------------- ----------
    PR_REP     70                                                1
    PR_REP     all_department                                    1
    PU_CLERK   30                                                5
    PU_CLERK   all_department                                    5
    PU_MAN     30                                                1
    PU_MAN     all_department                                    1
    SA_MAN     80                                                5
    SA_MAN     all_department                                    5
    SA_REP     80                                               29
    SA_REP                                                       1
    SA_REP     all_department                                   30
    
    JOBID      DEPARTMENTID                               COUNT(*)
    ---------- ---------------------------------------- ----------
    SH_CLERK   50                                               20
    SH_CLERK   all_department                                   20
    ST_CLERK   50                                               20
    ST_CLERK   all_department                                   20
    ST_MAN     50                                                5
    ST_MAN     all_department                                    5
    TotalAgregate  TotalAgregate                                107
    
    40 rows selected.
    Best regards
    Valerie

    I do not have the HR schema to play with, but isn't it just a nested decode it takes?

    for example something like...

    select decode(grouping(job_id),1,'TotalAggregate',job_id) as JobID
          ,decode(grouping(department_id),1,decode(grouping(job_id),1,'TotalAggregate','all_department'),department_id) as DepartmentID
          ,count(*)
    from employees
    group by rollup(job_id,department_id)
    order by job_id,department_id;
    
  • Can I use truncated and where clause in the statement even?

    Hello guys,.

    Can I use truncated with where clause in the same statement.


    For ex:

    TRUNCATE TABLE my_table WHERE id < 500;

    If not, that you recommend me to overtemperature to the level of high water line?


    By the way
    select * from v$version;
    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    "CORE 11.2.0.1.0 Production."
    AMT for 64-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    >

    Thank you very much.

    Published by: 970992 on 11:14 13.Ara.2012

    >
    Okay I need an increasing amount of space. However, at the same time I want to recover the spaces empty below HWM. So, I need to use less amount of space I am inserting. Therefore, shouldn't use retractable for this?
    >
    Why waste the effort. Oracle will reuse the space below the HWM when doing inserts. You already said that you insert more lines you delete so all these will be more accustomed to the top.

    The only time where that oracle may not use space is when the space is too small to be useful. It is documented in the doc, I told you
    >
    Understanding recoverable unused space
    Over time, Update, and Delete on objects within a tablespace can create pockets of empty space that individually are not large enough to be reused for the new data.
    >
    Most uses of CONTRACTION I've seen are totally useless. If you follow the doc and run the Advisor of segment it will tell you if there is space that can be retrieved and how much. But, even once, for your use even if case will get you will Oracle while you need to reassign the new extensions, then the HWM will just go still higher.

    If pay you a heavy price in Oracle did a full table scan, update of many blocks from the table, update THE index, impact performance for other users to access the table during the SHRINK and reallocate extensions (maybe even some of the same areas) when you insert more data.

    Do not SHRINK unless you know it's necessary.

  • Question about the transition from string values to the Partition clause in a merge statement

    Hi all

    I use the code to update the data of specific secondary partition using oracle merge statements below.

    I'm getting the name of the secondary partition and pass this string to the secondary partition clause.

    The Merge statement is a failure, indicating that the specified secondary partition does not exist. But the partition under do exists for the table.

    We use a server Oracle 11 GR 2.

    Here is the code I use to fill in the data.

    declare
    ln_min_batchkey PLS_INTEGER;
    ln_max_batchkey PLS_INTEGER;
    lv_partition_name VARCHAR2 (32767).
    lv_subpartition_name VARCHAR2 (32767).
    Start

    FOR m1 IN (SELECT (year_val + 1) AS year_val, year_val AS orig_year_val)
    FROM (SELECT DISTINCT
    To_char (batch_create_dt, 'YYYY') year_val
    OF stores_comm_mob_sub_temp
    ORDER BY 1)
    ORDER BY year_val)
    LOOP
    lv_partition_name: =.
    () scmsa_handset_mobility_data_build.fn_get_partition_name
    nom_table_p = > 'STORES_COMM_MOB_SUB_INFO ',.
    p_search_string = > m1.year_val);

    FOR m2
    IN (SELECT DISTINCT
    'M' || To_char (batch_create_dt, 'MM') AS month_val
    OF stores_comm_mob_sub_temp
    WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val)
    LOOP
    lv_subpartition_name: =.
    () scmsa_handset_mobility_data_build.fn_get_subpartition_name
    nom_table_p = > 'STORES_COMM_MOB_SUB_INFO ',.
    p_partition_name = > lv_partition_name,
    p_search_string = > m2.month_val);

    DBMS_OUTPUT. Put_line (' lv_subpartition_name = > ' | lv_subpartition_name |' and lv_partition_name = > ' | lv_partition_name);

    IF lv_subpartition_name IS NULL
    THEN
    DBMS_OUTPUT. Put_line ("to the INTERIOR of FI = > ' |") M2.month_val);
    INSERT INTO STORES_COMM_MOB_SUB_INFO (T1)
    T1.ntlogin,
    T1.first_name,
    T1.last_name,
    T1.job_title,
    T1.store_id,
    T1.batch_create_dt)
    SELECT t2.ntlogin,
    T2.first_name,
    T2.last_name,
    T2.job_title,
    T2.store_id,
    T2.batch_create_dt
    OF stores_comm_mob_sub_temp t2
    WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val
    AND'M '. To_char (batch_create_dt, 'MM') =
    M2.month_val;
    ELSIF lv_subpartition_name IS NOT NULL
    THEN
    DBMS_OUTPUT. Put_line (' INSIDE ELSIF = > ' | m2.month_val);
    MERGE (SELECT *)
    OF stores_comm_mob_sub_info
    SUBPARTITION (lv_subpartition_name)) T1
    USING (SELECT *)
    OF stores_comm_mob_sub_temp
    WHERE TO_CHAR (batch_create_dt, 'YYYY') =
    M1.orig_year_val
    AND'M '. To_char (batch_create_dt, 'MM') =
    M2.month_val) T2
    WE (T1.store_id = T2.store_id
    AND T1.ntlogin = T2.ntlogin)
    WHEN MATCHED
    THEN
    GAME UPDATE
    T1.postpaid_totalqty =
    (NVL (t1.postpaid_totalqty, 0))
    (+ NVL (t2.postpaid_totalqty, 0));
    T1.sales_transaction_dt =
    LARGEST)
    NVL (t1.sales_transaction_dt,
    T2.sales_transaction_dt),
    NVL (t2.sales_transaction_dt,
    T1.sales_transaction_dt)),
    T1.batch_create_dt =
    LARGEST)
    NVL (t1.batch_create_dt, t2.batch_create_dt),
    NVL (t2.batch_create_dt, t1.batch_create_dt))
    WHEN NOT MATCHED
    THEN
    INSERT (t1.ntlogin,
    T1.first_name,
    T1.last_name,
    T1.job_title,
    T1.store_id,
    T1.batch_create_dt)
    VALUES (t2.ntlogin,
    T2.first_name,
    T2.last_name,
    T2.job_title,
    T2.store_id,
    T2.batch_create_dt);
    END IF;
    END LOOP;
    END LOOP;

    COMMIT;

    end;
    /



    Really appreciate your input here.

    Thank you
    MK.

    Hello

    You can use "immediate execution" what works.

    Thank you

  • Preserve the default state and the link using cookies

    Hello

    I don't know where to post this with the re-design of this forum; It has been a while so please forgive me if this is in the wrong g spot.

    I have a very basic link, wrapped in a UL tag.

    I use JQuery to give links a color when they are clicked by performing a function Add/Remove class, the status of the connection is more preserved by cookies so if a user returns to a page; It shows which tab they were viewing.

    The problem is; It is a single page and I want to set a default link or tab; say one. I don't know how to do this.

    That's what I'm looking for to accomplished:

    1. A user accesses the page and the first link is red (default)
    2. If the user clicks another link that the link is active and the first link loses its default status
    3. When the user returns the first link is nolonger by default, that's all that bind the selected user on first visit; This is because this link was Micaela using cookies.
    4. The first link will ONLY maintain the State by default, if the user deletes his cookies or visits to the page for the first time.

    Here's a piece of JQuery, I used to maintain the selected state:

    {$(document) .ready (function ()}

    var idActive = $.cookie ('cookieActive');

    If {(idActive)

    $('#'_+_idActive).addClass ('activeLink');

    }

    $('_ul_li_a').click (function () {}

    ID var = $(this) .attr ('id');

    $("ul_li_a").removeClass ("activeLink");

    $(this) .addClass ("activeLink");

    $('cookieActive', id) .cookie.

    $.cookie('cookieactive', id, {expires: 10000});

    });

    });

    I guess your jQuery works the way you want, and the only problem is how to define the default value.

    In this case, give your default link an ID, such as "default". Then add an else clause of the conditional statement in your jQuery:

    If {(idActive)

    $('#'_+_idActive).addClass ('activeLink');

    } else {}

    $('#default').addClass ('activeLink');

    }

  • an INTO clause in this SELECT statement

    Hello

    This query is to start an error, an INTO clause in the SELECT statement. I have a line in my table

    DECLARE

    TNom VARCHAR (100);

    BEGIN

    Select tNom under Tnom in t_conf where Tna = 'Home';

    If instr (tNom, 'living room') > 0

    then return true;

    otherwise return false;

    end if;

    END;

    DECLARE

    v_Tname VARCHAR (100);

    BEGIN

    Select Tname in v_Tname t_conf where Tna = 'Home';

    If instr (v_Tname, "living room") > 0

    then return true;

    otherwise return false;

    end if;

    END;

  • Need help to set a DELETE statement.

    I have a table that contains the records of files. Files come in a bouquet each week. So, we need to delete records from a table to the corresponding fields and load the table with up-to-date data.

    In doing so, the DELETE statement takes a long time. Need help with this setting.

    Here are the details.

    (1) total number of records in the table: 23 million records.
    (2) approximate records deleted each time: 500 K to 1.5 million.
    (3) table is partitioned on a PERIOD key. That is, each partition will have the data for a given period.
    (4) table is not indexed
    (5) removal occurs on a combination of 2 fields (PERIOD + BATCH).

    Here is the query and the plan:

    ===========================================================

    SQL > EXPLAIN PLAN SET STATEMENT_ID = 'TSH' FOR
    2 REMOVE / * + PARALLEL(DETAIL_UNKNOWN,10) * / u DETAIL_UNKNOWN
    3 WHERE u.FLBATCHID = 'PCAFRINTERMAR1105' AND u.N_PER6 = 201214
    4;

    He explained.

    SQL > SET LINESIZE 130
    SQL > SELECT * FROM TABLE (DBMS_XPLAN. DISPLAY ('PLAN_TABLE', 'TSH', 'ALL'));

    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------
    Hash value of plan: 2400300449

    ----------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |
    ----------------------------------------------------------------------------------------------------
    | 0 | DELETE STATEMENT. 596K | 12 M | 838 (9) | 00:00:12 |
    | 1. REMOVE | DETAIL_UNKNOWN |
    | 2. SIMPLE HASH PARTITION | 596K | 12 M | 838 (9) | 00:00:12 | 6. 6.
    |* 3 | TABLE ACCESS FULL | DETAIL_UNKNOWN | 596K | 12 M | 838 (9) | 00:00:12 |
    ----------------------------------------------------------------------------------------------------


    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------
    Name of the query block / Alias object (identified by the operation identity card):
    -------------------------------------------------------------

    1 LED$ 1
    3 LED$ 1 / U@DEL$1

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    3 - filter("U".") FLBATCHID '= 'PCAFRINTERMAR1105' AND 'U'." N_PER6 "= 201214)


    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------
    Projection of the column information (identified by the operation identity card):
    -----------------------------------------------------------

    2 - (cmp = 2, 3) "U". ROWID [ROWID, 10], "U". "N_PER6" [NO.22], 'U' "." " FLBATCHID ' [VARCHAR2, 20].
    3 - « U ». ROWID [ROWID, 10], "U". "N_PER6" [NO.22], 'U' "." " FLBATCHID ' [VARCHAR2, 20].

    27 selected lines.

    ===========================================================

    Need your suggestions on how the query / table can be tuned.

    Hi Anand,

    I wanted to check why your tkprof Watch report two executions of the statement:

    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Execute      2   2315.71    2480.17          0       3351     624489      611765
    

    In fact, it there was only a single execution of the DELETE statement. The trace file begins with a call EXEC of any statement without call analysis

    *** TRACE DUMP CONTINUED FROM FILE XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_ora_241708.trc ***
    
    EXEC #1:c=20000,e=13996,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=32472879711702
    =====================
    PARSING IN CURSOR #2 len=68 dep=0 uid=72 oct=42 lid=72 tim=32472883567994 hv=740818757 ad='0'
    ...
    

    TKProf aggregates this EXEC call with call EXEC of the DELETE statement because they have the same location of cursor (#1), he thinks it was the same cursor.

    PARSING IN CURSOR #1 len=93 dep=0 uid=72 oct=7 lid=72 tim=32472889974030 hv=1242910589 ad='e5979d80'
    DELETE from detail_unknown where n_per6 = 201214 and FLBATCHID = 'PCAFRINTERMAR1105'
    END OF STMT
    PARSE #1:c=0,e=11462,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=32472889974024
    ...
    EXEC #1:c=2315710000,e=2480213492,p=0,cr=3691,cu=624489,mis=0,r=611765,dep=0,og=1,tim=32475370187626
    

    So, the question about two executions is closed - there was only a single run.

    The performance - 2315,71 seconds of time processor is absolutely huge for such amount of work. It looks like a bug.

    First, I propose to check the time without compression. If your environment allows this kind of testing try to decompress the partition and re - run on unpacking data DELETION.
    10.2 find the name of the partition

    select partition_name
      from dba_tab_partitions
     where table_name = 'DETAIL_UNKNOWN'
       and partition_position = 6
    

    After that

    alter table DETAIL_UNKNOWN modify partition  nocompress;
    alter table DETAIL_UNKNOWN move partition ;
    

    and run again the button DELETE.

    What is the operating system on the server?

  • check for the delete operation

    Hi all

    I'm a deletion of a table. How can I check if the removal of deleted rows?

    Thanks in advance
    BN

    I'm guessing that you want to check SQL ROWCOUNT % immediately after the DELETE statement (if you are not in a PL/SQL block when you issue DELETE it, your API client probably has a different appeal for this information).

    BEGIN
      DELETE FROM some_table
       WHERE some_column = some_value;
    
      IF( SQL%ROWCOUNT = 0 )
      THEN
        dbms_output.put_line( 'No rows were deleted' );
      ELSE
        dbms_output.put_line( 'We deleted some rows' );
      END IF;
    END;
    

    Justin

  • DEADLOCK DETECTED - DELETE statement - how/why he expects in SHARING mode?

    Hello

    I wonder if anyone can advise here. The environment is:

    Microsoft Windows 2003 Server
    Standard Oracle 10.2.0.4 Edition

    We had a deadlock detected in our application on a customer site - I enclose the corresponding part of the trace file below. While we think we have found the reason for the deadlock (looks like it is due to a foreign key in cascade), I'm confused as the lock mode that is requested.

    Here is the track information:
    Deadlock graph:
                           ---------Blocker(s)--------  ---------Waiter(s)---------
    Resource Name          process session holds waits  process session holds waits
    TX-00120012-00003b59        28     475     X             29     481           S
    TX-000a0029-0003508b        29     481     X             28     475           X
    session 475: DID 0001-001C-000F96B0     session 481: DID 0001-001D-00000079
    session 481: DID 0001-001D-00000079     session 475: DID 0001-001C-000F96B0
    Rows waited on:
    Session 481: no row
    Session 475: obj - rowid = 00014625 - AAAUYlAAIAAAAawAAo
      (dictionary objn - 83493, file - 8, block - 1712, slot - 40)
    Information on the OTHER waiting sessions:
    Session 481:
      pid=29 serial=18261 audsid=202192707 user: 51/info
      O/S info: user: SYSTEM, term: our_term, ospid: 5244:940, machine: our_machine
                program: our_exe.exe
      client info: GUI
      application name: app, hash value=3864155245
      action name: our_action, hash value=3631189430
      Current SQL Statement:
      DELETE FROM TABLE_1 T WHERE T.T_ID = :B1
    End of information on OTHER waiting sessions.
    Current SQL statement for this session:
    UPDATE TABLE_1 T SET T.STATUS_ID = :B2 WHERE T.T_ID = :B1 
    It seems to me like session * 481 * trying to do a deletion when the block is raised:
     DELETE FROM TABLE_1 T WHERE T.T_ID = :B1
    and ask which mode (dynamique31) S .
                                       ---------Blocker(s)--------  ---------Waiter(s)---------
    Resource Name          process session holds waits  process session holds waits
    TX-00120012-00003b59        28     475     X             29     481           S
    (also the 'no line' for lines didn't wait)
    Session 481: no row
    I thought it would be in mode (e) X (clusive) (for the line being deleted). Actually Yes, I set up a test of fast and simple locking and mode (e) X (is) expected the final delete .

    So, am I misinterpreted the tracing information, or is the DELETE statement requesting the lock in mode S (Hare)? If this is the case, I'd appreciate a quick explanation of how/why it's...



    Kind regards

    ADOS

    I think we have almost the same reason to wait in S mode as in [single key application | http://books.google.pl/books?id=14OmJzfCfXMC&dq=oracle+wait+interface+practical+guide&q=unique+key+enforcement].
    If two sessions want to insert the same key value, the other must wait, because the outcome depends on a commit / rollback of the first session. In the case of validation, session 2 must generate an error in case of cancellation, it must insert his record.

    In the test provided by ADOS, at session 1 there is an insert in session 2 - delete. The result of the delete operation depends, once again, commit or rollback in the first session. In the case of validation, it must remove, and cancellations, there is nothing to remove.

    If the insert in session 1 has been replaced by the Update, there is no S lock but 'normal' eXclusive

    Bartek

Maybe you are looking for

  • Music: Why the Star Ratings went?

    Apple, I was using iTunes since 1.0 and music from Apple since the first iPod players. The main way I sort my music is by assessing all my songs, so I can quickly make playlists based on songs of five stars (for example). I often listen to playlists

  • Time capsule assigned IP but no internet

    I'm in a two-story house where the wireless network may not extend between the upper and lower floors, so I bought an additional TC A1470 in addition to my express A1392 to connect via ethernet cable from 25 meters from my router upstairs. When I han

  • advice antivirus

    Hello I have an itsa windows vista computer and Im having problems mind virus can give u me more information, where can I go to download free antivurus so tat my computer can get cleaned up please I really need your advice and so your answer

  • error message in a loading module

    error: c:\users\wendy\appdata\local\nlabvbor.dll This module is not found.

  • Windows Defender won't start does not automatically, it's because I use AVG anti-virus software?

    I recently downloaded the free version of AVG v.9, which seems to work very well. However Windows Defender no longer seems work fine, normally this is an error message saying that it does not work and I have to manually start even if I set it to star