Problem in the SQL because of the order by clause

Hi all
I am facing a problem in a sql query. I use Oracle 10 g 2.
Query is given below:
SELECT t1.ename
        FROM T1, T2
       WHERE T1.EMPNO = 1234
         AND T1.ACCOUNTNO = T2.ACCOUNTNO
         AND T1.SEQ = T2.SEQ
       ORDER BY T2.SEQ
The query Plan is:
.----------------------------------------------------------------------------------------------------
| Id  | Operation                     | Name                 | Rows  | Bytes | Cost (%CPU)| Time     |
 ----------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT              |                      |     2 |   218 | 11716   (1)| 00:00:41 |
|*  1 |  TABLE ACCESS BY INDEX ROWID  | T1                   |     1 |    89 |     1   (0)| 00:00:01 |
|   2 |   NESTED LOOPS                |                      |     2 |   218 | 11716   (1)| 00:00:41 |
|*  3 |    TABLE ACCESS BY INDEX ROWID| T2                   |     2 |    40 | 11715   (1)| 00:00:41 |
|   4 |     INDEX FULL SCAN           | PK_T2_SEQ            | 58752 |       |   122   (5)| 00:00:01 |
|*  5 |    INDEX RANGE SCAN           | FK_ACCOUNTNO         |     3 |       |     0   (0)| 00:00:01 |
 ----------------------------------------------------------------------------------------------------
Now, I want to reduce the time of this request.

If I remove order by clause query that the query performance is quite perfect, but with order by clause its take time.

I already set SORT_AREA_SIZE, but still nothing improves.

Welcome and thank you for your suggestions.

Thank you

Published by: BluShadow on June 23, 2011 07:55
addition of {noformat}
{noformat} tags and formatted explain plan to make it readable.  Please see {message:id=9360002} for details on how to post code and data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

Hey, a quick test, try:

select ename from (
SELECT t1.ename, T2.SEQ
FROM T1, T2
WHERE T1.EMPNO = 1234
AND T1.ACCOUNTNO = T2.ACCOUNTNO
AND T1.SEQ = T2.SEQ
and rownum > 0)
ORDER BY SEQ

Amiel Davis

Tags: Database

