Dml returning by row_id on global_temporary table

Hi I have this procedure that inserting into global temporary table
is there a way I can get the rowid or some sort of unique identifier back after I am inserting heres the code example
basically I need to do some sort of processing in the record set into gt_obj table
CREATE GLOBAL TEMPORARY TABLE gt_obj as select * from dba_objects where rownum < 101
select * from gt_obj
declare
type tab_rowid is table of varchar2(101);
lv_rowid tab_rowid;
begin
insert into gt_obj
select * from dba_objects where object_type = 'TABLE' and rownum < 101
returning rowid bulk collect into lv_rowid;
for i in lv_rowid.first..lv_rowid.last
loop
dbms_output.put_line('rowid='||lv_rowid(i));
end loop;
end;

vxwo0owxv wrote:
Hi I have this procedure that inserting into global temporary table
is there a way I can get the rowid or some sort of unique identifier back after I am inserting heres the code example
basically I need to do some sort of processing in the record set into gt_obj table
CREATE GLOBAL TEMPORARY TABLE gt_obj as select * from dba_objects where rownum < 101This is not the appropriate way to create and use a global temp table (GTT).
A GGT should be defined once only. As permanent static definition in the data dictionary. Kind of like an object class definition in an oo language.
A session can then "instantiate" a GTT of that definition. Just like you would create an object of that specific class type in an oo language.
But a GTT is a tad easier to use. You do not need to call its constructor to create it. You do not need to calls its destructor to free and release its allocated memory when done using it.
You create the GTT definition once and up front as part of your database model:
SQL> create global temporary table name_values(
  2     name varchar2(20),
  3     value varchar2(30)
  4  )
  5  on commit preserve rows;
Table created.In a session, you can at anytime now instantiate a GTT using that definition by inserting data into it:
SQL> insert into name_values select 'table', table_name from user_tables where rownum < 11;
10 rows created.You do not run dynamic SQL in PL/SQL to use a CTAS (Create Table As Select) to create GTTs. Oracle is nothing at all like SQL-Server.
for i in lv_rowid.first..lv_rowid.last
loop
dbms_output.put_line('rowid='||lv_rowid(i));
end loop;Why? Yes, GTT rows do have rowids. But why would you want to use it? You just as well can simply read the entire GTT as it contains all your session's data inserted into it. In other words, it contains private session only data. Nothing else.
So what do you achieve by using rowids to loop through the rows in the GTT? It does not make access any faster or more flexible than doing a simple and straightforward select all rows from the GTT.
I suggest you review what a GTT is and how it works.

