Using the HAVING clause

I have trouble understanding the following query:

SELECT cust_city, COUNT (cust_last_name)

Customers

WHERE cust_credit_limit > 1000

GROUP BY cust_city

HAVING AVG (cust_credit_limit) BETWEEN 5000 AND 6000

According to my preparation for the review, it will work successfully without errors, although I don't understand why.

The AVG (cust_credit_limit) should also be included in with the rest of the fields to make it work correctly?

It would be greatly appreciated if someone could explain it to me better.

Thank you

Sean

5285cd35-2ff3-432e-B2FD-19285481be60 wrote:

I have trouble understanding the following query:

SELECT cust_city, COUNT (cust_last_name)

Customers

WHERE cust_credit_limit > 1000

GROUP BY cust_city

HAVING AVG (cust_credit_limit) BETWEEN 5000 AND 6000

According to my preparation for the review, it will work successfully without errors, although I don't understand why.

The AVG (cust_credit_limit) should also be included in with the rest of the fields to make it work correctly?

It would be greatly appreciated if someone could explain it to me better.

Thank you

Sean

No - the AVG function doesn't have to be in the select list. Explain why you think it should be.

How would it make a difference if you added to the SELECTION list and ignored, then?

When you have questions DOC the first thing you need to do is RTFM. See the HAVING clause in the RFSO of the SQL language

http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_10002.htm

>

HAVING clause

Use of the HAVING clause to restrict groups of returns of the lines to these groups for which the specified condition is TRUE .

>

As the doc t says

He HAVING condition applies to the 'groups '.

If you use the HR. EMPLOYEES table you can see the effect of the HAVING clause. This query is similar to yours but with none HAVING clause, and the AVG (salary) added to the selection list to see which groups will have

>

Select department_id, count (last_name), avg (salary)
employees
where salary > 500
Group by department_id

  1. DEPARTMENT_ID, COUNT (LAST_NAME), AVG (SALARY)
  2. 10,1,4400
  3. 20,2,9500
  4. 30,6,4150
  5. 40,1,6500
  6. 50,45,3475.55555555556
  7. 60,5,5760
  8. 70,1,10000
  9. 80,34,8955.88235294118
  10. 90,3,19333.3333333333
  11. 100,6,8601.33333333333
  12. 110,2,10154
  13. 1,7000

>

Note that 60 is the ONLY group with AVG (salary) between 5000 and 6000

Now, try the query using the HAVING clause

>

Select department_id, count (last_name)

employees

where salary > 500

Group by department_id

having avg (salary) between 5000 and 6000

DEPARTMENT_ID, COUNT (LAST_NAME)

60.5

>

Only group 60 has been selected - the HAVING condition has been applied to the first query GROUPS, not the lines.

Tags: Database

