query sql in the OPS

Hi all

I need to get a value using a request in the LICS of the controller.below sql is the query

sqlText = "SELECT application_id ';
sqlText += 'FROM ego_attr_groups_v ';
sqlText += ' WHERE attr_group_name = 'TREASURE "";

I would like to know how get the jdbc connection, run the query and assign to a variable.

Help, please.

Thank you
Robet

Hello

Import oracle.jdbc.OraclePreparedStatement;
Import oracle.jdbc.OracleResultSet;
Import oracle.apps.fnd.framework.server.OADBTransaction;

see the following code

OAMessageChoiceBean lineTypeBean = (OAMessageChoiceBean) webBean.findChildRecursive ("LineType");
OraclePreparedStatement oraclePreparedStatement = null;
OracleResultSet oracleResultSet = null;

String lineTypeIdValue = null;
StringBuffer stringBuffer = new StringBuffer();

stringBuffer.append ("SELECT line_type_id FROM apps.po_line_types_val_v");
stringBuffer.append ("WHERE SUPERIOR (line_type) = UPPER (" ' ");")
stringBuffer.append (lineTypeStr);
stringBuffer.append("')");
OADBTransaction oadbTransaction = am.getOADBTransaction ();
try {}
oraclePreparedStatement (OraclePreparedStatement) = oadbTransaction.createPreparedStatement (stringBuffer.toString (), 1);
oracleResultSet (OracleResultSet) = oraclePreparedStatement.executeQuery ();
{if (oracleResultSet.Next ())}
lineTypeIdValue = oracleResultSet.getString (1);
}
on the other
oracleResultSet.close ();
}
{} catch (sqlexception Exception)
pageContext.putDialogMessage (new OAException ("OraclePreparedStatement OR OracleResultSet Exception"));
sqlexception.printStackTrace ();
}

Tags: Oracle Applications