Similar Messages

  • Automatic Row Processing (DML) - Return Key Into Item

    Hello,
    This question is on Apex 4.2:
    I'm Displaying the [UNIKEY] column value after the record is inserted into the table using :
    page process > process row table_name > Source: Automatic Row Processing (DML) > Return Key Into Item > "Item Name"
    This works fine while inserting records, my question is why this does not respond on update / delete ?
    ϯ LT

    LT
    Check your branches.
    What might be happening is that on insert and update an other branch is followed.
    Where the branch of the insert either isn't clearing the cache of the page or is setting the item with it's own value.
    The branch on the update on the other hand is clearing the cache of the page and not setting the item.
    With a delete there is a clear cache process generate by the wizard. Check if this process is only running on the delete and not on the update.
    From memory the process is called something with reset.
    If the above doesn't help try to replicate the problem on apex.oracle.com and give access with a guest developer account so we can have a look.
    Nicolette

  • DML Returning Values In Forms 6i

    Hi there!
    I am watching the following behavior in Forms 6i:
    Whenever I set DML Returning Value to "Yes" in a data block that corresponds to a table Database (8.0.5) returns to me the updated values, but this doesnot happen with a data block that corresponds to an updatable view. What can I do about that?
    George

    There are many ways you could do this. One way would be to create a When-Validate-Item trigger on the USER_ID field that checks the database to see if the value already exists and raise an exception if it exists. For example:
    /* When-Validate-Item trigger */
    DECLARE
         n_dummy     NUMBER := 0;
         CURSOR test_User_ID IS
              SELECT count(*)
                FROM YOUR_TABLE_NAME_HERE
              WHERE USER_ID = :YOUR_BLOCK_NAME.USER_ID;
    BEGIN
         OPEN test_User_ID;
         FETCH test_User_ID INTO n_dummy;
         CLOSE test_User_ID;
         IF ( n_dummy > 0 ) THEN
              MESSAGE('User ID " '||:YOUR_BLOCK_NAME.USER_ID||' " already exists.  Please enter a unique User ID.',ACKNOWLEDGE);
              RAISE Form_Trigger_Failure;
         END IF;
    END;Please understand that this is just sample code and will need to be modified in order to work in your form. Also note, I'm not positive the "ACKNOWLEDGE" parameter to the MESSAGE built-in is valid for Forms 6i. Please confirm this before using.
    Hope this helps.
    Craig...
    If mine or someone else's response is helpful or correct, please mark it accordingly

  • How to get value from API which returns parameter in PL/SQL table?

    Hello
    I have below workflow API with returns info in PL/SQL table. I want to get value of 'USER_ORIG_SYSTEM_ID' column. How can i get that value in local variable.
    Please help.
    Thanks
    Avalon
    Wf_Directory.GetRoleInfo2
    Syntax
    procedure GetRoleInfo2
    (Role in varchar2,
    Role_Info_Tbl out wf_directory.wf_local_roles_tbl_type);
    Description
    Returns the following information about a role in a PL/SQL table:
    • Name
    • Display name
    • Description
    • Notification preference (’QUERY’, ’MAILTEXT’, ’MAILHTML’,
    ’MAILATTH’, ’MAILHTM2’, ’SUMMARY’, or, for Oracle
    Applications only, ’SUMHTML’)
    • Language
    • Territory
    • E–mail address
    • Fax
    • Status
    • Expiration date
    • Originating system
    • Originating system ID
    • Parent originating system
    • Parent originating system ID
    • Owner tag
    • Standard Who columns
    *******************************************************

    create a variable RoleXXX wf_directory.wf_local_roles_tbl_type;
    call procedure GetRoleInfo2('TEST_ROLE',RoleXXX)
    use RoleXXX.USER_ORIG_SYSTEM_ID

  • RFC returning PDF form in Binary table

    Hello,
    In our earlier application we were using a RFC to return PDF form as a table of binary fields and then these fields were concatenated and .pdf extension addded at the end. This will then display correctly in browser as a pdf form. Typically, this returns about 30000+ lines of binary for one form.
    Now we are migrating this application to Portal and I'm trying to display all this information through Adobe Interactive form. We do not currently have any other RFC to return all data that is part of the existing PDF document returned by current RFC. Getting all that data through one RFC is a tedious and time consuming task that we want to avoid. Is there a way to use the binary table returned by existing application and convert it to a pdf form? I was thinking of using the 'pdfsource' property of Interactive form - but am not sure about the possibilities.
    Can anyone help with some pointers?
    Thanks,
    Vishwas.

    I'm using following code to concatenate the binary string and then to display the PDF file.
    Concatenation was being done in earlier application and there is no code available for reference. I've tried following code, it opens the Adobe PDF viewer but it always shows error "File does not start with %PDF-". Please let me know if the code below is correct or is there something I need to do differently.
      public void wdDoInit()
        //@@begin wdDoInit()
    IWDMessageManager manager = wdComponentAPI.getMessageManager();
    //Populate data for RFC
    wdContext.currentZ_Sd_Get_Output_Pdf_Verify_InputElement().setKappl("V1");
    wdContext.currentZ_Sd_Get_Output_Pdf_Verify_InputElement().setKschl("ZA00");
    wdContext.currentZ_Sd_Get_Output_Pdf_Verify_InputElement().setKunag("0001000021");
    wdContext.currentZ_Sd_Get_Output_Pdf_Verify_InputElement().setKunwe("0001000023");
    wdContext.currentZ_Sd_Get_Output_Pdf_Verify_InputElement().setVbeln("0000018261");
    //Call RFC
    wdThis.wdGetPDF_from_Binary_compController().executeZ_Sd_Get_Output_Pdf_Verify_Input();
      int num = wdContext.nodePdf4().size();
    //Initial string
      String s = "";
    for(int n=0;n<num;n){
    //Concatenate binary data in string with Radix 2
    BigInteger bi = new BigInteger(wdContext.nodePdf4().getPdf4ElementAt(n).getData());
    s= bi.toString(2);+
       manager.reportSuccess(s);
    // Display pdf
        IWDResource resource = WDResourceFactory.createCachedResource(s.getBytes(), "file.pdf", WDWebResourceType.PDF);
        IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getUrl(0),"file.pdf");
        window.show();
       //@@end
    It opens the Adobe PDF viewer but gives error "file does not start with %PDF-".
    What is it that I'm not doing correctly here?
    Thanks,
    Vishwas.
    The data being returned from RFC is in RAW format. Is it same as Binary?
    Edited by: Vishwas Madhuvarshi on Mar 6, 2008 10:54 PM

  • Automatic Row Processing (DML) using synonym name instead of table

    I want my APEX form to select info using the table name but perform all the DML (add, change, delete) using the synonym name. I created the form using the wizard and went into the "Process Row of xxx" process that was created. I tried changing the table name to synonym name under the 'Source: Automatic Row Processing (DML)' section, but it still uses the table name. Is this possible or do I need to manually create processes using the synonym names

    Hi,
    when I change the Table Name property in the "Automatic Row Processing (DML)" process to a non existing table it raises an error when I run the page and try to save something. So it's actually using the value.
    Does the synonym point to the same table or a different table? What is the intention behind selecting from the table but updating through the synonym?
    Patrick
    My APEX Blog: http://www.inside-oracle-apex.com/
    The APEX Builder Plugin: http://builderplugin.oracleapex.info/
    The ApexLib Framework: http://apexlib.sourceforge.net/

  • Point cloud clip doesn't return anything in the result table

    Hi experts,
    I am wondering why my point cloud clipping function does not return anything into the result table.
    The boundaries of my point cloud are:
    min long 316,500
    max long 316,643.21
    min lat 234,000
    max lat 234,105.38
    min elevation -4.79
    max elevation 30.87
    For the ind_dimquery I have tried different geometry types, like 3003 and 3008, usually with the elem_info_array (1,1007,3)
    like in the following example:
    SQL> declare
    2 inp sdo_pc;
    3 begin
    4 select pc into inp from base109 where rownum=1;
    5 insert into restst
    6 select * from table(sdo_pc_pkg.clip_pc(
    7 inp,
    8 sdo_geometry(3003, 29903, null,
    9 mdsys.sdo_elem_info_array(1,1007,3),
    10 mdsys.sdo_ordinate_array(316510, 234080, -3, 316550, 234100, 2)),
    11 null, null, null, null));
    12 end;
    13 /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.20
    SQL> select count(*) from restst;
    COUNT(*)
    0
    What am I doing wrong? This should be a query window within the right area and I know that at least one point lies within this defined window.
    Any help is greatly appreciated!!!!!
    Cheers,
    F.

    yes exactly, I have tried all of this already.
    For a further example, there is a point in:
    POINTS(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    R G B I POINT_ID
    SDO_GEOMETRY(3001, 29903, SDO_POINT_TYPE(316503.49, 234089.46, 3.32), NULL, NULL
    71 91 78 70 55
    so theoretically, I'd feel that at the VERY LEAST this point should be in the 3008geometry and 1007 elem array for the coordinates for xmin, y min, zmin, xmax, ymax, zmax for
    316500, 234080, 2, 316510, 234100, 5
    but...nothing. Nothing in the result table.
    For full query:
    SQL> declare
    2 inp sdo_pc;
    3 begin
    4 select pc into inp from base109 where rownum=1;
    5 insert into restst
    6 select * from table(sdo_pc_pkg.clip_pc(
    7 inp,
    8 sdo_geometry(3008, 29903, null,
    9 mdsys.sdo_elem_info_array(1,1007,3),
    10 mdsys.sdo_ordinate_array(316500, 234080, 2, 316510, 234100, 5)),
    11 null, null, null, null));
    12 end;
    13 /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.13
    SQL> select count(*) from restst;
    COUNT(*)
    0

  • Return the rows of the table where a column contains a specific value first

    I want my query to return the rows of the table where a column contains a specific values first in a certain order, and then return the rest of the rows alphabetized.
    For Example:
    Country
    ALBANIA
    ARGENTINA
    AUSTRALIA
    CANADA
    USA
    Now i want USA and CANADA on top in that order and then other in alphabetized order.
    Edited by: 986155 on Feb 4, 2013 11:12 PM

    986155 wrote:
    If it is 2 then i can write a case... i want generalised one where may be around 5 or 6 mentioned should be in descending order at the top and remaining in ascending order there after.Computers tend not to work in 'generalized' ways... they require specifics.
    If you store your "top" countries in a table you can then simply do something like...
    SQL> ed
    Wrote file afiedt.buf
      1  with c as (select 'USA' country from dual union
      2             select 'Germany' from dual union
      3             select 'India' from dual union
      4             select 'Australia' from dual union
      5             select 'Japan' from dual union
      6             select 'Canada' from dual union
      7             select 'United Kingdom' from dual union
      8             select 'France' from dual union
      9             select 'Spain' from dual union
    10             select 'Italy' from dual
    11           )
    12      ,t as (-- top countries
    13             select 'USA' country from dual union
    14             select 'United Kingdom' from dual union
    15             select 'Canada' from dual
    16            )
    17  select c.country
    18  from   c left outer join t on (t.country = c.country)
    19* ORDER BY t.country, c.country
    SQL> /
    COUNTRY
    Canada
    USA
    United Kingdom
    Australia
    France
    Germany
    India
    Italy
    Japan
    Spain
    10 rows selected.

  • Help with query to return results from group within table?

    Hi
    Im a total noob, so please be gentle....!
    I am looking at a table that has a WORD column and a WORD_TYPE_ID column.
    Words can have the same type_id.
    What I am trying to do is write a query that will return the longest word for each word_type_id.
    I have been trying for hours to get this and all I seem to get is either error messages or I return the longest word in the whole WORD column.
    The furthest I can get before things break down is.....
    select word
    from table
    where
    length(word) =
    select
    max(length(word))
    from table
    Any help on this or if I could be pointed in the right direction it would be greatly appreciated.
    Thanks

    Hi,
    Welcome to the forum!
    Here's one way:
    SELECT    word_type_id
    ,       MIN (word) KEEP (DENSE_RANK LAST ORDDER BY LENGTH (word))     AS longest_word
    FROM       table_x
    GROUP BY  word_type_id;If there happens to be a tie within some word_type_id (that is, 2 or more words have exactly the same length, which is the longest in that group) the expression above will return the first one, in alphabetic order. (That's what MIN means here.)
    Edited by: Frank Kulash on Aug 11, 2009 1:56 PM
    You almost had it.
    As you noticed, you were getting the longest row in the whole table. That's because your sub-query was looking at the whole table.
    If you correlate the sub-query to the row in the main table, as shown below, you can get the longest word in each group:
    select  word
    from     table     m                              -- m for main
    where      length (word) = (
                                select  max (length(word))
                   from     table
                   where     word_type_id  = m.word_type_id     -- New
                   );

  • What is the Function MOdule that returns the fields in database table order

    Hello Folks
      I have a dynamic internal table with fields ( which are not in order). I want to display them in the order of which they are present in the database table? Is there any function module that returns the fields in database order?
    FAQ. Please search before posting your question.
    Edited by: Suhas Saha on Oct 10, 2011 10:19 PM

    Hi,
    You can use this BAPI.
    <b>BAPI_SALESORDER_GETLIST</b>
    Reward if useful.
    Regards,
    Vimal

  • Returning multiple values from a table

    Hi there i am working on a bit of sql which will return values when they exist in a table.
    The code I have returns the correct value when there is only one entry in the tbl_studentmodules table, as soon as there is more than one entry in this table it displays no rows at all :(.
    Can anyone point out how I go about returning multiple values?
                 select modulename from tbl_modulefeedback
    where 1 = (select count(*) from tbl_studentmodules
           where upper(:APP_USER) = upper(student_id))
    and 1 = (select count(*) from tbl_modulefeedback, tbl_studentmodules
          where tbl_modulefeedback.modulecode = tbl_studentmodules.modulecode)Thanks in advance!
    Ashleigh

    I'm not quite sure I understand what you are looking for, but I think a simple join may be what you need. something like:
    select modulename
    from tbl_modulefeedback mfb
       join tbl_studentmodules sm
          on mfb.modulecode = sm.modulecode
    where upper(sm.student_id) = upper(:APP_USER)This will return the module name for all modules that the given student has provided feeedback for. If there is a possibility that a student/module combination could appear in tbl_studentmodules more than once, something like this might be better to show the modulename only once.
    select modulename
    from tbl_modulefeedback mfb
    where mfb.modulecode in (select sm.modulecode
                             from tbl_studentmodules sm
                             where mfb.modulecode = sm.modulecode and
                                   upper(sm.student_id) = upper(:APP_USER))If this is not what you want, then post some sample data (preferrable in the form of insert statements or a with clause) and the results you expect rom that sample data.
    John

  • Using the XML returned by XI to populate table in Web Dynpro UI

    Hi,
    In Web Dynpro,I have a scenario where i have to generate reports. For this, I enter the "Customer number", "Date" & "Item No" in 'Generate report' page  and hit the "submit" button. These details are sent as XML to XI which interacts with the ABAP R/3 system, performs the search and returns the search results as an XML
    Now, I want to display search results contained in this XML by populating it in a table.
    From, the point where the XML is returned by XI, could you please tell me the step by step process to populate this XML in a table. Please include code, if any.
    Kindly help.

    Hello Sandeep,
    Create context node with following strucure:
    <i>
    result
    -CustomerNumber
    -ItemNumber
    -Material
    -OrderDate</i>
    Create data handler:
    public class XIDataHandler extends DefaultHandler {
         private String lastAttribute;
         private IWDNodeElement newElement;
         public void startElement(String namespaceURI, String localName, String rawName, Attributes atts) {
              if ("Result".equals(localName)) {
                   newElement = wdContext.createResultElement();
                   wdContext.nodeResult().addElement(newElement);
              } else {
                   if(null!=newElement)
                        lastAttribute = localName.trim();
         public void endElement(String namespaceURI, String localName, String rawName) {
              if ("Result".equals(localName)) {
                   newElement = null;
                   lastAttribute = null;
         public void characters(char[] data, int off, int length) {
              if(null!=newElement && null!=lastAttribute) {
                   final String value = new String(data, off, length).trim();
                   if(!"".equals(value)) {
                        newElement.setAttributeValue(lastAttribute, value);
    And parse XML in appropriate place within your application:
    try {
         SAXParserFactory factory = SAXParserFactory.newInstance();
         SAXParser parser = factory.newSAXParser();
         //Loading XML from string (XI_DOCUMENT), change if source differs
         StringReader sr = new StringReader(XI_DOCUMENT.trim());
         InputSource is = new InputSource(sr);
         parser.parse(is, new XIDataHandler());
    } catch (Exception e) {
         final StringWriter sw = new StringWriter();
         final PrintWriter pw = new PrintWriter(sw);
         e.printStackTrace(pw);
         wdComponentAPI.getMessageManager().reportException(sw.toString(), true);
    Create table and table columns and map your context to it.
    Best regards, Maksim rashchynski.

  • How to return column name in some table?

    Hi All,
    I know :system.cursor_value which returns the value of the current text item in the form.
    But Is there a way to return the column name and its value in some table?
    Note: I'm using Oracle DB 10g
    Thank you

    Did you read the original post? [...] You don't understand what I want and you don't say antthing useful for my goal!
    This is the SQL and PL/SQL forum. You need the Mind-Readers' forum down the hall.
    First you asked "Is there a way to return the column name and its value in some table?", and were told you can get the former from the data dictionary (you can get the latter from the table itself).
    Then you say you "want to create a trigger on a table", which tells us nothing about your problem.
    Finally you say "but suppose the table contains 50 columns then I have to write 50 columns names three times", which is essentially true - but the process can be automated. What you (probably) need to do is write queries based on the data dictionary tables that generates the PL/SQL that you ultimately put in your triggger - you then use that output to build the trigger(s).
    I don't think there's any way, at run time, to generically fish out all the columns of a table with their :new and :old values - you have to write (or auto-generate) specific code for each table.

  • Return the Minimum from two tables in a Union

    Hello
    I have written a simple union query from our dialler service which has 2 tables, in inbound and an outbound table. A lead can show in any table depending how they came through to an agent and they can also show in both tables.  I need to return the
    the first instance in the calltime column from both tables but also return all the other information.  I'm expecting multiple entries for the minimum calltime which is fine, I will be using a lookup in excel to extract the time.  Just to make matters
    a little more difficult i'm having to use the OPENQUERY function because its within MYSQL.
    SELECT O.Lead, O.DataList, O.[CallTime] AS 'CallDate', O.[Status], O.Uniqueid, O.Campaign, O.number, O.Advisor, 'Outbound' AS CallType
    FROM OPENQUERY (dialler, 'SELECT * FROM dialler_outbound_data') O
    WHERE O.CallTime >= '2014-12-01'
    UNION
    SELECT I.Lead, I.DataList, [CallTime] AS 'CallDate', I.[Status], I.Uniqueid, I.Campaign, I.Number, I.Advisor, 'Inbound' AS CallType
    FROM OPENQUERY (dialler, 'SELECT * FROM dialler_inbound_data') I
    WHERE I.CallTime >= '2014-12-01'
    Can anyone help please?
    Many Thanks
    Rich

    Hi Rich,
    The use of the ROW_NUMBER function as mentioned and temp tables should do the trick.  See the code below...hope this helps.
    SELECT ROW_NUMBER() OVER(ORDER BY O.[CallTime]) as 'Occurrance'
    ,O.Lead
    ,O.DataList
    ,O.[CallTime] AS 'CallDate'
    ,O.[Status]
    ,O.Uniqueid
    ,O.Campaign
    ,O.number
    ,O.Advisor
    ,'Outbound' AS CallType
    INTO #TEMP1
    FROM OPENQUERY (dialler, 'SELECT * FROM dialler_outbound_data') O
    WHERE O.CallTime >= '2014-12-01'
    SELECT ROW_NUMBER() OVER(ORDER BY I.[CallTime]) as 'Occurrance'
    ,I.Lead
    ,I.DataList
    ,[CallTime] AS 'CallDate'
    ,I.[Status]
    ,I.Uniqueid
    ,I.Campaign
    ,I.Number
    ,I.Advisor
    ,'Inbound' AS CallType
    INTO #TEMP2
    FROM OPENQUERY (dialler, 'SELECT * FROM dialler_inbound_data') I
    WHERE I.CallTime >= '2014-12-01'
    INSERT INTO #FINAL
    SELECT * FROM #TEMP1
    UNION
    SELECT * FROM #TEMP2
    SELECT * FROM #FINAL AS F WHERE F.Occurrance = 1
    I'm new to this so if this helps, I could use your vote. 
    Thanks,
     Zach

  • Using index in a query return few records than full table access

    Today we have an issue with a query, when it use the ok index the returned are not all records that apply to where clause condition.
    See bellow
    explain plan for
    select * from movdb.zan_m03 where
    M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
    M00za = 10 AND
    m00AC = 50 AND
    M00AD between 136906 and 136999
    SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1882720105
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | TABLE ACCESS BY INDEX ROWID| ZAN_M03 |
    |* 2 | INDEX RANGE SCAN | PK_ZAN_M03 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
    2 - access("M00AF"=TO_DATE('11/01/28','YY/MM/DD') AND "M00ZA"=10 AND
    "M00AC"=50 AND "M00AD">=136906 AND "M00AD"<=137141)
    filter("M00AD"<=137141 AND "M00AD">=136906)
    Note
    - rule based optimizer used (consider using cbo)
    20 rows selected.
    The query above return only one row insted 1579 record that apply to this conditions.
    When forcing a full table acess with a hint, the query return all records that apply, the 1579 record.
    select /*+ FULL(zan_m03) */ M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
    M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
    M00za = 10 AND
    m00AC = 50 AND
    M00AD between 136906 and 137141
    Can you help me to identify what's happening?
    I am with Oracle 10g R2 10.2.0.4 standard edition
    the statistics are up to date
    the opitimizer_mode are rule, but altering in session level to all_rows happens the same issue.
    Nothing about corruption in the alert log.
    Thanks in advance
    Regards
    Cristiano

    Yes the query are the same and correct restriction for where clause are M00AD between 136906 and 137141.
    I've pasted, by mistake, another test query
    The corrects are:
    select M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
    M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
    M00za = 10 AND
    m00AC = 50 AND
    M00AD between 136906 and 137141
    This use pk index and return one row
    select /*+ FULL(zan_m03) */ M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
    M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
    M00za = 10 AND
    m00AC = 50 AND
    M00AD between 136906 and 137141
    This does a full table access and return 1579 records
    I´ve been searching for wrong results bugs on my oracle support, but not found one that mentions something like our issue.
    I checked the dba_tables and dba indexes and the number of rows are different, and I think this would be the same because it's is a pk.
    Look this
    SQL> select NUM_ROWS from dba_tables where table_name = 'ZAN_M03'
    2 /
    NUM_ROWS
    228527878
    select NUM_ROWS from dba_indexes where index_name = 'PK_ZAN_M03';
    SQL> select NUM_ROWS from dba_indexes where index_name = 'PK_ZAN_M03';
    NUM_ROWS
    217510185
    Is normal a index for pk having much fewer rows than table? I think not, but not sure.
    Again
    Thanks in advance
    Regards
    Cristiano

Maybe you are looking for