Similar Questions

  • How to generate the HAVING clause?

    Hi all

    When I add a function like the SUM, the code generates the "group by" clause by default. I also want to generate the clause "have" about it, how to do this in ODI?

    -Ian.

    Hello

    In your interface drag and drop the source column in the Web for which you want to generate the HAVING clause.
    It will create filters for columns. Now use the aggregation works like SUM, MIN, MAX, AVG etc. in this filter query.

    The generated code will now contain the inside HAVING clause.

    Thank you
    Fati

  • Query with the having clause

    Hi all

    I have this select statement to help to filter different from zero records.

    Select GroupName, Nom_liste,

    Sum ((a_cost/1000) * degradation * quantity * total_count * index) such as total_cost,.

    FROM MyTable

    having sum ((a_cost/1000) * degradation * quantity * total_count * index) <>0

    Group GroupName, Nom_liste

    Having done so the query to run more slowly.

    How can I filter records with zero total_cost (they can be negative or greater than zero).

    Thank you!

    Hello

    user9542267 wrote:

    Hi all

    I have this select statement to help to filter different from zero records.

    Select GroupName, Nom_liste,

    Sum ((a_cost/1000) * degradation * quantity * total_count * index) such as total_cost,.

    FROM MyTable

    having sum ((a_cost/1000) * degradation * quantity * total_count * index) <> 0

    Group GroupName, Nom_liste

    Having done so the query to run more slowly.

    How can I filter records with zero total_cost (they can be negative or greater than zero).

    Thank you!

    The query you posted should not take more time with or without the HAVING clause.  The right of the comma before 'from' causes a compilation error very quickly anyway.

    If you get no result other than an error message, then this is not the code you are running.  Show the code you actually run, or a simplified version that has the same problem.

    For all performance issues, see the FAQ forum:

    https://community.Oracle.com/message/9362003#9362003

    If the problem was really in the HAVING clause, then you can try something like this:

    WITH got_total_cost AS
    (
    SELECT GroupName, Nom_liste
    , SUM ((a_cost/1000) * degradation * quantity * total_count * index) SUCH as total_cost
    FROM MyTable
    GROUP BY GroupName, Nom_liste
    )
    SELECT *.
    OF got_total_cost
    WHERE as total_cost <> 0
    ;

    but it would be very surprising he made all the difference.  I suspect that the problem is not really in the HAVING clause.

  • using the WITH Clause

    The sql statement is

    Select ename, job
    from emp, dept
    where emp.deptno = dep.deptno
    and emp.deptno = 10
    Union
    Select ename, job
    from emp, dept
    where emp.deptno = dep.deptno
    and emp.deptno = 20

    the statement above using the WITH Clause

    WITH dept10 AS
    (select ename, job, hiredate, sal, comm, dname, emp.deptno
    from emp, dept
    where emp.deptno = dept.deptno
    and emp.deptno = 10)
    dept20 AS
    (select ename, job, hiredate, sal, comm, dname, emp.deptno
    from emp, dept
    where emp.deptno = dept.deptno
    and emp.deptno = 20)
    SELECT *.
    OF dept10
    UNION
    SELECT *.
    OF dept20

    Correct me if I'm wrong...

    Thank you

    Hello

    SeenuGuddu wrote:
    the Question is how u would provide the statement above by using the Clause

    The answer is that the question is meaningless. You will not use a WITH clause for this work.

    Because you must use a WITH clause to get the same results as the first query, I think the best way would be:

    WITH     unnecessary_sub_query     AS
    (
         select DISTINCT
                    ename, job
    --     ,      hiredate, sal, comm, dname,emp.deptno     -- these columns are not in the original query
         from      emp
         ,      dept
         where      emp.deptno = dept.deptno
         and      emp.deptno IN (10, 20)
    )
    SELECT  *
    FROM     unnecessary_sub_query;
    

    is this correct using Clause WITH or correct me

    No, it's not ok to make queries more complex or slow they need to do.
    In addition to the extra columns, it seems that the second query that you posted (the one who has a WITH clause) produces the same results as the first request.

  • Use the nologging clause

    Hi, I tried to use the nologging clause to improve the performance of DML on one of the table. However I have observed this table with nologging option actually decreases performance :(
    Please see the next newspaper.

    SQL > create table test_log (int id, name char (40))
    2.

    Table created.

    Elapsed time: 00:00:00.03
    SQL > create table test_nolog (int id, name char (40)) nologging
    2.

    Table created.

    Elapsed time: 00:00:00.00
    SQL > insert into test_log select ROWNUM *-1, DBMS_RANDOM. String('A',1) FROM DUAL CONNECT BY LEVEL < = 1000000
    2.

    1000000 rows created.

    Elapsed time: 00:00:13.46
    SQL > insert into test_nolog select ROWNUM *-1, DBMS_RANDOM. String('A',1) FROM DUAL CONNECT BY LEVEL < = 1000000
    2.

    1000000 rows created.

    Elapsed time: 00:00:16.95
    SQL > update test_log set id = 100
    2.

    1000000 lines to date.

    Elapsed time: 00:00:46.35
    SQL > update test_nolog set id = 100
    2.

    1000000 lines to date.

    Elapsed time: 00:00:49.43

    Insert and update have no impact if the tables are created with the NOLOGGING clause or logging

    It generates the same amount of redo for insert and UPDATE stmts stmts

    NOLOGGING can help for the following things

    1 CTAS
    2.SQL * loader in direct mode
    3. INSERT / * + APPEND * /...

    SYSTEM@rman 15/12/2008> truncate table  test_log;
    
    Table truncated.
    
    Elapsed: 00:00:01.49
    SYSTEM@rman 15/12/2008> truncate table test_nolog;
    
    Table truncated.
    
    Elapsed: 00:00:00.67
    SYSTEM@rman 15/12/2008> insert into test_nolog select ROWNUM*-1,DBMS_RANDOM.STRING('A',1) FROM DUAL CONNECT BY LEVEL <=1000000;
    
    1000000 rows created.
    
    Elapsed: 00:00:39.80
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1731520519
    
    ------------------------------------------------------------------------------
    | Id  | Operation                     | Name | Rows  | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------
    |   0 | INSERT STATEMENT              |      |     1 |     2   (0)| 00:00:01 |
    |   1 |  COUNT                        |      |       |            |          |
    |*  2 |   CONNECT BY WITHOUT FILTERING|      |       |            |          |
    |   3 |    FAST DUAL                  |      |     1 |     2   (0)| 00:00:01 |
    ------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter(LEVEL<=1000000)
    
    Statistics
    ----------------------------------------------------------
           3081  recursive calls
          41111  db block gets
           8182  consistent gets
              0  physical reads
       60983504  _redo size_
            674  bytes sent via SQL*Net to client
            638  bytes received via SQL*Net from client
              3  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
        1000000  rows processed
    
    SYSTEM@rman 15/12/2008> commit;
    
    Commit complete.
    
    Elapsed: 00:00:00.03
    SYSTEM@rman 15/12/2008> insert into test_log select ROWNUM*-1,DBMS_RANDOM.STRING('A',1) FROM DUAL CONNECT BY LEVEL <=1000000;
    
    1000000 rows created.
    
    Elapsed: 00:00:38.79
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1731520519
    
    ------------------------------------------------------------------------------
    | Id  | Operation                     | Name | Rows  | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------
    |   0 | INSERT STATEMENT              |      |     1 |     2   (0)| 00:00:01 |
    |   1 |  COUNT                        |      |       |            |          |
    |*  2 |   CONNECT BY WITHOUT FILTERING|      |       |            |          |
    |   3 |    FAST DUAL                  |      |     1 |     2   (0)| 00:00:01 |
    ------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter(LEVEL<=1000000)
    
    Statistics
    ----------------------------------------------------------
           3213  recursive calls
          41323  db block gets
           8261  consistent gets
              2  physical reads
       60993120  _redo_ size
            674  bytes sent via SQL*Net to client
            636  bytes received via SQL*Net from client
              3  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
        1000000  rows processed
    
    SYSTEM@rman 15/12/2008> commit;
    

    They simply generate the same anount of redo

    If you use hint APPEND, you can reduce the timings of INSERT stmt

    SYSTEM@rman 15/12/2008> truncate table test_nolog;
    
    Table truncated.
    
    Elapsed: 00:00:00.28
    SYSTEM@rman 15/12/2008> INSERT /*+ APPEND */ into test_nolog select ROWNUM*-1,DBMS_RANDOM.STRING('A',1) FROM DUAL CONNECT BY LEVEL <=100
    
    1000000 rows created.
    
    Elapsed: 00:00:28.19
    
    Execution Plan
    ----------------------------------------------------------
    ERROR:
    ORA-12838: cannot read/modify an object after modifying it in parallel
    
    SP2-0612: Error generating AUTOTRACE EXPLAIN report
    
    Statistics
    ----------------------------------------------------------
           3125  recursive calls
           8198  db block gets
            929  consistent gets
              0  physical reads
         161400  redo size
            660  bytes sent via SQL*Net to client
            652  bytes received via SQL*Net from client
              3  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
        1000000  rows processed
    
    SYSTEM@rman 15/12/2008> 
    

    You can also view time significant difference/redo generated between INSERT and INSERT with append on a table NOLOGGING

  • Cannot use the command clause contained in the posting online of a cursor

    Dear people,
    I use Oracle 10 g with forms 6i. I had a requirement where I gotto choose the latest ten records and view the sorting in the opposite order.say for ex.
    Cursor C is select * from (select ename,sal from emp order by sal desc) where rownum<=10;
    But my problem is all the time that I came to know that we cannot use the order by clause in the view of a cursor line in forms 6i. Think it's one of the limitations of forms 6i.so u can suggest me what I can do to get the expected results? do we not have any alternative?


    Thanking you,


    Concerning
    Vids

    Published by: vidusnat on July 4, 2012 03:38

    Hello
    Please specify!
    Forms 6i must be with an older version of SQL and PL/SQL (8.x).

    To keep it simple create a VIEW in the comics with your as its source and the use of the VIEW in the form. As you noted, it works in 10g and exploit it.

    See you soon,.

  • try to get the SUM of all of the charges with the having clause

    Hi Oracle users.

    I'm trying to accomplish to get a sum of a series of charges and it should be easy, but I can't get it.

    For example, I have the following.

    Select ACCTLOC,  count(ACCTLOC) AS TOTALP
    FROM BOX_ACCTS_TBL 
     WHERE TIME_REQ > SYSDATE-120
     Group By ACCTLOC
      having (count(ACCTLOC) > 1)
     
     the results are
     
    ACCTLOC   TOTALP
     
    Philly     15970
    NY          8623
    Tacoma        3
    SanFran     195
    Hartford    5
    Miami       4374
    
      
    

    How can I get the SUM of this group? Do I put this in PL SQL and do a procedure to carry out the selection? Is this the way to go on this?
    I appreciate all the comments you can give.

    Thank you!

    with

    query_result as

    (select 'Philly' acctloc, 15970 totalp Union double all the)

    Select "NY", 8623 Union double all the

    Select "Tacoma", 3 double Union all

    Select "SanFran", 195 double Union all

    Select "Hartford", 5 Union double all the

    Select 'Miami', double 4374

    )

    Select acctloc, totalp, sum (totalp) on the_sum, avg (totalp) (on the_avg), ratio_to_report (totalp) (percentages))

    of query_result

    ACCTLOC TOTALP THE_SUM THE_AVG PERCENTAGES
    Philly 15970 29170 4861.66666666666666666666666666666666667 .547480287967089475488515598217346588961
    NY 8623 29170 4861.66666666666666666666666666666666667 .295611930065135413095646211861501542681
    Tacoma 3 29170 4861.66666666666666666666666666666666667 .000102845389098388755570791909496057593
    SanFran 195 29170 4861.66666666666666666666666666666666667 .006684950291395269112101474117243743572
    Hartford 5 29170 4861.66666666666666666666666666666666667 .000171408981830647925951319849160095989
    Miami 4374 29170 4861.66666666666666666666666666666666667 .149948577305450805622214604045251971203

    Concerning

    Etbin

  • HOW TO USE THE CONNECT_BY CLAUSE

    Hi guys... I have a table like this

    create table emp_del (ename varchar2 (10), mname varchar2 (10))
    Insert into emp_del values ('ABC', 'MNO')
    Insert into emp_del values ('MNO', 'XYZ')
    Insert into emp_del values ('XYZ', 'king')
    Insert into emp_del values ('king', NULL)

    I use this sql to return the name of any employee senior...

    SELECT SYS_CONNECT_BY_PATH (MNAME, '-->') "MANAGER_NAME".
    OF EMP_DEL
    CONNECT PRIOR MNAME = ENAME
    START BY ENAME =: P_EMPLOYEE_NAME

    ex: ename = ABC
    released as: - > MNO
    -> MNO-> XYZ
    -> MNO-> XYZ-> King
    -> MNO-> XYZ-> king - >

    I just need the output to be-> King

    can you guys help me

    One way:

    select ename
    from(
      select e.*,connect_by_isleaf lf
      from emp_del e
      connect by prior mname=ename
      start with ename=:P_EMPLOYEE_NAME
      )
      where lf = 1
    

    Note: it can be simplified as below, just used a subquery to understand...

    select ename
    from emp_del e
    where connect_by_isleaf = 1
    connect by prior mname=ename
    start with ename=:P_EMPLOYEE_NAME
    
  • WHERE the listagg clause

    Hello
    I have the sql query:
    select k.id, listagg(a.first_name ||' '|| a.last_name, ', ') within group (order by a.last_name) as Autor 
    from ksiazki k 
    left join autorstwa at on k.id = at.ksi_id 
    left join autorzy a on a.id = at.aut_id 
    group by k.id 
    and this return:
    k_id      listagg 
    1          a_name_1 & a_last_name_1, a_name_2 & a_last_name_2
    2          a_name_3 & a_last_name_3, a_name_4 & a_last_name_4
    3          a_name_3 & a_last_name_3, a_name_2 & a_last_name_2
    4          a_name_3 & a_last_name_3
    5          null
    and I want to add to the query of WHERE clause, for example:
    ...where listagg(...) = 'a_name_1 & a_last_name_1'
    query returns rank 1
    or
    ...where listagg(...) = 'a_name_2 & a_last_name_2'
    query return rows 1 and 3.

    My version of oracle:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

    Published by: Lucie 2011-06-21 16:22

    Published by: Lucie 2011-06-21 16:23

    Use the HAVING clause:

    select k.id, listagg(a.first_name ||' '|| a.last_name, ', ') within group (order by a.last_name) as Autor
    from ksiazki k
    left join autorstwa at on k.id = at.ksi_id
    left join autorzy a on a.id = at.aut_id
    group by k.id
    having listagg(a.first_name ||' '|| a.last_name, ', ') within group (order by a.last_name) = 'a_name_1 & a_last_name_1'
    /
    

    SY.

  • Use of the place where and having clause

    Hi all

    I have always a doubt as to the use of HAVING and WHERE clause.
    Suppose I have table T1 with a single column C1

    CREATE TABLE T1
    (C1 VARCHAR2 (1));

    who data following INSERT scripts

    INSERT INTO T1 VALUES ('A');
    INSERT INTO T1 VALUES ('B');

    INSERT INTO T1 VALUES('C');

    INSERT INTO T1 VALUES ('A');
    INSERT INTO T1 VALUES ('B');

    INSERT INTO T1 VALUES ('A');


    Now I want the result as follows



    C1 = COUNT (C1)
    ==============
    B = 2
    A = 3

    Then out of query 1 and 2, approach who is right?

    (1) SELECT C1, COUNT (C1) FROM T1
    WHERE C1 <>'C '.
    GROUP BY C1
    ORDER BY C1 DESC;

    (2) SELECT C1, COUNT (C1) FROM T1
    GROUP BY C1
    SEEN C1 <>'C '.
    ORDER BY C1 DESC;

    Published by: user13306874 on June 21, 2010 02:36

    In SQL, it is always better to filter data as soon as possible of the moment.
    In your example, the WHERE clause would be right now:

    SQL> explain plan for
      2  select c1,count(c1)
      3  from t1
      4  where c1 != 'C'
      5  group by c1
      6* order by c1 desc;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------
    Plan hash value: 3946799371
    
    ----------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes |
    ----------------------------------------------------
    |   0 | SELECT STATEMENT   |      |     5 |    10 |
    |   1 |  SORT GROUP BY     |      |     5 |    10 |
    |*  2 |   TABLE ACCESS FULL| T1   |     5 |    10 |
    ----------------------------------------------------
    
    Predicate Information (identified by operation id):
       2 - filter("C1"!='C')
    
    18 rows selected.
    
    SQL>
    

    As you can see that the filter is applied during the analysis of T1.

    Whereas in the case of HAVING:

    SQL> explain plan for
      2  select c1,count(c1)
      3  from t1
      4  group by c1
      5  having c1 != 'C'
      6* order by c1 desc;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------
    Plan hash value: 3146800528
    
    ----------------------------------------------------
    | Id  | Operation           | Name | Rows  | Bytes |
    ----------------------------------------------------
    |   0 | SELECT STATEMENT    |      |     6 |    12 |
    |*  1 |  FILTER             |      |       |       |
    |   2 |   SORT GROUP BY     |      |     6 |    12 |
    |   3 |    TABLE ACCESS FULL| T1   |     6 |    12 |
    ----------------------------------------------------
    
    Predicate Information (identified by operation id):
       1 - filter("C1"!='C')
    
    18 rows selected.
    
    SQL>
    

    The analysis is performed after all groups have been calculated: which was calculated in vain, because it will be further filtered because of the HAVING clause.

    In general, I would like to use as a guide: If you do not use aggregate functions in your predicate in the HAVING clause, set this predicate to the WHERE of your query part.

    Published by: Toon Koppelaars June 21, 2010 11:54

  • PL/SQL parameter in fusion by using the clause

    Hi all

    I need to create a procedure where I use the Merge clause. However, by using the condition, I have to put value user_define (V_LOCALE_CD). This value checks table of locale and then to make a match with table of flex_labels_test.

    There is no specific requirement and I don't have the test data.

    My only question how do I use user set the value using the condition. Here is the procedure I created as follows.

    create or replace the PROCEDURE UPSERT_FLEX_LABEL_3 (V_LOCALE_CD IN VARCHAR2,

    V_VALUE IN VARCHAR2,

    V_FIELDVALUE IN VARCHAR2,

    V_FIELDNAME IN VARCHAR2,

    V_TABLENAME IN VARCHAR2,

    N_FLEX_TYPE NUMBER,

    V_COLOR IN VARCHAR2 DEFAULT NULL,

    N_IMAGE_LIBRARY_ID IN THE NUMBER DEFAULT NULL,

    N_HIERARCHY_ID IN DEFAULT NUMBER 5237260000000000001,

    N_IS_INHERITED IN THE DEFAULT NUMBER 1)

    AS

    L_COUNT NUMBER;

    NUMBER OF N_LOCALE_ID;

    NUMBER OF NN_HIERARCHY_ID: = 5237260000000000001;

    NUMBER OF NN_IS_INHERITED: = 1;

    NUMBER OF INSERTCOUNT;

    UPDATECOUNT NUMBER;

    NUMBER OF ERR_CODE;

    ERR_MSG VARCHAR2 (100);

    BEGIN

    -SELECT ID IN N_LOCALE_ID OF PLACES WHERE LOCALE_CD = V_LOCALE_CD;

    / * IT WILL CHECK DUPLICATES, IF THEY ARE PRESENT, THEN IT WILL UPDATE RECORD ELSE IT WILL INSERT A NEW RECORD * /.

    BEGIN

    Merge into fl flex_labels_test

    using (select locale id where locale_cd = V_LOCALE_CD) L

    on (l.id = fl.locale_id)

    When matched then

    GAME UPDATE

    HIERARCHY_ID = NVL (N_HIERARCHY_ID, NN_HIERARCHY_ID),

    IS_INHERITED = NVL (N_IS_INHERITED, NN_IS_INHERITED),

    FLEX_TYPE = N_FLEX_TYPE,

    VALUE = V_VALUE,

    IMAGE_LIBRARY_ID = N_IMAGE_LIBRARY_ID,

    COLOR = V_COLOR

    WHERE TABLENAME = V_TABLENAME

    AND FIELDNAME = V_FIELDNAME

    AND FIELDVALUE = V_FIELDVALUE

    When not matched then

    INSERT (HIERARCHY_ID, ID_PARAMETRES_REGIONAUX, IS_INHERITED, FLEX_TYPE, TABLENAME, FIELDNAME, FIELDVALUE, VALUE, IMAGE_LIBRARY_ID, COLOR)

    VALUES (NVL (N_HIERARCHY_ID, NN_HIERARCHY_ID), N_LOCALE_ID, NVL (N_IS_INHERITED, NN_IS_INHERITED), N_FLEX_TYPE, V_TABLENAME, V_FIELDNAME, V_FIELDVALUE, V_VALUE, N_IMAGE_LIBRARY_ID, V_COLOR);

    UPDATECOUNT: = NUMBER OF ROWS SQL %;

    EXCEPTION

    WHILE OTHERS THEN

    ERR_CODE: = SQLCODE;

    ERR_MSG: = SUBSTR (SQLERRM, 1, 200);

    DBMS_OUTPUT. PUT_LINE ("ERRORS" |) ERR_CODE | ' AND ' | ERR_MSG);

    END;

    COMMIT;

    DBMS_OUTPUT. PUT_LINE ('RECORD INSERTCOUNT =' |) NVL(INSERTCOUNT,0));

    DBMS_OUTPUT. PUT_LINE (' UPDATECOUNT RECORD ='|) NVL(UPDATECOUNT,0));

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    RAISE_APPLICATION_ERROR (-20001, "ID NOT FOUND REGIONAL SETTINGS");

    END;

    I guess that's what I was looking for. Thank you guys for your efforts.

    FUSION using parameter variables

  • Not able to connect after changing the password using the VALUES ALTER clause

    Hello

    John explained earlier the clause VALUES below thread.

    Status expired

    I created a new account named SURI, and tried to use the password of the user account from the HR by using the VALUES clause. I was able to change the password but not able to connect SURI with HR password.

    Please see below for details. And the SQL statements that I have tried.
    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Aug 13 18:44:50 2012
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Enter user-name: sys as sysdba
    Enter password:
    
    Connected to:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    
    SQL> SELECT password
      2  FROM dba_users
      3  WHERE username = 'HR';
    
    PASSWORD
    ------------------------------
    4C6D73C3E8B0F0DA
    
    SQL> ALTER USER SURI IDENTIFIED BY VALUES '4C6D73C3E8B0F0DA';
    
    User altered.
    
    SQL> SELECT password
      2  FROM dba_users
      3  WHERE username='SURI';
    
    PASSWORD
    ------------------------------
    4C6D73C3E8B0F0DA
    
    SQL> conn suri/hr     -- HR account's password is hr only
    ERROR:
    ORA-01017: invalid username/password; logon denied
    
    
    Warning: You are no longer connected to ORACLE.
    
    SQL>
    Thank you
    Suri

    Its because you have used a different username.
    Oracle produces a hash based on the user name and the password, not only the password.

    Therefore, you can not use the hashed password of a user to log on to the account of another user.

    You need to get the password hashed Suri and then connect you to suri by using the password hashed Suri (using the identified by the syntax of values)

  • How to use the "Order by" clause dynamically on values LOV Forms 10g r2

    Hello

    I have following requirement, please guide me.

    1. create a list of values with 2 fields, Code and Description

    2. do not use the command clause contained in the registration request Group

    3. fix this LOV on a form field

    4. when the user calls the user LOV will see two fields in LOV with header as Code and Description

    5. when the user clicks the column header "Code" then LOV should be arranged on Code

    6 and if the user clicks on the header of the column "Description" then LOV must be sorted on the Description


    Thanks in advance.

    Please post this problem in this forum->

    [Formulas Forum | http://forums.oracle.com/forums/forum.jspa?forumID=82]

    And close this thread by he scored as replied. ;)

    Kind regards.

    LOULOU.

  • Can I use the following script should set up rman DB only or non-rman configured DB

    Hello

    I need your help this following script

    recover database using backup controlfile until Cancel;

    I can only used in configured RMAN DB.

    (or)

    Can we used above usual script on database (IE. RMAN not configured the database)

    Please suggest me. Thanks in advance.

    If you use RMAN to create backup BackupSet, you use RMAN to RESTORE the database.

    Subsequently, you can use RMAN or SQLPLUS to issue the command to RECOVER the DATABASE.

    (RMAN has no clause 'using backup controlfile' because it identifies the controlfile as a backup, while sqlplus must use the following clause if the controlfile is a backup)

    Hemant K Collette

  • Database parameter determines the parallel clause?

    Hi all

    I come with a request that we can use the parallel clause in several ddl, dml statements etc, but where I got stucked was, what parameter in the database that controls or defines the parallel clause.

    For example,.

    What is the maximum that we can use for parallel.

    Please help me in this

    Search PARALLEL_MAX_SERVERS

    This is the max in all concurrent sessions.  If you are looking for a session limit, you will need to see if the resource manager is configured.

    Hemant K Collette

Maybe you are looking for

  • why I don't use ASP bangla in firefox android?

    I think that firefox is better then Opera. Because its features is very beautiful and I can download documents (pdf) here. But we think that I feel very boaring, I can't use ASP bengali in firefox Android. on the other hands, I visit different types

  • Problem with update on Moto G 2nd Gen (India)

    Hi Mark/Matt, Please read and reply. Bit of bike G 2nd Gen users in India can be found on 21.11.14 version as the update is unavailable currently. But he did not have before, former users have obtained the 21.11.23 update and they are running 21.11.2

  • How to remove an incorrect IP address of a printer HP 3052 has

    When I installed everything first this printer I put an IP address which was the same as my router. Now I can't the printer to work on wireless configuration. How can I remove the IP now, I in the printer and get a new IP address. The installation di

  • I can't download the service pack 1 of windows vista.

    Impossible to download service pack 1 for vista I can't download the service pack 1 of windows vista.  I didn't bother with it so far because I now have a new router and I download to configure the router.

  • Beep codes for T500: what do the beeps mean?

    I regularly get the following beep sequence when I restart my T500: beep, beep, beep - beep, beep, beep beep- The beeps are relatively short. After the beeps, the system hangs just quietly. It does not continue the boot process, but it remains lit. I