New table without statistics returns invalid number of rows

Hi,
I've been searching for a while now for an explanation for the following "problem"
We have an Oracle 11.1.0.7 database on AIX5.3
In this database we have two tables, called KRT_PRODUCTS_INFO and KRT_STRUCTURES_INFO ( the table name don't really matter ).
The scenario is as following:
If we recreate these tables like:
CREATE TABLE KRT_PRODUCT_INFO_BUP AS SELECT * FROM KRT_PRODUCT_INFO;
DROP TABLE KRT_PRODUCT_INFO CASCADE CONSTRAINTS;
CREATE TABLE KRT_PRODUCT_INFO (...) TABLESPACE PIM_DATA NOLOGGING NOCOMPRESS NOCACHE NOPARALLEL MONITORING;
CREATE INDEX KRT_PRODUCT_INFO_X1 ON KRT_PRODUCT_INFO (PRODUCT_NUMBER) NOLOGGING TABLESPACE PIM_DATA NOPARALLEL;
CREATE INDEX KRT_PRODUCT_INFO_X2 ON KRT_PRODUCT_INFO (PIM_ARTICLEREVISIONID) NOLOGGING TABLESPACE PIM_DATA NOPARALLEL;
INSERT INTO KRT_PRODUCT_INFO (SELECT * FROM KRT_PRODUCT_INFO_BUP);
COMMIT;
CREATE TABLE KRT_STRUCTURE_INFO_BUP AS SELECT * FROM KRT_STRUCTURE_INFO;
DROP TABLE KRT_STRUCTURE_INFO CASCADE CONSTRAINTS;
CREATE TABLE KRT_STRUCTURE_INFO (...) TABLESPACE PIM_DATA NOLOGGING NOCOMPRESS NOCACHE NOPARALLEL MONITORING;
CREATE INDEX KRT_STRUCTURES_X1 ON KRT_STRUCTURE_INFO (STRUCTURE_GRP_REV_ID) NOLOGGING TABLESPACE PIM_DATA NOPARALLEL;
CREATE INDEX KRT_STRUCTURES_X2 ON KRT_STRUCTURE_INFO (STRUCTURE_GRP_IDENTIFIER) NOLOGGING TABLESPACE PIM_DATA NOPARALLEL;
CREATE INDEX KRT_STRUCTURES_X3 ON KRT_STRUCTURE_INFO (STRUCTURE_GRP_ID) NOLOGGING TABLESPACE PIM_DATA NOPARALLEL;
INSERT INTO KRT_STRUCTURE_INFO (SELECT * FROM KRT_STRUCTURE_INFO_BUP);
COMMIT;
and we run a complex query with these two tables, this query only return a couple of rows ( exactly 24 !!! )
If we however generate statistics on these tables after creation, the correct number of rows is returned, being 1.167.991 rows
The statistics are gathered using:
BEGIN
SYS.DBMS_STATS.GATHER_TABLE_STATS (
OwnName => 'PIM_KRG'
,TabName => 'KRT_PRODUCT_INFO'
,Estimate_Percent => NULL
,Method_Opt => 'FOR ALL COLUMNS SIZE REPEAT '
,Degree => NULL
,Cascade => TRUE
,No_Invalidate => FALSE);
END;
BEGIN
SYS.DBMS_STATS.GATHER_TABLE_STATS (
OwnName => 'PIM_KRG'
,TabName => 'KRT_STRUCTURE_INFO'
,Estimate_Percent => NULL
,Method_Opt => 'FOR ALL COLUMNS SIZE REPEAT '
,Degree => NULL
,Cascade => TRUE
,No_Invalidate => FALSE);
END;
/I can imagine that the 'plan' for the query used is wrong because of missing statistics.
But I can't imagine that it would actually return an incorrect number of rows.
I tested this behaviour in Toad and sqlplus ( first thought it was Toad ), and both behave the same.
Another fact is, that the "problem" is NOT reproducable on our TEST environment, that runs on Oracle 11.1.0.7 on Windows2008
Just to be sure this is the "complex" query used. It is not developed by me, and I think it looks somewhat strange but that shouldn't matter:
SELECT sr."Identifier" STRUCTURE_IDENTIFIER
, ar_i."Identifier" ITEM_NUMBER
, SUM (REPLACE (NVL (s.HIDE_LE10, 0) + NVL (p.HIDE_LE10, 0), 2, 1))
hide_le10
, SUM (REPLACE (NVL (s.HIDE_LE30, 0) + NVL (p.HIDE_LE30, 0), 2, 1))
hide_le30
, SUM (REPLACE (NVL (s.HIDE_LE40, 0) + NVL (p.HIDE_LE40, 0), 2, 1))
hide_le40
, SUM (REPLACE (NVL (s.HIDE_LE50, 0) + NVL (p.HIDE_LE50, 0), 2, 1))
hide_le50
, SUM (REPLACE (NVL (s.HIDE_LE55, 0) + NVL (p.HIDE_LE55, 0), 2, 1))
hide_le55
, SUM (REPLACE (NVL (s.HIDE_LE60, 0) + NVL (p.HIDE_LE60, 0), 2, 1))
hide_le60
, SUM (REPLACE (NVL (s.HIDE_LE70, 0) + NVL (p.HIDE_LE70, 0), 2, 1))
hide_le70
, SUM (REPLACE (NVL (s.HIDE_LE75, 0) + NVL (p.HIDE_LE75, 0), 2, 1))
hide_le75
, SUM (REPLACE (NVL (s.HIDE_LE58, 0) + NVL (p.HIDE_LE58, 0), 2, 1))
hide_le58
, SUM (REPLACE (NVL (s.HIDE_LE80, 0) + NVL (p.HIDE_LE80, 0), 2, 1))
hide_le80
, SUM (REPLACE (NVL (s.HIDE_LE90, 0) + NVL (p.HIDE_LE90, 0), 2, 1))
hide_le90
, SUM (REPLACE (NVL (s.HIDE_LE92, 0) + NVL (p.HIDE_LE92, 0), 2, 1))
hide_le92
, SUM (REPLACE (NVL (s.HIDE_LE94, 0) + NVL (p.HIDE_LE94, 0), 2, 1))
hide_le94
, SUM (REPLACE (NVL (s.HIDE_LE96, 0) + NVL (p.HIDE_LE96, 0), 2, 1))
hide_le96
, COUNT (*) cnt
FROM KRAMP_HPM_MAIN."StructureRevision" sr
, KRAMP_HPM_MAIN."StructureGroupRevision" sgr
, KRAMP_HPM_MASTER."ArticleStructureMap" asm
, KRAMP_HPM_MASTER."ArticleRevision" ar_p
, KRAMP_HPM_MASTER."ArticleDetail" ad_p
, KRAMP_HPM_MASTER."ArticleRevision" ar_i
, KRAMP_HPM_MASTER."ArticleDetail" ad_i
, KRAMP_HPM_MASTER."ArticleReference" ar
, KRT_STRUCTURE_INFO s
, KRT_PRODUCT_INFO p
WHERE sr."StructureID" = sgr."StructureID"
AND sgr."StructureGroupID" = asm."StructureGroupID"
AND ar_p."ID" = asm."ArticleRevisionID"
AND ar_p."ID" = ad_p."ArticleRevisionID"
AND ad_p."Res_Text100_02" = 'PRODUCT'
AND ar_i."ID" = ad_i."ArticleRevisionID"
AND ad_i."Res_Text100_02" = 'ARTICLE'
AND ar."ArticleRevisionID" = ar_p."ID"
AND ar."ReferencedSupplierAID" = ar_i."Identifier"
AND s.STRUCTURE_GRP_REV_ID = sgr."ID"
AND p.PIM_ARTICLEREVISIONID = ar_p."ID"
GROUP BY sr."Identifier", ar_i."Identifier";Any ideas are welcome..
Thanks
FJFranken

Hemant K Chitale wrote:
These two tables are in the PIM_KRG schema while the other tables in the query are distributed across two other schemas "KRAMP_HPM_MAIN" and "KRAMP_HPM_MASTER" ?
Do you happen to have the same table names occurring in multiple schemas - the query is then referencing the data in the wrong schema ?
Hemant K ChitaleHi,
This is not the case. The KRAMP_HPM schema's are application dedicated schema's
And this also then does not explain why the results are correct after generating statistics.
Anyway thanks for the tip.
FJFranken

Similar Messages

  • Return specific number of rows depending on the data in a column in table

    Hi,
    I have a table named orders which has column orderid and noofbookstoorder in addition to other columns.
    I want to query the orders table and depending on the value of the 'noofbookstoorder' value return that number of rows.
    Eg
    Orderid noofbookstoorder
    1 1
    2 3
    3 2
    when I query the above data saying
    select * from orders where orderid=2;
    since it has noofbookstoorders value as 3 the query should return 3 rows and when I query
    select * from orders where orderid=3;
    it should return 2 rows and
    select * from orders where orderid=1;
    should return 1 row.
    Is it possible to achieve this. If yes, then how do I write my query.
    Thanks in advance.

    with t as (
               select 1 Orderid,1 noofbookstoorder from dual union all
               select 2,3 from dual union all
               select 3,2 from dual
    select  t.*
      from  t,
            table(cast(multiset(select 1 from dual connect by level <= noofbookstoorder) as sys.OdciNumberList))
      where Orderid = <order-id>
    /For example:
    SQL> with t as (
      2             select 1 Orderid,1 noofbookstoorder from dual union all
      3             select 2,3 from dual union all
      4             select 3,2 from dual
      5            )
      6  select  t.*
      7    from  t,
      8          table(cast(multiset(select 1 from dual connect by level <= noofbookstoorder) as sys.OdciNumberList))
      9    where Orderid = 2
    10  /
       ORDERID NOOFBOOKSTOORDER
             2                3
             2                3
             2                3
    SQL> with t as (
      2             select 1 Orderid,1 noofbookstoorder from dual union all
      3             select 2,3 from dual union all
      4             select 3,2 from dual
      5            )
      6  select  t.*
      7    from  t,
      8          table(cast(multiset(select 1 from dual connect by level <= noofbookstoorder) as sys.OdciNumberList))
      9    where Orderid = 3
    10  /
       ORDERID NOOFBOOKSTOORDER
             3                2
             3                2
    SQL> with t as (
      2             select 1 Orderid,1 noofbookstoorder from dual union all
      3             select 2,3 from dual union all
      4             select 3,2 from dual
      5            )
      6  select  t.*
      7    from  t,
      8          table(cast(multiset(select 1 from dual connect by level <= noofbookstoorder) as sys.Odc
    iNumberList))
      9    where Orderid = 1
    10  /
       ORDERID NOOFBOOKSTOORDER
             1                1
    SQL>  -- And if you want to select multiple orders
    SQL> with t as (
      2             select 1 Orderid,1 noofbookstoorder from dual union all
      3             select 2,3 from dual union all
      4             select 3,2 from dual
      5            )
      6  select  t.*
      7    from  t,
      8          table(cast(multiset(select 1 from dual connect by level <= noofbookstoorder) as sys.Odc
    iNumberList))
      9    where Orderid in (2,3)
    10  /
       ORDERID NOOFBOOKSTOORDER
             2                3
             2                3
             2                3
             3                2
             3                2
    SQL> SY.
    Edited by: Solomon Yakobson on Oct 26, 2009 7:36 AM

  • Loop through a csv file and return the number of rows in it?

    What would be simplest way to loop through a csv file and
    return the number of rows in it?
    <cffile action="read" file="#filename#" output="#csvstr#"
    >
    <LOOP THROUGH AND COUNT ROWS>

    ListLen(). Use chr(13) as your delimiter

  • How do you return the number of Rows in a ResultSet??

    How do you return the number of Rows in a ResultSet? It's easy enough to do in the SQL query using COUNT(*) but surely JDBC provides a method to return the number of rows.
    The ResultSetMetaData interface provides a method for counting the number of columns but nothing for the rows.
    Thanks

    No good way before JDBC2.0. u can use JDBC2.0 CachedRowSet.size() to retrieve the number of rows got by a ResultSet.

  • Insert into table error - ora-01722 invalid number

    Need some assistance with inserting data into a table. The date column keeps on failing to insert.
    here is my insert statement
    insert into tab_mod_history (TABLE_OWNER, TABLE_NAME, PARTITION_NAME, SUBPARTITION_NAME, INSERTS, UPDATES, DELETES, TIMESTAMP, TRUNCATED)
    values ('$i_owner','$i_table','$i_part_name','$i_subpart_name','$i_ins','$i_upd','$i_del','$time','$trunc');Script loads data for partition tables, but not normal tables with the timestamp column
    I select the data using this select statement:
    select table_owner, table_name, partition_name, subpartition_name, inserts, updates, deletes, timestamp, truncated
    from dba_tab_modifications
    where table_owner in ('scott','MAC')
    order by table_name;

    ok here are the errors:
    values ('MAC','WC_MST','11','1','1','12/04/2011','NO','','')
    ERROR at line 2:
    ORA-01722: invalid number
    Session altered.
    values ('MAC','WF_05A','208','128','208','18/02/2011','NO','','')
    ERROR at line 2:
    ORA-01722: invalid numberHere is the table structure
    SQL> desc tab_mod_history
    Name                                      Null?    Type
    TABLE_OWNER                                        VARCHAR2(30)
    TABLE_NAME                                         VARCHAR2(30)
    PARTITION_NAME                                     VARCHAR2(30)
    SUBPARTITION_NAME                                  VARCHAR2(30)
    INSERTS                                            NUMBER
    UPDATES                                            NUMBER
    DELETES                                            NUMBER
    TIMESTAMP                                          DATE
    TRUNCATED                                          VARCHAR2(3)
    DROP_SEGMENTS                                      NUMBERI used the column names to create the variables..that is why $time was used.
    How else could I have done it????
    thought this was easy..but to my dismay...

  • XMLType toobject return invalid number while providing the XML Schema/DTD

    We are exploring an option of converting XML into an oracle object and found toobject procedure that does the job. It works fine without XML Schema and provides XML data as oracle object. But it takes more time in parsing the XML since it uses canonical mapping. I hope by providing XML Schema we can improve the performance of this procedure. However when we use toobject with XML Schema it reports error as INVALID NUMBER irrespective of the input XML changes. Could anyone help me in this regard?

    Sorry
    The option of using toObect() to get an instance of the object that was creaed by regidsteing an XML Schema with the database, or which is associated with an XML Schema that has been registered with the database is depricated and will be removed in the next release. The main reason for this is that we reserve the right to change the structure, naming conventions or any other aspects of the object model we dervie from an XML schema, even as a result of a one-off patch, and consequently any code that was written to rely on this mapping would be broken on a regular basis.
    We do gurantee that code that uses the XML abstraction (eg XPATH/XQUERY) to access the content of the XML will work unchanged...
    In you case you have 2 options...
    1. Use the canonical mapping mechansim
    2. Write code that instantiates the objects from the outpiut of an XMLTable...
    -M

  • Install CS4 web premium on a new computer without "old product/serial number" that I need to validate this copy?

    I am trying to install CS4 web premium on a new computer and have the serial number/date of purchase for this product, but at the start of installation it wants an old product previously installed and what that serial number is.  There's a chance it's on some old computer in a box, but I haven't seen / used a product besides CS4 in years (purchased in 2011) and don't know how I can put it on this new computer & get back to using it without knowing this mystery serial number? Thanks for your help & suggestions

    It appears you purchased an upgrade version of CS4 and if so you are required to prove that you qualify for using it.  This means you need to identify the old version and its serial number - no way around that.  You will need to find that mystery version information.  If you check your Adobe account online you might find it.

  • To_number function return Invalid number

    Dear All,
    We have problem recently regarding one of our query that using to_number function. It worked smoothly for 4-5 years until recently our client complaints that the query is returning error ORA-01722: invalid number.
    This is the SQL Script -> SELECT * FROM <table_name> WHERE to_number(b) between :param1 and :param2;
    * Column b is defined as VARCHAR2(20)
    First thing that come to my mind is this error is due to invalid value entered by user. Using the solutions provided by users in this forum and internet, I created SQL a function that checks whether the value is numeric or not.
    So, when I run the query (+SELECT b from <table_name> WHERE is_numeric(b) = 0 AND ROWNUM < 20+) this is the result that I get.
    b
    251567
    251568
    251569
    251570
    251571
    (Up to 11 record; value from 251567 - 251577)
    Is there any limitation on the maximum value that can be converted using to_number* function?*
    I have search the solutions over the internet and I accept the solution/recommendation that we should not store numeric value on varchar/char column; but I hope somebody can explain why I can't use to_number to convert the above figures to numeric, because when I execute SELECT to_number('251567') FROM DUAL it doesn't returned any error)
    Thank you in advance for any help or clarification on this issue.
    Edited by: user5535734 on Apr 16, 2012 10:46 PM

    Funny answer, Billy!
    Sounds like: The world is evil, so you have 3 choices:
    1. Implement a good world
    2. Be a bad guy, too
    3. Live with that bad world and its consequences
    I guess, 930427 only asked for some protection...
    If one has to deal with two external system to move data from one to another - you can't change either of these systems (1 or 2) and you can't afford to fail (3).
    Sometimes blanks inside the numeric values are the reason for INVALID NUMBER, i.e. "123 456".
    as simple
    to_number(replace(VALUE_CHAR, ' ', NULL))
    may help...

  • Universe object that returns the number of rows in table?

    Is it possible to create a Universe object to support the following SQL query:
    SELECT * FROM (SELECT ROWNUM rownum1 FROM TABLE) WHERE rownum1 = (SELECT (MAX(ROWNUM)) FROM TABLE)

    Amr,
    Hey dude, welcome back, long time no hear from you.
    You were on the right track with "number of rows", but here is the correct syntax:
    =NumberOfRows([Query 1])
    Thanks,
    John

  • Want to know the table names as well as number of rows

    hi...every one.....i want to explain more in detail to previous thread i have posted.
    actually i need to display all the table names and number of rows for each, in a schema(like AP,HR,....)
    it's must that i should do it by using a stored procedure.
    so the best way for this would be by using cursor and loop.
    so please help me in solving this question.

    i need to display all the table names and number of rows for each, in a schema(like AP,HR,....)
    it's must that i should do it by using a stored procedure.Homework ?
    Anyway, try this
    SQL> create or replace procedure count_rows
      2  is
      3     nrows   number;
      4     str     varchar2(100);
      5  begin
      6     for T in (select table_name from user_tables
      7                     order by table_name)
      8     loop
      9             str := 'select count(*) from '||T.table_name;
    10             execute immediate str into nrows;
    11             dbms_output.put_line(T.table_name||'  '||nrows);
    12     end loop;
    13* end;
    SQL> /Don't forget to "set serveroutput on" when you execute it.

  • Problem with jdbc:odbc returning incorrect number of rows.

    Hello,
    Am sure i have done something stupid, but i have an issue with jdbc:odbc ....
    It is a simple sceanrio that i have coded umpteen times before ...
    I have the following ....
    1. Connection to DB2 on an IBM i5 (I apologise for not using native drivers from jt400.jar, but i had an ODBC code example and was in a rush - no excuse i know)
    2. Statement object created from connection above
    3. A string with my SQL in it
    4. A result set for the results.
    These are created as follows:
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection(ODBCSource, userID, password);
    if (con == null) {
    // error handling not relevant here
    } else {
    Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    String SQL = "select * from table";
    ResultSet rs = s.executeQuery(SQL);
    i then try to loop ....
    while (rs.next() )
    // stuff
    however, i only ever get one result .... if i stick in the check for isLast, the first loop hits this check, i get my little status message, and the loop ends.
    while (rs.next() )
    if (rs.isLast() )
    System.out.println("I am on last record");
    BUT if i run the SQL
    "select count(*) from table" ... i get a count of 148 !!
    I tried setting the FetchSize through setFetchSize(), but made no difference.
    This is running on a JBoss server 4.2.1GA, JDK is "jdk1.6.0_02" .... i have a suspicion that this may be a JBoss specfic issue, as this exact code runs just fine on the Domino platform that it was originally on, if this is the case, i apologise for wasting everyones time .... but would still appreciate any pointers you can give me.
    Cheers

    Hello,
    Thanks for the reply, I am not sure i follow what you are saying.
    I only mentioned JBoss as it is the application server that we have deployed to and because the orignal code ran fine on a Domino server, I will take your advice and try to run it through in debug rather than running actually on the application server.
    Am i incorrect in my assumption that if "select count(*) from table" gives a count of 148, i should expect 148 records in a result set created from "select * from table" ? This is all rather new to me so i apologise if this is incorrect, I'd love to know why this is incorrect so i dont make similar mistakes in future.
    Also, If i run this same code on the previous platform, i get 148 iterations of the code contained within
    while (rs.next() ) { ... }
    When the war file is deployed to JBoss, the same SQL statement gives a result set that only iterates once for
    while (rs.next() ) { ... }
    The previous platform as I say was domino, but it was running as a lotus notes java agent (despite not using any notes documents etc) as it happened to be where the web pages that call this process were located. It is possible that some of the main code has changed as I had cut and paste the code into a servlet using MyEclipse, but i have double checked the bit that does this SQL request and it is identical
    To complete the picture, the new servelt is then called from the action tag on the submit form on a JSP, when it ends the servlet redirects via the requestdispacher to success or failure jsp pages depending on the outcome of the processing.
    Thank you again for your help.

  • CLR Procedure and returning large number of rows

    I have a CLR stored procedure coded in C# that retrieves data from a web service, and returns that data using SendResultsStart/SendResultsRow/SendResultsEnd. This all works fine, except when the data from the web service is tens or even thousands of records.
    The code itself takes about 3 minutes on average to do all it's work with around 50000-60000 records, but the procedure does not return in SSMS for about another 10-15 minutes, during which time the CPU and memory usage go up significantly.
    To rule out any of the CLR code as the culprit, I created a very simple CLR procedure that just loops to return 100000 records with int and nvarchar(256) fields with the current count, and "ABC" followed by the count.  Here is the code:
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void ABC()
    System.Diagnostics.Stopwatch ExecuteTimer = System.Diagnostics.Stopwatch.StartNew();
    SqlMetaData[] ResultMetaData = new SqlMetaData[2];
    ResultMetaData[0] = new SqlMetaData("count", SqlDbType.Int);
    ResultMetaData[1] = new SqlMetaData("text", SqlDbType.NVarChar, 256);
    SqlContext.Pipe.SendResultsStart(new SqlDataRecord(ResultMetaData));
    for (int x = 0; x < 100000; x++)
    SqlDataRecord ResultItem = new SqlDataRecord(ResultMetaData);
    ResultItem.SetValue(0, x);
    ResultItem.SetValue(1, "ABC" + x.ToString());
    SqlContext.Pipe.SendResultsRow(ResultItem);
    SqlContext.Pipe.SendResultsEnd();
    TimeSpan ExecTime = ExecuteTimer.Elapsed;
    SqlContext.Pipe.Send("Elapsed Time: " + ExecTime.Minutes.ToString() + ":" + ExecTime.Seconds.ToString() + "." + ExecTime.Milliseconds.ToString());
    I then executed procedure ABC in SSMS, and it took 21 minutes to return.  All of the data rows were visible after just a couple of seconds, but the query continued to run as the CPU and memory went up again.
    Is this really how long it should take to return 100000 rows, or am I missing something?  Is there a better approach than using SendResultsStart/SendResultsRow/SendResultsEnd?
    I've googled this to death and haven't found anything that helped or even explained why this is.
    I would greatly appreciate any suggestions or alternate methods to achieve this faster.
    Thanks!
    Alex

    When you create a new object, space on the garbage-collected heap is allocated for that object, and the address will be stored in a reference. Some time later, there will no longer be any references that hold the address of the allocated object. It doesn't
    matter whether the reference count went to 0 because the reference was set to null or because the reference was on the stack and is no longer in lexical scope, the end result is the same: the garbage collector will, at some point in time, have to perform the
    book-keeping operations necessary to identify that the space allocated for that now-unreferenced object can be re-used. When, on the other hand, you only create a single SqlDataRecord object and hold onto the reference, all of the book-keeping operations
    associated with creating 100,000 objects are eliminated. This is why the documentation for the SqlDataReader class advises that:
    When writing common language runtime (CLR) applications, you should re-use existing
    SqlDataRecord objects instead of creating new ones every time. Creating many new
    SqlDataRecord objects could severely deplete memory and adversely affect performance.

  • Query returning different number of rows standalone vs insert statement

    Hi,
    We are using Oracle 10g. We are facing a issue where a SELECT inserts 26294 rows when used with a insert statement. The same select (cut-and-paste) when executed standalone, returns only 60 rows. Any idea what could be causing this?
    Thanks in advance,
    Hari Narayanan
    TIAA-CREF
    See details below,
    SQL> INSERT INTO cref.position_recon_breaks (
    2 effective_date,
    3 fund_entity_id,
    4 security_alias,
    5 accounting_system,
    6 pace_shares,
    7 accounting_sys_shares,
    8 accounting_sys_unp_trd_shares
    9 )
    10 SELECT pr.effective_date,
    11 pr.ENTITY_ID,
    12 pr.SECURITY_ALIAS,
    13 'MELLON',
    14 CREF_SHARES PACE_SHARES,
    15 CORP_SHARES ACCOUNTING_SYS_SHARES,
    16 CORP_UNP_TRD_SHARES ACCOUNTING_SYS_UNP_TRD_SHARES
    17 FROM cref.MELLON_POSITION_RECON pr
    18 WHERE ABS(SHARES_DIFFERENCE) >= 1;
    25294 rows created.
    SQL> select count(*) from
    2 (SELECT pr.effective_date,
    3 pr.ENTITY_ID,
    4 pr.SECURITY_ALIAS,
    5 'MELLON',
    6 CREF_SHARES PACE_SHARES,
    7 CORP_SHARES ACCOUNTING_SYS_SHARES,
    8 CORP_UNP_TRD_SHARES ACCOUNTING_SYS_UNP_TRD_SHARES
    9 FROM cref.MELLON_POSITION_RECON pr
    10 WHERE ABS(SHARES_DIFFERENCE) >= 1);
    COUNT(*)
    60

    charred/jzhang,
    Thanks for your responses. Just as an additional info, MELLON_POSITION_RECON is one hell of a view - not written by me :) - with unions and inline queries.
    If it would be of any help, here is the script,
    CREATE OR REPLACE FORCE VIEW CREF.MELLON_POSITION_RECON
    (EFFECTIVE_DATE, FUND_CODE, ENTITY_ID, ENTITY_NAME, SECURITY_ALIAS,
    SECURITY_NAME, PRIMARY_ASSET_ID, CREF_SECURITY_COUNT, CORP_SECURITY_COUNT, CREF_CURRENCY_CODE,
    CORP_CURRENCY_CODE, CREF_EXCHANGE_RATE, CORP_EXCHANGE_RATE, CREF_SHARES, CORP_SHARES,
    CREF_PRICE_LOCAL, CORP_PRICE_LOCAL, CREF_MARKET_VALUE_USD, CORP_MARKET_VALUE_USD, CREF_MARKET_VALUE_LOCAL,
    CORP_MARKET_VALUE_LOCAL, CREF_ACCRUED_INCOME_USD, CORP_ACCRUED_INCOME_USD, CORP_UNP_TRD_MARKET_VALUE, CORP_UNP_TRD_SHARES,
    SHARES_DIFFERENCE, SHARES_DIFF_INCL_UNP, LOCAL_PRICE_DIFFERENCE, MKT_VALUE_USD_DIFF, MKT_VALUE_USD_DIFF_INCL_UNP,
    ACCRUED_INCOME_DIFF)
    AS
    SELECT /*+ ORDERED */
    P.EFFECTIVE_DATE
    ,E.CODE FUND_CODE
    ,P.ENTITY_ID
    ,E.LONG_NAME ENTITY_NAME
    ,P.SECURITY_ALIAS
    ,S.ISSUE_NAME SECURITY_NAME
    ,S.PRIMARY_ASSET_ID
    ,P.CREF_SECURITY_COUNT
    ,P.CORP_SECURITY_COUNT CORP_SECURITY_COUNT
    ,P.CREF_CURRENCY_CODE
    ,P.CORP_CURRENCY_CODE CORP_CURRENCY_CODE
    ,P.CREF_EXCHANGE_RATE
    ,P.CORP_EXCHANGE_RATE CORP_EXCHANGE_RATE
    ,P.CREF_SHARES
    ,P.CORP_SHARES CORP_SHARES
    ,P.CREF_PRICE_LOCAL
    ,P.CORP_PRICE_LOCAL CORP_PRICE_LOCAL
    ,ROUND(P.CREF_MARKET_VALUE_USD,2) CREF_MARKET_VALUE_USD
    ,P.CORP_MARKET_VALUE_USD CORP_MARKET_VALUE_USD
    ,ROUND(P.CREF_MARKET_VALUE_LOCAL,2) CREF_MARKET_VALUE_LOCAL
    ,P.CORP_MARKET_VALUE_LOCAL CORP_MARKET_VALUE_LOCAL
    ,ROUND(P.CREF_ACCRUED_INCOME_USD,2) CREF_ACCRUED_INCOME_USD
    ,P.CORP_ACCRUED_INCOME_USD
    ,P.CORP_UNP_TRD_MARKET_VALUE
    ,P.CORP_UNP_TRD_SHARES
    ,NVL(P.CORP_SHARES, 0) - NVL(P.CREF_SHARES, 0) SHARES_DIFFERENCE
    ,NVL(P.CORP_SHARES,0) +
    (NVL(P.CORP_UNP_TRD_SHARES, 0) - NVL(P.CREF_SHARES, 0)) SHARES_DIFF_INCL_UNP
    ,NVL(P.CREF_PRICE_LOCAL, 0) - NVL(P.CORP_PRICE_LOCAL, 0) LOCAL_PRICE_DIFFERENCE
    ,NVL(ROUND(P.CREF_MARKET_VALUE_USD,2),0) - NVL(P.CORP_MARKET_VALUE_USD,0) MKT_VALUE_USD_DIFF
    ,NVL(ROUND(P.CREF_MARKET_VALUE_USD,2),0) -
    (NVL(P.CORP_MARKET_VALUE_USD, 0) + NVL(P.CORP_UNP_TRD_MARKET_VALUE,0)) MKT_VALUE_USD_DIFF_INCL_UNP
    ,NVL(ROUND(P.CREF_ACCRUED_INCOME_USD,2),0) - NVL(P.CORP_ACCRUED_INCOME_USD, 0) ACCRUED_INCOME_DIFF
    FROM
    SELECT ENTITY_ID
    ,EFFECTIVE_DATE
    ,SECURITY_ALIAS
    ,SUM(CREF_SECURITY_COUNT) CREF_SECURITY_COUNT
    ,SUM(CORP_SECURITY_COUNT) CORP_SECURITY_COUNT
    ,MAX(CREF_CURRENCY_CODE) CREF_CURRENCY_CODE
    ,MAX(CORP_CURRENCY_CODE) CORP_CURRENCY_CODE
    ,MAX(CREF_EXCHANGE_RATE) CREF_EXCHANGE_RATE
    ,MAX(CORP_EXCHANGE_RATE) CORP_EXCHANGE_RATE
    ,SUM(CREF_SHARES) CREF_SHARES
    ,SUM(CORP_SHARES) CORP_SHARES
    ,MAX(CREF_PRICE_LOCAL) CREF_PRICE_LOCAL
    ,MAX(CORP_PRICE_LOCAL) CORP_PRICE_LOCAL
    ,SUM(CREF_MARKET_VALUE_USD) CREF_MARKET_VALUE_USD
    ,SUM(CORP_MARKET_VALUE_USD) CORP_MARKET_VALUE_USD
    ,SUM(CREF_MARKET_VALUE_LOCAL) CREF_MARKET_VALUE_LOCAL
    ,SUM(CORP_MARKET_VALUE_LOCAL) CORP_MARKET_VALUE_LOCAL
    ,SUM(CREF_ACCRUED_INCOME_USD) CREF_ACCRUED_INCOME_USD
    ,SUM(CORP_ACCRUED_INCOME_USD) CORP_ACCRUED_INCOME_USD
    ,MIN(QUERY_TIMESTAMP) QUERY_TIMESTAMP
    ,SUM(CORP_UNP_TRD_MARKET_VALUE) CORP_UNP_TRD_MARKET_VALUE
    ,SUM(CORP_UNP_TRD_SHARES) CORP_UNP_TRD_SHARES
    FROM
    SELECT -- WANT ONE ROW PER FUND PER SECURITY
    /*+ index(p I_POS_ENTID_SRCINTFC_CREF) index (pd) */
    E.FUND_ENTITY_ID ENTITY_ID
    ,P.EFFECTIVE_DATE
    ,PD.SECURITY_ALIAS
    ,SYSDATE QUERY_TIMESTAMP
    ,1 CREF_SECURITY_COUNT
    ,MAX(PD.LOCAL_CURRENCY) CREF_CURRENCY_CODE
    ,MAX(PD.MKT_EXCHANGE_RATE) CREF_EXCHANGE_RATE
    ,SUM(PD.SHARE_PAR_VALUE) CREF_SHARES
    ,MAX(PD.PRICE) CREF_PRICE_LOCAL
    ,SUM(PD.MARKET_VALUE) CREF_MARKET_VALUE_USD
    ,SUM(PD.LOCAL_MARKET_VALUE) CREF_MARKET_VALUE_LOCAL
    ,SUM(PD.ACCRUED_INCOME) CREF_ACCRUED_INCOME_USD
    ,0 CORP_SECURITY_COUNT
    ,TO_CHAR(NULL) CORP_CURRENCY_CODE
    ,0 CORP_SHARES
    ,TO_NUMBER(NULL) CORP_PRICE_LOCAL
    ,TO_NUMBER(NULL) CORP_EXCHANGE_RATE
    ,0 CORP_MARKET_VALUE_USD
    ,0 CORP_MARKET_VALUE_LOCAL
    ,0 CORP_ACCRUED_INCOME_USD
    ,0 CORP_UNP_TRD_MARKET_VALUE
    ,0 CORP_UNP_TRD_SHARES
    FROM CREF.ENTITY E,
    CREF.ENTITY EF                fund entity       NF
    ,HOLDINGDBO.POSITION P
    ,(SELECT MAX(EFFECTIVE_DATE) CURRENT_DATE
    FROM HOLDINGDBO.POSITION P,
    PACE_MASTERDBO.INTERFACES I
    WHERE I.SHORT_DESC = 'MELLON'
    AND I.INSTANCE = P.SRC_INTFC_INST) DT
    ,HOLDINGDBO.POSITION_DETAIL PD
    ,PACE_MASTERDBO.INTERFACES I
    WHERE E.PORTFOLIO_ENTITY_TYPE_CODE = 'PORT'
    AND E.ENTITY_ID = P.ENTITY_ID
    AND EF.ENTITY_ID = E.FUND_ENTITY_ID           -- NF
    AND EF.ACCOUNTING_SYSTEM = 'MELLON'      -- NF
    AND E.ENTITY_ID = P.ENTITY_ID
    AND I.SHORT_DESC = 'STARDIRECT'
    AND I.INSTANCE = P.SRC_INTFC_INST
    AND P.EFFECTIVE_DATE = DT.CURRENT_DATE
    AND P.POSITION_ID = PD.POSITION_ID
    -- "GROUP BY" COMBINES THE LONG AND SHORT POSITIONS
    GROUP BY P.EFFECTIVE_DATE, E.FUND_ENTITY_ID, PD.SECURITY_ALIAS
    UNION ALL
    SELECT -- CORPORATE SENDS ONE ROW PER FUND PER SECURITY (NO SHORTS)
    /*+ index(p I_POS_ENTID_SRCINTFC_CREF) index (pd) */
    E.ENTITY_ID
    ,P.EFFECTIVE_DATE
    ,PD.SECURITY_ALIAS
    ,SYSDATE QUERY_TIMESTAMP
    ,0 CREF_SECURITY_COUNT
    ,TO_CHAR(NULL) CREF_CURRENCY_CODE
    ,0 CREF_SHARES
    ,TO_NUMBER(NULL) CREF_PRICE_LOCAL
    ,TO_NUMBER(NULL) CREF_EXCHANGE_RATE
    ,0 CREF_MARKET_VALUE_USD
    ,0 CREF_MARKET_VALUE_LOCAL
    ,0 CREF_ACCRUED_INCOME_USD
    ,1 CORP_SECURITY_COUNT
    ,PD.LOCAL_CURRENCY CORP_CURRENCY_CODE
    ,PD.SHARE_PAR_VALUE CORP_SHARES
    ,PD.PRICE CORP_PRICE_LOCAL
    ,pd.mkt_exchange_rate CORP_EXCHANGE_RATE
    ,PD.MARKET_VALUE CORP_MARKET_VALUE_USD
    ,PD.LOCAL_MARKET_VALUE CORP_MARKET_VALUE_LOCAL
    ,PD.ACCRUED_INCOME CORP_ACCRUED_INCOME_USD
    ,0 CORP_UNP_TRD_MARKET_VALUE
    ,0 CORP_UNP_TRD_SHARES
    FROM CREF.ENTITY E
    ,HOLDINGDBO.POSITION P
    ,(SELECT MAX(EFFECTIVE_DATE) CURRENT_DATE
    FROM HOLDINGDBO.POSITION P,
    PACE_MASTERDBO.INTERFACES I
    WHERE I.SHORT_DESC = 'MELLON'
    AND I.INSTANCE = P.SRC_INTFC_INST) DT
    ,HOLDINGDBO.POSITION_DETAIL PD
    ,PACE_MASTERDBO.INTERFACES I
    WHERE E.FUND_FLAG = 'Y' --
    AND E.ENTITY_ID = P.ENTITY_ID
    AND I.SHORT_DESC = 'MELLON'
    AND I.INSTANCE = P.SRC_INTFC_INST
    AND P.EFFECTIVE_DATE = DT.CURRENT_DATE
    AND P.POSITION_ID = PD.POSITION_ID
    UNION ALL
    SELECT
    UTS.FUND_ENTITY_ID ENTITY_ID
    ,UTS.EFFECTIVE_DATE
    ,UTS.SECURITY_ALIAS
    ,SYSDATE QUERY_TIMESTAMP
    ,0 CREF_SECURITY_COUNT
    ,TO_CHAR(NULL) CREF_CURRENCY_CODE
    ,0 CREF_SHARES
    ,TO_NUMBER(NULL) CREF_PRICE_LOCAL
    ,TO_NUMBER(NULL) CREF_EXCHANGE_RATE
    ,0 CREF_MARKET_VALUE_USD
    ,0 CREF_MARKET_VALUE_LOCAL
    ,0 CREF_ACCRUED_INCOME_USD
    ,0 CORP_SECURITY_COUNT
    ,TO_CHAR(NULL) CORP_CURRENCY_CODE
    ,0 CORP_SHARES
    ,TO_NUMBER(NULL) CORP_PRICE_LOCAL
    ,TO_NUMBER(NULL) CORP_EXCHANGE_RATE
    ,0 CORP_MARKET_VALUE_USD
    ,0 CORP_MARKET_VALUE_LOCAL
    ,0 CORP_ACCRUED_INCOME_USD
    ,UTS.SUM_MARKET_VALUE CORP_UNP_TRD_MARKET_VALUE
    ,UTS.SUM_SHARES CORP_UNP_TRD_SHARES
    FROM
    (SELECT MAX(EFFECTIVE_DATE) CURRENT_DATE
    FROM HOLDINGDBO.POSITION P,
    PACE_MASTERDBO.INTERFACES I
    WHERE I.SHORT_DESC = 'MELLON'
    AND I.INSTANCE = P.SRC_INTFC_INST) DT
    ,cref.UNPROCESSED_TRADES_SUM UTS
    WHERE DT.CURRENT_DATE = UTS.EFFECTIVE_DATE
    AND UTS.UPDATED_BY = 'MELLON'
    GROUP BY EFFECTIVE_DATE, ENTITY_ID, SECURITY_ALIAS
    ) P,
    cref.ENTITY E,
    SECURITYDBO.SECMASTER_HISTORY S
    WHERE P.ENTITY_ID = E.ENTITY_ID
    AND P.SECURITY_ALIAS = S.SECURITY_ALIAS
    AND S.SRC_INTFC_INST = (SELECT INSTANCE FROM PACE_MASTERDBO.INTERFACES
    WHERE SHORT_DESC = 'EAGLE PACE')
    AND S.EFFECTIVE_DATE = (SELECT MAX(S1.EFFECTIVE_DATE)
    FROM SECURITYDBO.SECMASTER_HISTORY S1
    WHERE S1.SRC_INTFC_INST = S.SRC_INTFC_INST
    AND S1.SECURITY_ALIAS = S.SECURITY_ALIAS
    AND S1.EFFECTIVE_DATE <= P.EFFECTIVE_DATE);

  • Smartforms table: how to fix the number of rows to be display in the table.

    Hello.
    I´m having problems with a smartform. I have defined a window with 7 cm high. Then I have define a table to print the content of a table.
    I'm using the header, the main area, and the footer. It seems to be ok. But the main area is sizeble. I mean, that if in the table has 2 records, it dispaly the 2 records and inmediatly display the footer. It probably use only 3 cm of the 7 cm defined for the high of the window.
    And I want that the footer of the table would be display at the end of the 7 cm of the window. Is that posible ?
    Please, tomorrow we will have our kick off the module and this is the last issue we have.
    Thanks in advance for your help.

    Better idea wud be to create a WINDOW, just Below you Main window (After table) ..
    In Form Layout (Form Painter) you can fix this Window on any place , Pass the FOOTER text node over there  .. So you will get a Static FOOTER diplay ..
    That what you need ?? Let me know
    Edited by: Lokesh Tarey on Jul 22, 2010 7:15 AM

  • Simple MDX : Associated Date Value for returned week number on Row Axis ?

    Team , I have this MDX Below :
    I'm trying to see if i can also have a Column which  Uniques the week Starting/Ending Date   as below , Thanks in advance for your help and time .
    1 20040101  20040101  20040103    (null)
    1 20040102  20040101  20040103      1
    1 20040103  20040101  20040103     (null)
    2 20040104  20040104  20040110    (null)
    2 20040105  20040104  20040110       1
    2 20040106  20040104  20040110       1
    2 20040107  20040104  20040110     (null)
    2 20040108  20040104  20040110      (null)
    2 20040109  20040104  20040110      (null)
    2 20040110  20040104  20040110      (null)
    Rajkumar Yelugu

    Hi Rajkumar,
    According to your description, you want to show the week start and week end date together with the date dimension members, right? In this case, you can add week start and week end attribute to date dimension. Adding Week Start and Week End dates to your
    Date Dimension table can make navigating your dimensional model extremely handy and tasty to the end user. Please refer to the link below to see the detail information.
    Calculating Week Start and Week End Dates Dynamically
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

Maybe you are looking for