Similar Questions

  • write the query sql for the following situation?

    We have a table like format following...

    A AND B
    ...................
    10 30
    50 40
    60 80
    90 100


    so to write the query and get the result like formats following...


    RESULT
    ............
    30
    50
    80
    100


    Try this... He's one of the interview question. I can't write the query...


    If a knowledge write the query...

    Hello
    Try this

    select (case when a>b then a else b end)   "Result"  from ;
    
  • Query SQL to split the lines based on the amount

    I have the data in the following format in the table.

    ORDER_ID PRODUCT_ID QUANTITY

    O1 A1   3

    I need to write the sql query to divide the data in following format:

    ORDER_ID PRODUCT_ID QUANTITY

    O1 A1   1

    O1 A1   1

    O1 A1   1

    Query must split the data based on the value in the quantity column.

    Thank you

    Developer

    Hello

    create table order_items (
      order_id varchar2(2),
      product_id varchar2(2),
      quantity number
    )
    ;
    insert into order_items values ('O1', 'A1', 3)
    ;
    -- Recursive Subquery Factoring
    with item(order_id, product_id, quantity) as (
      select
        order_id, product_id, quantity
      from order_items
      union all
      select
        order_id, product_id, quantity - 1
      from item
      where quantity > 1
    )
    select
      order_id, product_id, 1 quantity
    from item
    order by order_id
    ;
    drop table order_items purge
    ;
    
    Table ORDER_ITEMS created.
    
    1 row inserted.
    
    OR PR   QUANTITY
    -- -- ----------
    O1 A1          1
    O1 A1          1
    O1 A1          1
    
    Table ORDER_ITEMS dropped.
    
  • SQL query to display the sum of the values of each June and December

    Hello having problems of construction of a query to the list SQL query to display the sum of the values of each June and December each year.

    My Table;

    TABLE name: MONTH_TERM

    Fields with values:

    TERM_KEYMONTH_ACTUALMONTH_DATE
    8250001/11/2015 0:00
    8245001/12/2015 0:00
    8240501/01/2016 0:00
    8240001/02/2016 0:00
    8245001/03/2016 0:00
    8242501/04/2016 0:00
    8243501/05/2016 0:00
    8241006/01/2016 0:00
    8240901/07/2016 0:00
    8241501/08/2016 0:00
    8242009/01/2016 0:00
    8242210/01/2016 0:00
    8243611/01/2016 0:00
    8255601/12/2016 0:00
    8256801/01/2017 0:00
    8262402/01/2017 0:00

    What I would like to see in a query result:

    TERM_KEYMONTH_ACTUALMONTH_DATETotal of 6 months
    8250001/11/2015 0:00
    8245001/12/2015 0:00950
    8240501/01/2016 0:00
    8240001/02/2016 0:00
    8245001/03/2016 0:00
    8242501/04/2016 0:00
    8243501/05/2016 0:00
    8241006/01/2016 0:002525
    8240901/07/2016 0:00
    8241501/08/2016 0:00
    8242009/01/2016 0:00
    8242210/01/2016 0:00
    8243611/01/2016 0:00
    8255601/12/2016 0:002658
    8256801/01/2017 0:00
    8262402/01/2017 0:00

    ---

    Here's my query:

    Select

    "TERM_KEY,"

    "MONTH_ACTUAL,"

    to_char(MONTH_DATE,'MM/YYYY') MONTH_DATE,

    DEAL to_char (MONTH_DATE, 'MM')

    WHEN '06' THEN (SELECT SUM (MONTH_ACTUAL)

    OF MONTH_TERM

    WHERE the to_char (MONTH_DATE, 'MM') between 1 and 6

    AND term_key = 82)

    WHEN '12' THEN (SELECT SUM (MONTH_ACTUAL)

    OF MONTH_TERM

    WHERE the to_char (MONTH_DATE, 'MM') between 7 and 12

    AND term_key = 82)

    ELSE null

    END as SIX_MO_CUMM,

    of MONTH_TERM

    where term_key = 82

    It's my results:

    TERM_KEYMONTH_ACTUALMONTH_DATETotal of 6 months
    8250001/11/15 0:00
    8245001/12/15 0:003608
    8240501/01/16 0:00
    8240001/02/16 0:00
    8245001/03/16 0:00
    8242501/04/16 0:00
    8243501/05/16 0:00
    8241001/06/16 0:003717
    8240901/07/16 0:00
    8241501/08/16 0:00
    8242001/09/16 0:00
    8242210/01/16 0:00
    8243601/11/16 0:00
    8255601/12/16 0:003608
    8256801/01/17 0:00
    8262401/02/17 0:00

    Any ideas on how to fix would be great

    Select term_key,

    month_actual,

    month_date,

    case mod (to_char (month_date, 'mm'), 6)

    When 0 then sum (month_actual)

    During)

    term_key partition

    order of month_date

    between the previous month '5' interval and the current line

    )

    end '6 MONTHS in TOTAL'

    from tbl

    order of term_key,

    month_date

    /

    TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
    ---------- ------------ --------- --------------
    82 500 NOVEMBER 1ST, 15TH
    82 450 1 DECEMBER 15 950
    82 405 1 JANUARY 16
    82 400 1 FEBRUARY 16
    82 450 1ST MARCH 16
    82 425 1ST APRIL 16
    82 435 1 MAY 16
    82 410 2525 1 JUNE 16
    82 409 1 JULY 16
    82 415 1ST AUGUST 16
    82 420 16 - SEP - 01

    TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
    ---------- ------------ --------- --------------
    82 422 1 OCTOBER 16
    82-436 NOVEMBER 1, 16
    82 556 2658 1 DECEMBER 16
    82 568 1 JANUARY 17
    82 624 1 FEBRUARY 17

    16 selected lines.

    SQL >

    SY.

  • SQL query to find the total number of source based nonsource passangersbetween source and destination station and passenger station on the same chekindate

    Hello

    SQL query to find the total number of source based nonsource passangersbetween source and destination station and passenger station on the same chekindate.

    Please help on this script and let me know if you need more details.

    ---

    You use a SELECT statement.  Let me know if you need more details.

  • SQL query to represent the data in the graph bar

    Hello

    JDev 11.1.1.5.0

    We must create a dashboard to track the translation. We have created the ADF table with buttons 'Create', 'Update' and 'Delete' to manipulate the table.

    Our DB table structure is

    File_id (PK), File_Name, ToSpanish - ARE (YES/NO), beginning of the ToSpanish, ToChina(YES/No), ToChina-Date... etc.

    Once the translated file required language then user must update the DB table using the button "Update".

    So far, we have implemented the requirement above.

    We need represent the status of the translation in the graph bar with the language as X access and file count get access Ex: Spanish-100 China - 200 files files

    Please suggest the sql query to retrieve the necessary info from the DB table that can be represented in the graph bar. Also, it would be great, if you can provide a pointers to create a bar chart.

    Thanks in advance,

    MSR.

    If you set your major increment and minor than 1, then you won't not show decimal points.  You can try setting these 10 or 100 to reach your goal.

    Subtype = "BAR_VERT_CLUST" >

                 

  • CF query fails in the CF, but works in SQL Server

    I have the following cfquery which fails in CF and sql in the error code is exactly the same as those listed here and works very well when placed in sqlserver...

    code will work when this section is deleted:

    and t.EmployeeNumber in

    (select std_user_id

    of HED.dbo.EDD_CPR_EMP

    where TERMINATION_DATE is null)

    Why it does not work with above the code and how to make it work?

    my code:

    < html >
    < head >
    < title > retrieve data from database < /title >
    < / head >

    < body >

    <!-Game-> Datasource (s)
    < cfset intellex_datasource = "In Intelex" >

    < CFQUERY NAME = "get_data" datasource = "#intellex_datasource #" >

    Select distinct
    c.CourseTypeName Type,
    Substring (s.WorkGroupName, 1, 2) Dept,
    t.EmployeeNumber Win2k,
    t.FirstNam FirstName,
    t.LastName LastName,
    a.CourseName courses,
    b.NextDate NextDate
    trnTraining a, trnEmployeeTraining b, trnCourseType c, trnEmployeeWorkgroup r, trnWorkgroups s, sysEmployee t
    where b.PriorityId = 'Y '.
    and a.CourseId = b.CourseId
    and a.CourseTypeId = c.CourseTypeId
    and c.CourseTypeName = 'MS '.
    and r.employeeID = b.employeeID
    and r.employeeID = t.employeeID
    and t.EmployeeNumber in
    (select std_user_id
    of HED.dbo.EDD_CPR_EMP
    where TERMINATION_DATE is null)
    and t.deleted is null
    and r.workgroupID = s.workgroupid
    and len (s.WorkGroupName) < = 2
    and b.NextDate > = getdate()
    order of t.LastName, t.EmployeeNumber, a.CourseName
    ;

    < / cfquery >
    < h4 > used data based on criteria of form < / h4 >
    < cfoutput query = "get_data" >

    #Get_data.type #, "Check it", #Get_data.win2k # < br >

    < / cfoutput >

    < / body >
    < / html >

    CF_newtome wrote:

    -Looks like CF is unable to manage a sql to access two different databases?

    CF can do, but I guess that the credentials that you use in the CF data source where is the problem.

    Connect to SQL Server in SQL Server Management Studio by using the same credentials used by the data source and test your query.

    See you soon

    Eddie

  • Export as .xls. Classic report type: SQL (body of function from PL/SQL returning the SQL) query

    Hey guys,.

    I'm using version 4.2.6 apex. The theme is 26.

    IM also using Listener Oracle APEX.

    I can print my classic report in PDF or CSV format.

    But I need to export it as a .xls extension.

    Report type: SQL (body of function from PL/SQL returning the SQL) query

    I need is like this cause my 'where' clause type is dynamic.

    Look at using this method: Tom's Blog: a non-standard export excel 2010 (.xlsx)

    I do something similar for downloads to excel in my projects...

    Thank you

    Tony Miller
    Software LuvMuffin
    Ruckersville, WILL

  • SQL query to get the NULL records after the last matching flag

    I have a xx1 table with id and flag columns. So I want the data in this table, after the last flag matched. I want that data to id 7 in the rooms. Even if the id 2,3,5 are null flag 'Y' was at 6. ID so I need a query to get the data of the xx1 table after the last correspondence flag (from 7 to 9 id).

    SQL > create table xx1

    2 (identification number,

    3 flag varchar2 (10));

    Table created.

    SQL > insert into xx1 values (1, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (2, null);

    1 line of creation.

    SQL > insert into values xx1 (3, null);

    1 line of creation.

    SQL > insert into xx1 values (4, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (5, null);

    1 line of creation.

    SQL > insert into xx1 values (6, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (7, null);

    1 line of creation.

    SQL > insert into values xx1 (8, null);

    1 line of creation.

    SQL > insert into values xx1 (9, null);

    1 line of creation.

    SQL > select * from xx1.

    FLAG OF THE ID

    ---------- ----------

    1. IS

    2

    3

    4. IS

    5

    6. IS

    7

    8

    9

    9 selected lines.

    SQL >

    Hello

    user11164339 wrote:

    Hi Frank - when I run the query, I don't see the results data.

    I get

    FLAG OF THE ID

    ----- ----------

    7

    8

    9

    What you do differently?

  • query sql delicate... date of the created object.

    friends...
    I am trying to solve this query sql delicate for some time, but unable to progress when it comes to this day...

    Q.
    Query dba_objects and list all tables created yesterday ' sysdate - 1' and in another column of the list all the tables created ' sysdate - 7'.

    -query below gives me to yesterday, but don't know how to have 'Last_week' column filled... maybe I join?
    select owner, object_name, to_char(created, 'MM-DD-YYYY HH24:MI:SS') "Yesterday", to_char(created, 'MM-DD-YYYY HH24:MI:SS') "Last_Week"
    from dba_objects
    where object_type = 'TABLE'
    and created >=trunc(sysdate - 1)
    and created < trunc(sysdate)
    appreciate your time and effort in looking at this...

    Thank you

    Published by: khallas301 on March 19, 2013 09:27
    typo edited... Thanks to frank

    khallas301 wrote:
    Query dba_objects and list all tables created yesterday ' sysdate - 1' and in another column of the list all the tables created ' sysdate - 7'.

    Well, sysdate - 7 ways months ago, not last week. If this is what you want, then:

    select  owner,
            object_name,
            case
              when trunc(created) = trunc(sysdate - 1) then to_char(created,'MM-DD-YYYY HH24:MI:SS')
            end "Yesterday",
            case
              when trunc(created) = trunc(sysdate - 7) then to_char(created, 'MM-DD-YYYY HH24:MI:SS')
            end "Week Ago"
      from  dba_objects
      where object_type = 'TABLE'
        and (
                trunc(created) = trunc(sysdate - 1)
             or
                trunc(created) = trunc(sysdate - 7)
            )
    /
    

    SY.

  • Detroit SQL of the query in writing: analysis of the GAPS in order of Row_Wid in a Table

    I am writing a query that scans a product Dimension Row_Wid, notes the gaps in the sequence and generates the missing Row_Wids. It loads these 'missing Feds"in a sequence of wid created table to reuse by Informatica transformation of research without bond during the subsequent data loads. Yes, I expect many people asking why I do this. The simple reason is that Informatica has a limit of 2 147 sequence generator 483 647'. I arrived at this upper limit, but my table contains only 2.2 million lines of actual data. I'm trying to reuse these Row_Wids now 'not used '.

    I have a job with success the query to find the first ditch and fill some of that gap. Now my next problem is to figure out how to get my request to move away from the next. I can't use the PL/SQL in the query. My client does not allow its use.

    I'll paste the code I have now. I need to evolve to the next gap. Suggestions? Help? Ideas?



    The Version of database: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

    The table I'm inserting: CREATE GLOBAL TEMPORARY TABLE "OLAP". "" ROWWIDVAL "("ROWWID"NUMBER (10.0), NUMBER (10,0)"EXTRAVAL") ON COMMIT PRESERVE ROWS;
    A note: the Temp Table to test this point, I've created is "RowWidVal" and it has two columns.

    -Updated Code collaboration-
    Insert Into RowWidVal(
    SELECT
         CASE
              WHEN NumGen <= GapSize+2 THEN (P2.MinGapStart-1)+NG.NumGen
         END RowWid, 0
    FROM
         (SELECT MIN(T4.GapStart) MinGapStart, MIN(T4.GapStop) MinGapStop, (MIN(T4.GapStop) - MIN(T4.GapStart)) GapSize
              FROM
                   (SELECT T2.row_wid + 1 GapStart,
                        (SELECT MIN(T1.row_wid) - 1 FROM w_product_d_test T1 WHERE T1.row_wid > T2.row_wid) GapStop
                        FROM w_product_d_test T2
                        LEFT OUTER JOIN w_product_d_test T3 ON T2.row_wid = T3.row_wid - 1
                   WHERE T3.row_wid IS NULL
                   ) T4
         WHERE T4.GapStop IS NOT NULL
      ) P2,
         (SELECT LEVEL NumGen
          FROM dual
          CONNECT BY LEVEL <= (SELECT ((Min(GapStop) - Min(T4.GapStart)) +1) GapSize
                                   FROM
                                       (SELECT T2.row_wid + 1 GapStart,
                                            (SELECT MIN(T1.row_wid) - 1 FROM w_product_d_test T1 WHERE T1.row_wid > T2.row_wid) GapStop
                                            FROM w_product_d_test T2
                                            LEFT OUTER JOIN w_product_d_test T3 ON T2.row_wid = T3.row_wid - 1
                                            WHERE T3.row_wid IS NULL
                                       ) T4
                                        WHERE T4.GapStop IS NOT NULL)
         ) NG
    WHERE P2.MinGapStart < P2.MinGapStart+(GapSize+2));
    Published by: user1002601 on 16 January 2013 08:33

    Published by: user1002601 on 16 January 2013 08:39

    How about this?

    Sample data:

    SQL> create table w_product_d_test (row_wid number);
    
    Table created
    
    SQL>
    SQL> insert into w_product_d_test (row_wid)
      2  select column_value
      3  from table(sys.odcinumberlist(1,2,3,4,5,11,12,13,31,32,33,34));
    
    12 rows inserted
    
    SQL> select * from w_product_d_test;
    
       ROW_WID
    ----------
             1
             2
             3
             4
             5
            11
            12
            13
            31
            32
            33
            34
    
    12 rows selected
     
    

    Generate sequence available numbers:

    SQL> with gaps as (
      2    select rw, gapsize
      3    from (
      4      select row_wid as rw
      5           , row_wid - lag(row_wid,1,0) over(order by row_wid) - 1 as gapsize
      6      from w_product_d_test
      7    )
      8    where gapsize > 0
      9  )
     10  select g.rw - t.column_value as available_rw
     11  from gaps g
     12     , table(
     13         cast(
     14           multiset( select level from dual connect by level <= g.gapsize )
     15           as sys.odcinumberlist
     16         )
     17       ) t
     18  ;
    
    AVAILABLE_RW
    ------------
              10
               9
               8
               7
               6
              30
              29
              28
              27
              26
              25
              24
              23
              22
              21
              20
              19
              18
              17
              16
              15
              14
    
    22 rows selected
     
    
  • IOM sql Query to get the status of the failed task

    Hello world

    We have an obligation as we need to get the status of a particular task (say Create User in OID - Completed\Rejected status resource) for the particular user. We are able to get the status of the provisioed of resources to the user but not the status of the special mission which is trigerred for the user.can someone put some light on it. We must have the SQL query to do this.

    Thanks in advance.

    Kind regards
    MKN

    Hello
    Use this query to get the status of the task, also check the cooments

    SELECT USR. USR_LOGIN, OSI. SCH_KEY, ANN. SCH_STATUS, STA. STA_BUCKET OF
    OSI, CHS, STA, MIL, TOS, PKG, OUEDRAOGO, USR, OBJ, OST
    WHERE OSI.MIL_KEY = MIL.MIL_KEY
    AND ANN. SCH_KEY = OSI. SCH_KEY
    AND STA. STA_STATUS = SCH. SCH_STATUS
    AND TOS. PKG_KEY = PKG. PKG_KEY
    AND MIL. TOS_KEY = TOS. TOS_KEY
    AND OUÉDRAOGO. USR_KEY = USR. USR_KEY
    AND OUÉDRAOGO. OST_KEY = OST. OST_KEY
    AND OST. OBJ_KEY = OBJ. OBJ_KEY
    AND OSI. ORC_KEY = OUEDRAOGO. ORC_KEY
    AND OBJ. OBJ_NAME = "User AD".
    AND OST. OST_STATUS = "Provisioning" - filter accordinglly
    AND STA. STA_BUCKET = 'pending' - filter accordinglly
    AND PKG. PKG_NAME = "AD User" - filter accordinglly
    AND MIL.MIL_NAME = 'System' - filter accordinglly Validation
    ;
    Thank you
    Kuldeep

  • SQL query to get the number of days monthwise

    Hello
    I'm new to sql, can someone please tell me query to find the number of days between the two dates months wise.
    say
    FIRSTDATE last date
    21/03/2011-25/06/2011

    March April May June
    9 22 23 18

    Hello

    Welcome to the forum!

    Here's one way:

    WITH     all_dates     AS
    (
         SELECT     start_date + LEVEL - 1     AS a_date
         FROM     (
                   SELECT     TO_DATE ('21/03/2011', 'DD/MM/YYYY')     AS start_date
                   ,     TO_DATE ('25/06/2011', 'DD/MM/YYYY')     AS end_date
                   FROM     dual
              )
         CONNECT BY     LEVEL     <= end_date + 1 - start_date
    )
    SELECT       TO_CHAR ( TRUNC (a_date, 'MONTH')
                , 'fmMonth YYYY'
                )               AS month
    ,       COUNT (*)               AS num_days
    FROM       all_dates
    WHERE       a_date - TRUNC (a_date, 'IW')     < 5
    GROUP BY  TRUNC (a_date, 'MONTH')
    ORDER BY  TRUNC (a_date, 'MONTH')
    ;
    

    What is a 'working day '? I guess you mean every day except Saturday or Sunday, but the query aboveare sometimes figures less than you have asked:

    MONTH             NUM_DAYS
    --------------- ----------
    March 2011               9
    April 2011              21
    May 2011                22
    June 2011               18
    

    Are a few days working on Saturday or Sunday? How do you get the 22 working days in April 2011 and 23 in may?

    SQL is good at obtaining results with a variable number of rows, but you have to say exactly the desired number of columns when you write the query.
    If you really need the output of the way you said, with any number of columns, then watch in swing or a grouping of the chain . See the FAQ forum
    https://forums.Oracle.com/forums/Ann.jspa?annID=1535
    "4. How can I convert rows to columns.

  • Query SQL Report with condition (multiple settings) at the point of the apex?

    Hi all

    I have a small problem and cannot find a solution.

    I need to create reports based on a query, SQL or I.R. Nothing hard here.
    I need to add the WHERE clause dynamically with javascript to an element of the Apex.
    Even once is not very difficult. I set the agenda of the Summit, put my query like this "SELECT * FROM MYTAB WHERE COL1 =: P1_SEARCH" then I call the page by setting the P1_SEARCH value. For example, COL1 is rowid. It works very well.

    But here's my problem. Consider that P1_SEARCH contains several ROWID, and I don't know the number of these values,
    (no I don't create a large number of items and create a query with so much GOLD!), I would sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (: P1_SEARCH) with something like: ROWID1, ROWID2 in P1_SEARCH."

    I also tried: 'ROWID1, ROWID2' and 'ROWID1', 'ROWID2 '.
    but I can't get anything else than the mistake of filter. It works with a value, but as soon as there are two values or more, it seems that the Apex is unable to read the string.


    How can I do it please?

    Thanks for your help.

    Max

    mnoscars wrote:

    But here's my problem. Consider that P1_SEARCH contains several ROWID, and I don't know the number of these values,
    (no I don't create a large number of items and create a query with so much GOLD!), I would sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (: P1_SEARCH) with something like: ROWID1, ROWID2 in P1_SEARCH."

    I also tried: 'ROWID1, ROWID2' and 'ROWID1', 'ROWID2 '.
    but I can't get anything else than the mistake of filter. It works with a value, but as soon as there are two values or more, it seems that the Apex is unable to read the string.

    For a standard report, see + {message identifier: = 9609120} +.

    For an IR - and improve safety by avoiding the risk of SQL Injection, use a collection containing the values in a column instead of a CSV list:
    {code}
    SELECT * FROM MYTAB WHERE ROWID IN (SELECT c001 FROM apex_collections WHERE collection_name = "P1_SEARCH")
    {code}
    (Please close duplicate threads spawned by your original question.)

  • The query sql without prescription by will return same result on several tracks?

    Hello

    I have a sql without a prescription and I limit the number of rows to 100 max per rownum < 100. Now the question is, if the data set on which this sql is running, does not change, the sql returns the same result the performance of several?

    For example, there are 150 lines and the sql returns 100 rows because of rownum < 100. Now running the same sql several times, I have the same set of 100 lines? or it could be 150? On the basis of these the kind of database engine and return data when no order by clause are provided?

    Thank you for your time.

    -Hozy

    Hi, Hozy,

    Hozy says:
    Hello

    I have a sql without a prescription and I limit the number of rows to 100 max per rownum< 100.="" now="" the="" question="" is,="" if="" the="" data="" set="" on="" which="" this="" sql="" runs,="" does="" not="" change,="" will="" the="" sql="" return="" the="" same="" result="" set="" on="" multiple="">

    N ° if there is no ORDER BY clause, then there is no guarantee that the order will remain the same. If the table is small, the output will probably be the same thing, but you can't count on it.
    I guess that you do not have a CONNECT BY query. CONNECT BY queries without ORDER BY clause or brothers and SŒURS of ORDER BY, the output is partially ordered.

    For example, there are 150 lines and the sql returns 100 rows due to rownum< 100.="" now="" on="" executing="" the="" same="" sql="" multiple="" times,="" will="" i="" get="" the="" same="" set="" of="" 100="" rows?="" or="" it="" could="" be="" any="" of="" the="" 150?="" on="" what="" bases="" these="" the="" database="" engine="" sort="" and="" return="" data="" when="" no="" order="" by="" clause="" is="">

    No, you necessarily will not get the same 100 lines each time. ROWNUM reflects the order in which the establishment has recovered the lines.
    Say you run the query at 11:00. Maybe do you a full table scan to obtain the data on the drive, and the order of the lines is determined by how it data happens to be on the disk. As the data is read from the disk, it is cached in memory.
    Say you run the same exact query at 12:00, without changing the table. Instead of retrieve all data from the disk, Oracle will try to use the blocks that are cached in memory, which is not necessarily the way the blocks are stored on the disk. If some of the older blocks 11:00 to 12:00 (otherwise said, some, but not all, blocks are more in memory because memory was required for other purposes), then the items picked up at 11:00 can be recovered first at 12:00 and the lines that I have high ROWNUMs at 11:00 can get low ROWNUMs at 12:00. (See Matthew 7:30.)

    Again, you would never notice it on a small table. You can run this query

    SELECT  ename
    FROM    scott.emp
    WHERE   ROWNUM  < 10;
    

    a thousand times and get the same results every time. You will get the same results the 1001eme time? Probably, but not necessarily.

    If you want the output to be in a particular order, to use an ORDER BY clause in the main query.
    If you want ROWNUM to reflect a particular order, use a subquery with an ORDER BY clause and ROWNUM reference in the main query.

Maybe you are looking for

  • Renaming of files

    I was curious to know, if there was a way I could highlight a series of images and Relabel the in order without having to do manual. For example in the image below, there are 6 images with different names, I could highlight and name them 1-6 for exam

  • Satellite M300 PSMDCA takes a long time to start

    I have a Toshiba Satellite M300 PSMDCA - 01800C and there are some problems with it. First of all, when you start the computer, it takes a long time to start and activate Outlook.I am running Windows 7Home Premium.Computers arrow where I bought the c

  • What happens immediately after that I get a refund?

    Can I continue using the app for some time, or it be uninstalled immediately?

  • My icloud music library does not appear on itunes mac

    Hi, I have iPhone and Mac and iTunes and Apple music subscription. I have my subscription songs I added to my playlist, all work well on the iPhone. Unfortunately none of my music library appears on library Mac, even if iTunes Mac is connected to my

  • Cannot install hard disk Portable Toshiba on HP20 - 2105A

    I bought a Toshiba 1 TB USB 3.0 portable hard drive (model No. DTB310) and when I plug the USB 3.0 cable, the computer shows that the folder is empty, i.e. There is no setup.exe file. I use a HP20 - 2105A with 8.1-64-bit Windows computer (bought in S