Entire result set built?

Given a table with 500,000 rows, if the following sequence occurs:
1. a cursor is opened which does a table scan
(just a simple select, no sorting)
2. one row is fetched
3. the cursor is left open without fetching any more rows
Is the entire result set built by oracle? Is the whole table read into the data cache? Or does oracle at some point suspend the table scan until an additional fetch request is made?
In other words, if a number of users execute this code, will oracle actually complete the table scan for each of them, even though none of them fetched more than one row?
DECLARE
CURSOR cur1 IS select * from large_table;
lt_rec large_table%ROWTYPE;
BEGIN
OPEN cur1;
FETCH cur1 INTO lt_rec;
-- cursor left open
-- no more fetches
Thanks!

I think the table is read in to the data cache, although blocks read in as a result of a full table scan are automatically marked as Least Recently Used, and are therfore pretty cache friendly.
I suppose Oracle has to maintain a read lock on the table as well.

Similar Messages

  • Is column visibility based on the first page of the result set or the entire result set?

    I have tried, in vain, to play with the column visibility expression in my report. So where my Business Unit is "MC" or "FM", then I want to display column "HCFA Number"...otherwise hide it. If I run strictly for "MC"
    it works! If I run simply for "CO" it works! And doesn't show! But if I combine "CO" and "MC", it is hidden and I would expect it to be visible since "MC" is part of my entire report.
    Here's the expression I came up with for Column Visibility...
    =IIf((Fields!BUSINESS_UNIT.Value = "MC") OR
    (Fields!BUSINESS_UNIT.Value = "FM"),FALSE,TRUE)
    Am I missing something here or just being dense late on a Friday???
    Thanks for your review and am hopeful for a reply.

    Hi ITBobbyP,
    It seems you have add parameter based on the "Business Unit" which is multiple values and when you select the "CO,MC" the entire column "HCFA Number" is hide, but what you want is to hide the CO related "HCFA Number"
    and show the MC related "HCFA Number", right?
    The expression you are using to show/hide the column visibility will based on the current filtered entire result set. That is mean the entire column "HCFA Number" will be show when the result set contains "MC" or "FM"
    or both, otherwise, it will always hide.
    In your scenario, you can set the row visibility using the expression and you will get the result like below:
    You can set the visibility of the textbox "[HCFANumber]", but the CO related "HCFANumber" will be blank:
    If I have some misunderstanding, please try to provide more details information about the expect result you want.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • How to execute entire result set of multiple sql statements via sp_executesql?

    I have a query that generates multiple insert statements (dynamic sql).  So when I execute this my result set is a table of sql insert statements (one insert statment per row in my source data table).  Like so:
                 Select 'INSERT INTO [dbo].[Table_1] ([Col1]) VALUES (' +  SrcData + ')' from SourceDataTbl
    How can I completely automate this and execute all these sql statements via sp_executesql?
    My plan is to completely automate and execute all this via an SSIS package.
    As always any help is greatly appreciated!
    fyi-  This is a very simple version of what I am trying to do.  My query probably plugs in 20+ values from the SourceDataTbl into each of the sql insert statements.

    Ah, a small error in Visakh's post, which I failed to observe, and then I added one on my own.
    DECLARE @SQL Varchar(max)
    SELECT @SQL =
       (SELECT 'INSERT INTO [dbo].[Table_1] ([Col1]) VALUES (' +  SrcData +
                ')' + char(10) + char(13)
        from SourceDataTbl
        FOR XML PATH(''), TYPE).value('.', 'nvarchar(max)')
    EXEC sp_executesql @SQL
    Without ", TYPE" FOR XML returns a string when assigned to a variable. The TYPE thing produces a value of the XML data type, so that we can apply the value method and get string out of the XML.
    And why this? Because:
    DECLARE @str nvarchar(MAX)
    SELECT @str = (SELECT 'Kalle Anka & co' FOR XML PATH(''))
    SELECT @str
    SELECT @str = (SELECT 'Kalle Anka & co' FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)')
    SELECT @str
    Although the data type is string when , TYPE is not there, it is still XML and characters special to XML are enticised.
    Confused? Don't worry, for what you are doing, this is mumbo-jumbo.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Please help - Scrollable result set in sql server 2000

    Hi can some one please help me. I'm trying to create scrollable result set in sql server 2000, but i just can't get it to work. I've been trying to do this for the past 12 hours. I want to go home, but I can't till I get this going! please help!!! My crap code is as follows:
    package transact;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JInternalFrame;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    public class DummyFrame extends Dummy
    protected String name, surname;
    protected Connection conn;
    protected CallableStatement cstatement;
    public DummyFrame()
    createFrame();
    private void createFrame()
    try
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    conn = DriverManager.getConnection(
    "jdbc:microsoft:sqlserver://server:1433;" +
    "user=user;password=pwd;DatabaseName=Northwind");
    catch (Exception e)
    e.getMessage();
    populateFields();
    menuAction();
    show();
    private void menuAction()
    btncontacts.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    getRecords();
    populateFields();
    btncontacts.setText("NEXT");
    btnkeywords.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    // transaction.getRecords();
    nextRecord();
    populateFields();
    btncontacts.setText("NEXT");
    protected void nextRecord()
    try
    // CallableStatement cstatement = null;
    cstatement = conn.prepareCall(
    "{call Employee_Selection}", ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = cstatement.executeQuery();
    while (rs.next())
    surname = rs.getString("Lastname");
    cstatement.getMoreResults();
    catch (Exception e)
    e.getMessage();
    protected void getRecords()
    try
    CallableStatement cstatement = null;
    cstatement = conn.prepareCall(
    "{call Employee_Selection}", ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = cstatement.executeQuery();
    while (rs.next())
    surname = rs.getString("Lastname");
    name = rs.getString("Firstname");
    rs.first();
    // call stored procedure
    catch (Exception e)
    e.getMessage();
    // populate the fields;
    private void populateFields()
    txtfirstname.setText(name);
    txtsurname.setText(surname);
    }

    ummm ok i think the logic in your code is kinda screwy...
    here is what your should be doing.
    create the gui.
    get the resultset...
    have code that looks like this for nextRecord...
    protected void displayNextRecord(){
      // we do not call next here because we already called it last time
      surname = rs.getString("Lastname");
      name = rs.getString("Firstname");
      populateFields();
      if(!rs.next(){
        btncontacts.setEnabled(false);// i'm not sure what btncontacts is but we want to disable next becuase there are no more records...
    // in your intitalization code you need to do this...
    // you old stuff ending with...
    ResultSet rs = cstatement.executeQuery();
    // the new stuff...
    if(rs.first()){
      displayNextRecord();
    }else{
      btncontacts.setEnabled(false);//the result set is empty
    }ok the real problem you are having is that you are trying to display one record at a time but you are scrolling
    through the entire result set using while(rs.next()... what you
    want to do is create the result set once and scroll through
    it one item at a time with your gui.
    the example method i have given displays the data from the current
    row in your gui. then it advances the result set forward one row if possible. this method assumes that the result set will always
    be positioned on a valid row thus the need for calling
    rs.first() before we originally call displayNextRecord()
    well i hope you find this helpful.

  • AF Query: Criteria fields disappearing but result set not refreshed

    I have been searching for days and cannot find a solution to this problem. I have an af:query component based on a view criteria. I have the query component only displayed as an advanced search without the basic/advanced toggle. A user can then use "Add Fields" and filter down their result set. Now whenever the user navigates away from that page and returns the filtered result set remains, but the list of fields that the user added to filter on are missing, i.e.
    Search Box
    Field1 is not blank
    Navigate away and return
    Search Box
    blank; nothing listed here, but result set is still filtered for Field1 not blank.
    The only thing the customer can do is add a bogus field, and then click reset to return the entire result set.
    If anyone can help with this problem, I would greatly appreciate it. I am using:
    JDeveloper 11.1.1.4
    Oracle 11g
    Weblogic 10.3
    Thanks,
    Michelle

    Actually, in researching another problem, I think this is either a problem with jheadstart or with .jsff pages. I created a test case for a different problem that I posted to metalink and in this I did not use jheadstart and I used just a single .jspx page with a panel tabbed layout. The problem does not occur here, so one of the 2 is causing my problem, now the question is which.
    Thanks for your help,
    Michelle

  • Random result set from cursor

    Hello all,
    I have a cursor defined that simply performs a SELECT. I would like to be able to dynamically state whether I'd like the entire result set returned or a random selection.
    The issue I'm having is that because the cursor is already defined I am trying to build this functionality into the LOOP. I am able to return random sets by using DBMS_RANDOM but I've only been able to do this when modifying the SELECT statement. I have considered an ORDER BY in the cursor and then simply EXIT'ing when the ROWNUM meets a certain number of returned results. This would, at least, provide the ability to return a user specified number of random records. Perhaps the ORDER BY could be modified by a cursor parameter?
    I'm hoping there's an elegant solution that I'm missing.
    Thanks for any help!
    Mark

    user10368702 wrote:
    Thanks for pointing out this feature to me. The problem is that my cursors are currently doing multi-table joins and the SAMPLE clause will not work with them. To clarify, I would like to programatically decide whether I'd like to return all the rows from the cursor, or just a sampling. The current method being used it to generate a random number and loop through the entire cursor until that rownum is found. I dislike the table walk, but am unable to come up with a way to return a specific sample size or record num. Ideally I'd like to be able to perform the equivalent of ROWNUM = X with the results from the cursor.
    Thanks for any help!Probably you can't use dynamic SQL (using OPEN or EXECUTE IMMEDIATE) for a particular reason? Because in that case you could just use your query as an inline view like that:
    SELECT * FROM (
    <YOUR_QUERY_INCLUDING DBMS_RANDOM_VALUE>
    WHERE <RANDOM_VALUE> <= <YOUR_LIMIT>and construct your query dynamically.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/
    Edited by: Randolf Geist on Sep 29, 2008 11:21 PM
    Removed unnecessary ORDER BY

  • How to pass one row of a result set to a cffunction?

    I can pass the entire result set of a query to a cffunction,
    but the function only needs one row.
    The code below is a syntax error, where "3" is array index
    notation for the third row of the result set.
    What is the correct way to pass one row of a result set to a
    cffunction?
    Thank you.

    iirc, cf does not allow one to reference and access a row of
    a resultset
    like that.
    you will have to create a structure/array that holds the data
    from
    specific query row and pass that to your function. looping
    over
    queryname.columnlist list will make it easier and not
    specific to any
    particular query. make it into another function that accepts
    a query and
    row number as arguments and returns a struct/array of that
    row data (or
    automatically passes it to another function).
    sample code for creating a structure of specific query row
    data:
    <cfset rowstruct = {}>
    <cfloop list="#queryname.columnlist#" index="col">
    <cfset rowstruct[col] = queryname[col][somerownumber]>
    </cfloop>
    <cfdump var="#rowstruct#">
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

  • How do I create an Event Handler for an Execute SQL Task in SSIS if its result set is empty

    So the precedence on my entire package executing is based on my first SELECT of my Table and an updatable column. If that SELECT results in an empty result set, how do I create an Event Handler to handle an empty result set?
    A Newbie to SSIS.
    I appreciate your review and am hopeful for a reply.
    PSULionRP

    Depends upon what you want to do in the eventhandler. this is what you can do
    Store the result set from the Select to a user variable.
    Pass this user variable to a Script task.
    In the Script task do whatever you want to do including failing the package this can be done by failing the script task, which in turns fails the package. something like
    Dts.TaskResult = Dts.Results.Failure
    Abhinav http://bishtabhinav.wordpress.com/

  • Can I create a result set filter on a SSRS Report similar to what you can do in Excel?

    Asking this question in a different way...I have my SSRS Result set. Now the Business User wants to filter down a 15-page report to what they want to specifically see....Sooo my result set has a list of claims. And now the Business User just wants to see
    the list of claims by a certain Provider, which is also in the report. So I don't want to put that "filter" on the front-end...within the Stored Procedure that is producing the report because they want to see everything. Is there a way to make SSRS
    intelligent enough to parameterize the back-end result set? Or do I need to do it the old fashioned way by allowing for an optional parameter, let them run their report, define the available values by a query similar to the stored procedure filtering, and
    let them drill down that way?
    I have tried playing around with Dataset filters and a parameter using the existing result set and existing Dataset, but I just cannot seem to get this to work the way I envision. If this entails creating a Function or Procedure within the SSRS, bring it
    on...I'm willing to learn. And I do have some VBA experience...so I'm not intimidated.
    Again...I apologize for the similar type question, but I felt the need to be a little more clear.
    Thanks for your review and am hopeful for a reply.
    PSULionRP
     

    I GOT IT!!!
    Followed the following...
    Here's what I've put into my SSRS Knowledgebase...
    Filters/Parameters on the Report Result Set
    Request from the Business User to add "parameters" to the Report Result Set. Kind of like auto filtering you can do in Excel
    Within the Report Design within Microsoft Visual Studio…
    — Insert a new Dataset which is merely carving out the SQL from the working Report Stored Procedure and customizing the SQL for the DISTINCT values that you want
    — Insert a NEW Parameter based on the carved out SQL
    General → Allow blank value
                      Allow multiple values
    Available Values → Get values from a query
    Specify the previously created Dataset
    Default Values → Get values from a query
    Specify the previously created Dataset
    — Insert a Filter back on the original Dataset that is used to create the Report
    Expression → Choose the Report Detail Item column name
    Operator → In
    Value → Physically type in the Parameter Name created previously
    Works EXACTLY as I had envisioned. Prompts for the From Date and Thru Date, runs the report, dynamically builds the "optional" parameters/filters,
    and then allows the Busimess User to speify or drill down into the result set based on the dynamically built parameter drop-down list.

  • Can we pass temporary result set to the  procedure?

    Hi,
    The result set is stored in a temporary storage. Can we pass that resultset to the procedure?
    Thanks and regards
    Gowtham Sen.

    I'm still unclear just what this result set is... Is is a table or a cursor or something else?
    If you imply the physical result set of a SQL query, there is no such thing in Oracle. Oracle does not create and store a result set in memory containing the rows of the SQL SELECT. Creating such sets in memory does not scale. A single SELECT on such a database can kill the performance of the entire database by exhasuting all memory with a single large physical result set.
    Oracle "results" live in the database cache (residing in the SGA). Rows (as data blocks) are paged into and out of this case as demand dictates. When PL/SQL code, for example, fetches a row, the SQL engine grabs the row from the db cache (SGA) and copies it to the PGA (the private memory area of the PL/SQL process). The row also may not yet exist in the db cache - in which case it needs a physical read from disk to get the data block containing that row into the db cache (after which it is copied to the PGA).
    A PL/SQL process can do a bulk fetch - e.g. fetch a 100 rows from the SQL query/cursor at a time. In that case, a 100 rows are copied from the SGA db cache to the PGA.
    At no time is there are single large unique and dedicated memory struct in the SGA that contains the complete "result set" of a SQL query.
    Once you have fetched that row, that is it. Deal is done. You cannot reverse the cursor and fetch the row again. After you have fetched the last row in that cursor, you cannot pass that cursor to another process - the cursor is now empty. That other process cannot rewind the cursor and start fetching from the 1st row again. You will need to pass the SQL to that process in order for it to create its own cursor - also keeping in mind that in between the rows can have changed and that this other process could now see different results with its cursor.
    If you want to create such a physical temporary result set that is consistent and re-usable, you can use a temporary table - and insert the results of the SELECT into this temp table for further processing. This temp table is session specific and is auto destroyed when the session terminates.
    A comment though - it sounds like you're approaching the date warehouse processing (scrubbing, transformation and loading of data) as a row-by-row process.
    That is a flawed approach. Row-by-row processing does not scale. One should deal with data sets. Especially when the volumes are large. One should also attempt to perform minimal passes through a data set. Processing a bunch of rows, then passing that rows to another process to do some processing on the same rows.. this means multiple passes through the same data. That is very inefficient performance and resource wise.

  • About Result Set

    hi folks,
    am using jsp to display the records from the db via jdbc credentials. ok. i had doubt regarding result set in java..
    In my jsp page i show the records "form" entry format. while loading the page. i used while(rs.next() operation) to get the records from the db. and i fill into the form fields..
    say as eg : employee id: 900
    employee name : zzz
    ok. what is my problem.? while am loading the page it fill all of the records and it showing the last record.
    if suppose while am pressing next button in jsp page. what happen means.. it fill some null value.
    when gave a look to that operation.
    i already get last record when page loads. if i hit next button means there is no such records. so it fills null value.
    so my question is? when page loads i should load first record of query which i have. not last record...
    thanks

    You also might consider carefully re-wording your entire question to clarify the issue as to what the problem is and what >you were expecting. yes, i do.
    There was several sentences in your post that I couldn't follow (conveying technical information is often difficult).yeah!. i feel it. while the volunteer read other side of the globe he/she may feel tough right. i dont give pain here after.
    i did mistake around the resultset. then after i corrected from a wild search over the google.

  • Scrollable result set in PDK How?

    is there any standart possibility
    to work with cursors?
    or only i can do to store entire
    limited result set(in XML m.b.)
    and send back demanded part
    if so when collect garbage?

    O'Rix,
    I am not sure if I understand your question. But, if you are asking if you can use cursors in the PDK, yes, in a Database portlet you can.

  • Writing result set to .csv file

    All,
    I am writing a result set(date and a message as a string)
    if(rs!= null){
                    date = new java.util.Date();
                    String logDate = sdf.format(date);
                    File log = new File(logDate+".csv");
                    writer = new BufferedWriter(new FileWriter(log));
               // 5) Move to first record (and then next) record.
               while(rs.next())
                  writer.write(rs.getString(1) + "," + rs.getString(2) + "\n");
                    rowCount++;
               }Eaxmple:
    1. 2008-03-31 error during
    The problem is when I write this to a .csv file, when opened with excel, the date appears as
    If I right click the column, and select format, I can format the date properly, but I don't want to do this.
    Any suggestions?
    M

    ##### is what Excel usually displays when it can't display the entire cell contents in the width of the column. Try expanding the column in Excel and see if the date appears.

  • Interactive Reporting Reports - Same Rpt Format, but Different Result Set

    I have created a report using result set 1. I've saved that, but want to copy it & use the same format/columns to create a new report using a different result set (the result sets have the same data, but one is filtered). Is there an easy way to change the name of the result set being used w/o re-creating the entire report columns & all?
    Terri

    I am in the Dashboard Studio - Optimize Utility. When I select that report (or any of the others), the Reparent button is grayed out on the toolbar. I've also tried right-clicking on the report and it's grayed out there as well. Any ideas?

  • JDBC Result Set from Non-Database Source

    In Java, is it possible to create a result set from a non-database data source?, for example an XML file, text file, vectors, java beans
    We have a Swing application that currently makes direct JDBC calls to the DB2 database for creating result sets. We want to replace JDBC calls with calls to web service, but want to still create result sets on the client, so the replacement of the datasource from database to web service call is transparent to the rest of the code.

    In Java, is it possible to create a result set from a
    non-database data source?, Yes.
    for example an XML file,
    text file, vectors, java beans
    We have a Swing application that currently makes
    direct JDBC calls to the DB2 database for creating
    result sets. We want to replace JDBC calls with calls
    to web service, but want to still create result sets
    on the client, so the replacement of the datasource
    from database to web service call is transparent to
    the rest of the code.You might want to think carefully about what you are doing.
    It is fairly easy, although somewhat tedious (many methods,) to create a new type of ResultSet.
    But if the above application is doing SQL via statements and expecting the result via a ResultSet then you are not just creating a ResultSet but an entire driver and one that will have to deal with SQL as well. And if you have to handle the SQL itself that means you will probably need a parser and interpreter.

Maybe you are looking for

  • How do i use Jukebox drivers to install firmwa

    I have searched these forums and tried numerous things to get my Zen 20gb to update its firmware. I searched for appropriate updates and found the file JB3MV2_PCWDRV_US__30_03.EXE. It appears that this is the correct update, so i'm wondering what i d

  • Windows 2008 Server R2 not loading Desktop

    Hi All, I have windows 2008 server R2 using as Database server.Today when i try to login it is showing two more user accounts in the login screen and i login to the server with administrator account but it was showing a blue screen(not blue screen er

  • Mac keeps freezing since upgraded to yosemite

    since I have upgraded to Yosemite on my MacBook pro 2009 safari and chrome and many other apps that I try to run freeze and lock up the entire computer. If I wait eventually it will unfreeze. I have tried restarting several times. Could I have a viru

  • My phone won't connect to the internet

    Last night, I was using my blackberry to connect to the internet. It worked. I could browse, I could tweet and reply to them and use the BBM service. When I woke up this morning to check updates, I could not connect to the internet service anymore. T

  • BOM Update using a function module - 'CSAP_MAT_BOM_MAINTAIN'

    Hi, I have problem in updating the item status for a BOM using a function module - 'CSAP_MAT_BOM_MAINTAIN'. My goal is reset the Checkbox for 'Indicator: item relevant to production'. When i pass the value ' '[Space] to the structure field 'T_STPO-RE