Similar Questions

  • passing parameters in the order by clause of the cursor

    Hi friends,
    I am facing a strange problem

    I have a cursor with an order by clause.

    OPEN FOR Cursor_nomrpt
    SELECT DISTINCT
    CAST (plano.desc3 AS VARCHAR2 (50)) category
    plano.name plan_name
    , chip nvl (CAST (plano.desc6 AS VARCHAR2 (50)), 'not applicable')
    , nvl (trunc(plano.value18,2), 0) nominal_slm
    , nvl (trunc(plano.value19,2), 0) blm
    plano.dbdateeffectivefrom date_live
    ,
    Plano.DBKEY pog_id
    , case when plano.value47 < 0 THEN 0 when plano.value47 IS NULL THEN 0 ELSE plano.value47 END as parent_id
    Of
    Plano dplapro1.ix_spc_planogram
    INNER JOIN dplapro1.ix_spc_performance ON plano.dbkey = perf.dbparentplanogramkey perf
    Produces INNER JOIN dplapro1.ix_spc_product ON perf.dbparentproductkey = product.dbkey
    INNER JOIN dplapro1.ix_spc_product_key ON product.dbkey2 = prodkey.dbkey prodkey
    AND prodkey.keylevel = 2
    WHERE
    Plano.value50 = 0
    AND plano.dbkey4 = p_subcatkey
    ORDER BY ltrim (rtrim (p_orderby)) CSA;

    p_orderby is the parameter that is passed. But the result is not sorted. But when I run the cursor to hardcode the value of parameter, that it works fine...

    Need your help on this

    Hello

    When you use a local variable in a cursor, it's as if you had hard-coded literal in its place, you cannot use a variable to a column name.

    If you know all the possible values for p_orderby, you can do something like this:

    ...
    ORDER BY  TRIM ( CASE  p_orderby
                   WHEN  'DESC'     THEN  plano.desc
                   WHEN  'VALUE'     THEN  plano.value
                   ...
               END
                ) ASC;
    

    If you don't know not all possible values, you can use dynamic SQL statements.

    By the way

    TRIM (x)
    

    Returns the same results as

    LTRIM ( RTRIM (x))
    
  • How to remove the Order By clause

    How can I get rid of the Order By clause in the underlying SQL query? I created a simple hierarchy, but when I use the hierarchy in the analysis and then come down, the results show multiple occurrences of each child. For some reason, I was able to reduce the number of occurrences of each child by adding a saved filter.

    I was expecting this:

    Expected.jpg

    Instead, I got this:

    Actual.jpg

    The generated physical query looks like this:

    SET VARIABLE QUERY_SRC_CD = "report"; SELECT s_0, s_1, s_2, s_3, s_4 s_5, (FROM s_6)

    SELECT

    s_0 0,.

    CAST (NULL AS VARCHAR s_1 (1)).

    "Registration - College". «Dimensions of the inscription '.» "' Exercise ' s_2,.

    'All the colleges' s_3,.

    IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_4 all Colleges").

    MOUNT s_5 (NULL AS DOUBLE),

    "Registration - College". "" Counties of schooling. "" Full-time student "s_6

    "REGISTRATION - College".

    UNION ALL

    SELECT

    1 s_0

    "Registration - College". «Dimensions of the inscription '.» "" Name of College "s_1,.

    "Registration - College". «Dimensions of the inscription '.» "' Exercise ' s_2,.

    'All the colleges' s_3,.

    IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_4 all Colleges").

    IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_5 College ').

    "Registration - College". "" Counties of schooling. "" Full-time student "s_6

    "REGISTRATION - College".

    WHERE

    ("Registration - College". «Dimensions of the inscription '.» ("' Exercise ' IN ('201213')) AND (IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". (("' Colleges ') (1))

    ) djm ORDER OF 1, 3 ASC NULLS LAST, 4 ASC NULLS FIRST, 5 ASC NULLS FIRST, 2 ASC NULLS FIRST, NULLS FIRST CSA 6

    EXTRACT FIRST 10000000 LINES ONLY

    HI mbengue,.

    Check the report you are running any column presentation sorted in the user interface (in which case the order by clause will creep into generated sqls Physics). Also, I think that its worth it to check the settings of the hierarchy you have configured and if the installation program for the calculation of the measured column (number of students in this case), has been done correctly.

    Kind regards

    Arko

  • How does the order by clause in oracle 10G?

    Hi This is my table called Master.I want to order by sno. so I run the below mentioned query.

    SNO DESC STIME, ETIME CCODE ADD SID

    11 11 11 1 10 s11

    1 1 s1 09:00 12:00 10

    2 2 s2 06:00 07:00 9

    3        3      S3        9:00       23:00                         0

    SELECT * FROM MASTER BY SNO

    SNO DESC STIME, ETIME CCODE ADD SID

    1 1 s1 09:00 12:00 10

    11      11         s11        11             1              10

    2         2         s2           6:00        7:00           9

    3         3         S3           09:00     23:00                        0

    but I had bad results. Help kindly me.i can't understand how the order by clause is fetching the record.

    Hello

    Most probably because that SNO is not digital, but a tank.

    If it contains a number onlly, try

    SELECT * FROM MASTER BY TO_NUMBER (SNO);

  • What's the point of having several columns in the ORDER BY clause?

    DB version: 10 gr 2

    When you use the ORDER BY clause, the lines are always sorted by the first column in the ORDER BY clause. So, what's the point of having several columns in the ORDER BY clause (I always see this in production codes)?

    For the below SQLs' schema SCOTT, result sets are always classified according to the first column ename. When I added use asc and desc of employment, does not change the result set.
    SQL> select * from emp order by ename;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    20
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
    
    14 rows selected.
    
    SQL> select * from emp order by ename, job;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    20
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
    
    14 rows selected.
    
    SQL>  select * from emp order by ename, job desc;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    20
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
    
    14 rows selected.

    Search in this example, you will see the difference

    SQL> create table test_order (name varchar2(10), surname varchar2(10), age number);
    
    Table created.
    
    SQL> insert into test_order values('Kamran','Agayev',26);
    
    1 row created.
    
    SQL> insert into test_order values('Kamran','Taghiyev',26);
    
    1 row created.
    
    SQL> insert into test_order values('John','Kevin',23);
    
    1 row created.
    
    SQL> select * from test_order;
    
    NAME       SURNAME           AGE
    ---------- ---------- ----------
    Kamran     Agayev             26
    Kamran     Taghiyev           26
    John       Kevin              23
    
    SQL> select * from test_order
      2  order by age;
    
    NAME       SURNAME           AGE
    ---------- ---------- ----------
    John       Kevin              23
    Kamran     Agayev             26
    Kamran     Taghiyev           26
    
    SQL> select * from test_order
      2  order by age asc, surname desc;
    
    NAME       SURNAME           AGE
    ---------- ---------- ----------
    John       Kevin              23
    Kamran     Taghiyev           26
    Kamran     Agayev             26
    
    SQL>
    

    When in the second query, I sorted out only for age, you saw it there two 26 years old Keita, there was first Agayev, then Taghiyev. But if I want to get the family names in descending order when there are two very old person, then I will add the second column in the order by clause

    - - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev a. (10g OCP)
    http://kamranagayev.WordPress.com

  • Purpose of the ORDER BY clause in the analytic function Min Max

    I was always using analytical functions like Min Max without ORDER BY clause. But today I used with the ORDER BY clause. The results are very different. I would like to know the purpose of the ORDER BY clause in Min, Max and analogues of analytical functions.

    user10566312 wrote:
    I was always using analytical functions like Min Max without ORDER BY clause. But today I used with the ORDER BY clause. The results are very different. I would like to know the purpose of the ORDER BY clause in Min, Max and analogues of analytical functions.

    It is a good point that many developers are not so aware. As far as I understand it the way it works.

    Some analytical functions do not need an order by or windowing clause (SUM, COUNT, MIN, etc.). If there is no specified window, then the full score is the window.
    As soon as you add a command also add you a windowing clause. This window has the default value of 'rank ofrows between unbounded preceding and current_row. So as soon as you add an order by clause, you get a sliding window.

    Documentation: http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm

    windowing_clause
    ...
    You cannot specify this clause unless you specified the order_by_clause. Window limits defined by the clause RANGE you can not specify only a single expression to the > order_by_clause. Please refer to 'Restrictions on the ORDER BY Clause'.

    example of

    with testdata as (select 10 numval, level lv from dual connect by level < 10)
    select lv, numval, sum(numval) over () sum1, sum(numval) over (order by lv) sum2
    from testdata;
    
    LV NUMVAL SUM1 SUM2
    -- ------ ---- ----
     1     10   90   10
     2     10   90   20
     3     10   90   30
     4     10   90   40
     5     10   90   50
     6     10   90   60
     7     10   90   70
     8     10   90   80
     9     10   90   90 
    

    Published by: Sven w. on 25 Sep 2012 16:57 - default behavior has been corrected. Thanks to Chris

  • Evaluate the Expression in the order by Clause

    Hello

    I'm struggling to run after JPQL.

    Select r.firstname, r.lastname, (e.distance/e.duration) from Runner r Inner Join r.event e Order BY (e.distance/e.duration) Desc;

    Error suggests that ' (' character is unacceptable in the Order By Clause.) Here is the error.

    javax.servlet.ServletException: java.lang.IllegalArgumentException: an exception occurred while creating a query in EntityManager:
    Description of the exception: syntax error parsing the query [Select r.firstname, r.lastname, (e.distance/e.duration) of Runner r Inner Join r.event e Order BY Desc (e.distance/e.duration);], line 1, column 101: unexpected token [()].
    Inner exception: NoViableAltException (81! = [1328:1: orderByItem returns [object node]: (n = stateFieldPathExpression (a = ASC | DESC = d |) | I = IDENT (a CSA = | d = DESC |)) ;])])

    Can someone show me please how to fix it.

    Thank you
    Adam

    What version do you use? It should work in EclipseLink > 2.1.

    ---
    James: http://www.eclipselink.org

  • Condition in the order by clause?

    Hello

    my version of db is,
         Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production 
        
    Im having a query like this,
        select a,b,c,d,sum(e) from f group by a,b,c,d order by a,b,c,d
        
    Now if the value of one is 1 I want the result of the following query
        select a,b,c,d,sum(e) from f group by a,b,c,d order by b,a,c,d
        
    The only change between the two queries above are sorted by the clause.

    How to get there?

    Good help will be appreciated.

    Concerning
    Sankar MN

    Published by: SankarMCA on October 5, 2010 04:51

    Hello

    You can use CASE expressions in the ORDER BY clause.
    For example:

    ORDER BY  CASE
                  WHEN  a  = 1  THEN  b
                              ELSE  c
              END
    ,         CASE
                  WHEN  a = 1  THEN  c
                              ELSE  b
              END
    ,         d
    
  • Problem with the order of focus of keyboard on the form of Muse (UPDATE)

    Hello.

    I used the standard form of Muse on a Web site. Everything works fine, except for the order of keyboard focus.

    I mean, it's after a name entry, you press TAB and you go on the field of the e-mail. That's ok. BUT, when you press TAB once again, it will not in the message field. He goes to the button send and then starts to go through the links in the navigation bar and only after all of them it goes on the message field.

    I suspect that my form is not align vertically (and shot the message field to the right) Muse is just after a vertical order. As there is nothing under the email field, it goes back to the navigation bar (which is fixed at the top and has interactive elements / links) and then again to find the message field.

    I think the image as an attachment can explain this better. The URL is Bytezone - Digital goods better to do besides.

    Is the cause of the order of the fields in the form, or is there a way for me to control the order of keyboard somehow focus?

    UPDATE - I just realized that the FIRST element to focus on the use of the TAB key is the message, then the name and e-mail (which is weird). How can I solve this?

    Thanks in advance.


    PS - as a 'bonus' problem, I can't find a way to edit the FOCUS State of the Submit button also. Is this normal?

    form_focus_problem.png

    Muse assigns values to index tab in a 'left to right', then order "top to bottom". Then tab order should follow the same regardless of the creation of fields or placement in design mode.

    Thank you

    Sanjit

  • Error because the ORDER BY clause

    Hi gurus
    I have this formula for a formula column

    function CF_PREVIOUS_QUANTITY returns the number is
    quantity number;
    Start
    SELECT QUANTITY_REMAINING IN the amount
    Of
    (
    SELECT
    QUANTITY_REMAINING
    Of...
    WHERE THE...
    -ORDER BY trx_date DESC
    )
    WHERE rownum = 1;
    return quantity;
    end;

    Copy the following code compiles only if COMMAND LINE is commented out, otherwise I get this:
    Met the ORDER symbol when waiting for him...

    The code compiles ok in SQLDeveloper. I want to just get the first record in a recordset.
    What's not here?

    I use 6-speed

    Thanks in advance
    Oscar

    A problem of M - to-1.

    try either:

    ... (- preferred)
    for (SELECT in c
    QUANTITY_REMAINING
    Of...
    WHERE THE...
    ORDER BY trx_date DESC) loop
    Return c.QUANTITY_REMAINING;
    end loop;

    ... (- awkwardly)
    SELECT QUANTITY_REMAINING IN the amount
    Of
    (SELECT QUANTITY_REMAINING
    (
    SELECT
    QUANTITY_REMAINING
    Of...
    WHERE THE...
    ORDER BY trx_date DESC
    )
    WHERE rownum = 1
    );

  • process of execution of the order by clause

    What is the process of execution of the order clause in the sql statement and how it will affect the performance of the query.

    Siddharth Singh says:
    What is the process of execution of the order clause in the sql statement

    Depends on. First of all, that you mean "alrogithmically, how Oracle data products ordered"? There are a number of different approaches. Data can be ordered as you pick up sequentially from an index. Or it can be explicitly materialized and sorted.

    and how it will affect the performance of the query.

    Depends on. There could be no impact because it relies on the index to classify the data and index is the most effective path independently of the presence of an ORDER BY. Or it could require a huge amount of time to materialize and sort several GB of data.

    Justin

  • WITH the ORDER BY clause and bug SDO_GEOMETRY?

    I'm having a problem using SDO_GEOMETRY in a WITH clause. Specifically with ORDER BY. I'll show a shortened version of SQL here. I'm doing something wrong or is this a bug?

    It works:
                         SELECT 
            loc.location_id,
                        SDO_GEOM.SDO_DISTANCE(cent.lat_long, 
                        MDSYS.SDO_GEOMETRY
                        (
                        2001, -- SDO_GTYPE attribute: 2 in 2001 specifies dimensionality is 2.
                        '4326', 
                        SDO_POINT_TYPE(-78.6386145, 35.772096, NULL),
                        NULL,
                        NULL
                        ),
                       0.01, -- tolerance
                        'unit=mile') result_center_distance
                        
              
                         FROM location loc
                         JOIN centroid cent ON loc.centroid_id = cent.centroid_id
             ORDER BY result_center_distance
    After the statement select in a with clause, this does not work, which gives an identifier not valid "SDO_GEOMETRY" ORA-00904:
    WITH location_distance AS
    (
                         SELECT 
            loc.location_id,
                        SDO_GEOM.SDO_DISTANCE(cent.lat_long, 
                        MDSYS.SDO_GEOMETRY
                        (
                        2001, -- SDO_GTYPE attribute: 2 in 2001 specifies dimensionality is 2.
                        '4326', 
                        SDO_POINT_TYPE(-78.6386145, 35.772096, NULL),
                        NULL,
                        NULL
                        ),
                       0.01, -- tolerance
                        'unit=mile') result_center_distance                    
              
                         FROM location loc
                         JOIN centroid cent ON loc.centroid_id = cent.centroid_id
             ORDER BY result_center_distance
      ) SELECT * from location_distance
    If I duplicate the function of the distance in the ORDER BY, it works:
    WITH location_distance AS
    (
                         SELECT 
            loc.location_id,
                        SDO_GEOM.SDO_DISTANCE(cent.lat_long, 
                        MDSYS.SDO_GEOMETRY
                        (
                        2001, -- SDO_GTYPE attribute: 2 in 2001 specifies dimensionality is 2.
                        '4326', 
                        SDO_POINT_TYPE(-78.6386145, 35.772096, NULL),
                        NULL,
                        NULL
                        ),
                       0.01, -- tolerance
                        'unit=mile') result_center_distance                    
              
                         FROM location loc
                         JOIN centroid cent ON loc.centroid_id = cent.centroid_id
             ORDER BY                     SDO_GEOM.SDO_DISTANCE(cent.lat_long, 
                MDSYS.SDO_GEOMETRY
                (
                2001, -- SDO_GTYPE attribute: 2 in 2001 specifies dimensionality is 2.
                '4326', 
                SDO_POINT_TYPE(-78.6386145, 35.772096, NULL),
                NULL,
                NULL
                ),
                  0.01, -- tolerance
                'unit=mile')
      ) SELECT * from location_distance

    This is a bug. But it is set to 11g R2. Note that this is not a space bug, but a bug in generic compilation.

  • How to use the order by clause

    Hi Al
    order_tracker1 is a tabular_block that I use this to search I want to order by when I search by serch_value
    Please guide


    The code given is used to find
    declare
    l_where varchar2 (4000);
    Start

    If: search_type = "ALL" then
    l_where: = ' id | party_name | COMMENT1 | del_date like "%' | : serch_value | » %''' ;
    on the other
    l_where: =: search_type |' as "%' | : serch_value | » %''';
    end if;

    set_block_property ('order_tracker1', default_WHERE, l_where);
    go_block ('order_tracker1');
    execute_query;
    end;


    Thanks and greetings
    Vikas Singhal

    Hai,

    Change the line set_block_property ('order_tracker1', default_WHERE, l_where); TO

    set_block_property ('order_tracker1', default_WHERE, l_where |) "order by serch_value");

    or in time design, you can give in the palette of the ORDER BY Clauesproperty.

    or you can write to set_block_property (ORDER_BY, 'order_tracker1', 'serch_value');

    Kind regards

    Manu.

    If this answer is useful or appropriate, please mark. Thank you.

  • problem with the order of statements

    Hello

    I know that, in the declaration section, the cursor should be at the top of the statement and only then I can declare the internal procedures, functions etc.
    But what happens if in this slider, I need the result of the internal function said after the cursor? The cursor does not see this feature because is declared after.
    How do I write this slider, is it possible?

    Thank you!

    The SQL engine is aware of the standalone procedures and functions as well as public packet methods. He is not aware of the private methods in a package or nested procedures & functions. The PL/SQL engine always runs all PL/SQL blocks, it's just a question of which blocks exposes it PL/SQL in SQL engine.

    If you need to call a nested function or a private function declared in your package, it is normally relatively simple just call the function in an iteration on the cursor rather than in the cursor declaration itself, i.e.

    declare
      l_dname dept.dname%type;
      cursor employees is
        select *
          from emp;
      function get_dname( p_deptno in number )
        return varchar2
      is
        l_dname dept.dname%type;
      begin
        select dname
          into l_dname
          from dept
        where deptno = p_deptno;
        return l_dname;
      end;
    begin
      for i in employees
      loop
        l_dname := get_dname( i.deptno );
      end loop;
    end;
    /
    

    rather than trying to call the GET_DNAME procedure in the context of the cursor EMPLOYEES.

    Justin

  • Problems with the order of the music through car after upgrading to iOS 9.2.1

    I use the iPhone 6, iOS 9.2.1 BMW 3 series and it's control of media (menus, different keys etc.). The iPhone is connected with a USB cable.

    When the music is stopped on the iPhone, I can't start playing music with the controls of the car. I have to use the play button on the iPhone, to start the music.

    I can control the application music with the controls of the car then. After the music stops, the music cannot play again, only with the play button on the iPhone. This isn't safe when driving... The problem occurred after the upgrade to 9.2.1.

    I also have a model of bmw 3 2012 series, my iPhone 6 iso 9.2.1 does let me not even play music via Bluetooth. He also says that the USB cable is not compatible, it allows me to Bluetooth my phone but not my music, I need to plug thanks to the lead to play music, very frustrating

Maybe you are looking for