Help two sql queries toload target table

create table table1
    (code varchar2(10)
     ,mod_time date);
     insert into table1 values('2533',to_date('31-JUL-2012', 'DD-MON-YY'));
     insert into table1 values('2534',to_date('31-JUL-2012', 'DD-MON-YY'));
      insert into table1 values('2535',to_date('01-SEP-2012', 'DD-MON-YY'));
      create table table2
    (code varchar2(10)
     ,ID   NUMBER
     ,TYPE VARCHAR2(3)
     ,mod_time date);
     insert into table2 values('2533',1,'AB',to_date('01-SEP-2012', 'DD-MON-YY'));
     insert into table2 values('2534',1,'CD',to_date('01-SEP-2012', 'DD-MON-YY'));
     create table table3
     (ID   NUMBER
      ,mod_time date);
      insert into table3 values(1,to_date('01-SEP-2012', 'DD-MON-YY'));
      insert into table3 values(2,to_date('01-SEP-2012', 'DD-MON-YY'));
      create table target
      (code varchar2(10)
      ,ID   NUMBER
      ,TYPE VARCHAR2(3)
      ,table1_modtime date
      ,table2_modtime date
      ,table3_modtime date
      ,valid_till  date
      ,valid_from  date
      drop table target
      combine all the three tables where table1.mod_time<=31-jul-2012, table2.mod_time<=31-jul-2012,table3.mod_time<=31-jul-2012
      initial load to target load should be get the information from all the tables modtime<=31-jul-2012
      Need to have select query to get the below 1st load expected output
      valid_till defaults to to_date('31-DEC-2030', 'DD-MON-YY')
      valid_from defaults to to_date('01-01-1995', 'DD-MON-YY')
     1st load expected output
      code    id     type  table1_modtime   table2_modtime      table3.modtime  valid_from valid_till  
      2533                 31-JUL-2012                                                            01-01-1995  31-DEC-2030 
      2534                 31-JUL-2012                                                             01-01-1995   31-DEC-2030 
      -------------------------------------------------------------------------------------------------------for the second load. first get the query to get the values from all the tables
mod_time>31-jul-2012 .
if the code exists then update the existing record with valid_till to 02-jan-2013 i.e yesterday
and insert new record with the new values and valid from date to 03-jan-2013 i.e today
    --------------------2nd load expected output 
      code    id     type  table1_modtime   table2_modtime      table3.modtime      valid_from     valid_till
      2533                 31-JUL-2012                                                               01-01-1995       02-jan-2013 --updating old record valid-till to yesterday
      2534                 31-JUL-2012                                                               01-01-1995       02-jan-2013  --updating old record valid-till to yesterday
      2533      1     AB   31-JUL-2012        01-SEP-2012        01-SEP-2012         03-jan-2013  31-DEC-2030----updating old record valid-from to today
      2534      1     CD   31-JUL-2012        01-SEP-2012       01-SEP-2012          03-jan-2013  31-DEC-2030--updating old record valid-from to today
      2535                  01-SEP-2012                                                              01-01-1995  31-DEC-2030 --no record exist so insert new record in target table
  Edited by: choti on Jan 3, 2013 5:01 PM

Hi ,
Just check the data you have inserted into the tables because, trying to join the table and putting the date constraint its returning no values
select T1.CODE as code ,t3.id as id ,t2.type as type  ,T1.MOD_TIME as table1_modtime ,T2.MOD_TIME as table2_modtime ,T3.MOD_TIME as table3_modtime from table1 t1, table2 t2,table3 t3 where T1.CODE = t2.code and t2.id = t3.id
and t1.mod_time<=to_date('31-jul-2012', 'DD-MON-YY')
and t2.mod_time<=to_date('31-jul-2012', 'DD-MON-YY')
and t3.mod_time<=to_date('31-jul-2012', 'DD-MON-YY')And this because for the code 2533 and 2534 in the table1 the id entry in the table2 is 1 . but the date entry in the table3 for the Id 1 is 01-SEP-2012 which falls outside the date. Kindly confirm on this data entry in table2.

Similar Messages

  • Need help in SQL Queries using GUI controls or variables

    Hello, all
    I have a big problem (I have already had with Visual Basic a few mounths ago) with Java while writing my SQL Queries.
    I would like to know how I must do to use variable data or GUI control data in my SQL Query to select only some records.
    Here, my first Query that works without any problem (no WHERE clause !!!) :
    Statement requeteBedes = connectBedes.createStatement();
    ResultSet resultatSeries = requeteBedes.executeQuery("SELECT * FROM Series");
    initComboBoxSeries(resultatSeries);the method "initComboBoxSeries" fills a JComboBox with all the names of the series in my database.
    Here comes my problem.I would like to use the value of the selected "series" in the JComboBox to search in another table of the same Database. I made another statement but it returns a Null ResultSet :
    ResultSet resultatSearchAlbumsFromSeries = requeteBedes.executeQuery("SELECT * FROM bandes_dess WHERE  ser_nom = '" + strComboBoxSeriesSelected + "' "); The variable strComboBoxSeriesSelected contains the value of the selected line in the combobox with all the series, filled after the first query that is here above and that works very well.
    Could some one help me and tell me how I must use variables or GUI controls values in my SQL Queries or tell me if there is a place where I could find an explanation of that kind of problems (like more "advanced SQL Queries", as the ones currently used in all the Learning Java 2 books)
    Thank you all for your help.
    Christian.

    executeQuery() will never return null. At least that's what the spec says. You are probably catching an exception (probably a syntax error caused by a single quote in strComboBoxSeriesSelected) and ignoring it. Or do you mean the ResultSet contains no rows?
    Anyway, to use parameterized queries, take a look at PreparedStatements. Your code should look like this using PreparedStatement:Statement requeteBedes = connectBedes.prepareStatement("SELECT * FROM bandes_dess WHERE  ser_nom = ?");
    requeteBedes.setString(1, strComboBoxSeriesSelected);
    ResultSet resultatSeries = requeteBedes.executeQuery();Alin.

  • Need help for SQL Queries Tunning

    hi all,
    we have a procedure for search consumers, which using sql queries like:
    SELECT TRIM (NAME) AS NAME, TRIM (accno) AS accno,
    TRIM (connaddress) AS connaddress,
    TRIM (CATEGORY) AS CATEGORY, TRIM (landmark) AS landmark,
    SUBSTR (accno, 1, 3) AS subdivisionname
    FROM consumermaster
    WHERE LOWER (accno) LIKE
    LOWER ('%' || NVL (caccno, '#noval#') || '%')
    OR LOWER (NAME) LIKE LOWER ('%' || NVL (cname, '#noval#') || '%')
    OR LOWER (connaddress) LIKE
    LOWER ('%' || NVL (cadd, '#noval#') || '%')
    OR phone LIKE '%' || NVL (cphone, '#noval#') || '%'
    OR accno = (SELECT accno
    FROM requestregistration
    WHERE requestid = creqid)
    UNION
    SELECT TRIM (NAME) AS NAME, TRIM (accno) AS accno,
    TRIM (connaddress) AS connaddress, TRIM (CATEGORY)
    AS CATEGORY,
    TRIM (landmark) AS landmark,
    SUBSTR (accno, 1, 3) AS subdivisionname
    FROM scodetails
    WHERE LOWER (accno) LIKE
    LOWER ('%' || NVL (caccno, '#noval#') || '%')
    OR LOWER (NAME) LIKE LOWER ('%' || NVL (cname, '#noval#') || '%')
    OR LOWER (connaddress) LIKE
    LOWER ('%' || NVL (cadd, '#noval#') || '%')
    OR phone LIKE '%' || NVL (cphone, '#noval#') || '%'
    OR accno = (SELECT accno
    FROM requestregistration
    WHERE requestid = creqid);
    it's ok for small tables but now data increase .......
    searching method is very slow
    now i want to tune this query for better performance
    please sugg me best method
    Thanks in advance
    Regards
    vij..

    The link given by Asif should get you on the right track for tuning this query.
    I just formatted your SQL:
    SELECT Trim(NAME)        AS NAME,
           Trim(accno)       AS accno,
           Trim(connaddress) AS connaddress,
           Trim(category)    AS category,
           Trim(landmark)    AS landmark,
           Substr(accno,1,3) AS subdivisionname
    FROM   consumermaster
    WHERE  Lower(accno) LIKE Lower('%'
                                   ||Nvl(caccno,'#noval#')
                                   ||'%')
            OR Lower(NAME) LIKE Lower('%'
                                      ||Nvl(cname,'#noval#')
                                      ||'%')
            OR Lower(connaddress) LIKE Lower('%'
                                             ||Nvl(cadd,'#noval#')
                                             ||'%')
            OR phone LIKE '%'
                          ||Nvl(cphone,'#noval#')
                          ||'%'
            OR accno = (SELECT accno
                        FROM   requestregistration
                        WHERE  requestid = creqid)
    UNION
    SELECT Trim(NAME)        AS NAME,
           Trim(accno)       AS accno,
           Trim(connaddress) AS connaddress,
           Trim(category)    AS category,
           Trim(landmark)    AS landmark,
           Substr(accno,1,3) AS subdivisionname
    FROM   scodetails
    WHERE  Lower(accno) LIKE Lower('%'
                                   ||Nvl(caccno,'#noval#')
                                   ||'%')
            OR Lower(NAME) LIKE Lower('%'
                                      ||Nvl(cname,'#noval#')
                                      ||'%')
            OR Lower(connaddress) LIKE Lower('%'
                                             ||Nvl(cadd,'#noval#')
                                             ||'%')
            OR phone LIKE '%'
                          ||Nvl(cphone,'#noval#')
                          ||'%'
            OR accno = (SELECT accno
                        FROM   requestregistration
                        WHERE  requestid = creqid); You are using some function on almost each and every column in the where clause. Try getting rid of them as they are hindering the use of indexes, if any, on any of the columns.
    Also the guidelines in the link provided are the best starting point.

  • Sql queries from internal tables based on context node

    Hi experts,
    I want to select from my inetrnal table which is based on the context node, the rows which do not appear in another internal table based on the context node.
    I have this data:
    data lt_item_level type table of wd_this->element_item_level INITIAL SIZE 0.
    data lt_item_level_cp type table of wd_this->element_item_level INITIAL SIZE 0.
    data lt_po_items TYPE table of wd_this->element_po_items INITIAL SIZE 0.
    I want to do this:
    select * into CORRESPONDING FIELDS OF TABLE lt_item_level_cp from lt_item_level WHERE lt_po_items-po_number NE lt_item_level-item_number.
    But i get an error:
    "LT_ITEM_LEVEL" is not defined in the ABAP Dictionary as a table,
    Is there a way to do it with select or should i loop over my internal tables?
    thank u very much!!

    hi,
    You cannot use Select queries on internal table.  do like this :
    loop at itab into wa where wa-F1 NE wa-F2.
    append wa to itab1.
    endloop.
    Here itab1 will have all the records as per your requiement.
    I hope it is clear.
    Edited by: Saurav Mago on Oct 26, 2009 5:37 PM

  • HELP in Sql Queri... Urgent..

    Hi All,
    Can anyone lemme know using this will effet to our performance ??
    And the sys is throwing ' ( ' syntax error... If u have any alternative for this queri plz lemme know....
    SELECT A~VBELN
             A~WADAT
             A~WADAT_IST
             A~LFART
             B~WERKS
             B~MATNR
             c~maktx
             d~werks
             INTO CORRESPONDING FIELDS OF TABLE I_LIKP
             FROM  ( ( ( LIKP AS A INNER JOIN LIPS AS B
             on AVBELN = BVBELN where
             A~LFART in S_LFART AND
             A~WADAT_IST in S_WADAT AND
             B~WERKS in S_WERKS )
             inner join makt as c on cmatnr = bmatnr )
             inner join t001w as d on dwerks = bwerks ).
             if not i_likp is initial.
             select e~tknum
                    e~vsart
                    f~vbeln
                    into corresponding fields of table i_vttk
                    from vttk as e inner join vttp as f
                    on etknum = ftknum
                    for all entries in i_likp where f~vbeln = i_likp-vbeln.
             endif.
    Regards,
    Parvez.

    hi
    For performance tunning plz apply this
    ¨ Use the GET RUN TIME command to help evaluate performance. It's hard to know whether that
    optimization technique REALLY helps unless you test it out. Using this tool can help you know what is effective, under what kinds of conditions. The GET RUN TIME has problems under multiple CPUs, so you should use it to test small pieces of your program, rather than the whole program.
    ¨ Avoid 'SELECT *', especially in tables that have a lot of fields. Use SELECT A B C INTO instead, so that fields are only read if they are used. This can make a very big difference.
    ¨ Field-groups can be useful for multi-level sorting and displaying. However, they write their data to the
    system's paging space, rather than to memory (internal tables use memory). For this reason, field-groups are only appropriate for processing large lists (e.g. over 50,000 records). If you have large lists, you should work with the systems administrator to decide the maximum amount of RAM your program should use, and from that, calculate how much space your lists will use. Then you can decide whether to write the data to memory or swap space. See the Fieldgroups ABAP example.
    ¨ Use as many table keys as possible in the WHERE part of your select statements.
    ¨ Whenever possible, design the program to access a relatively constant number of records (for instance, if you only access the transactions for one month, then there probably will be a reasonable range, like 1200-1800, for the number of transactions inputted within that month). Then use a SELECT A B C INTO TABLE ITAB statement.
    ¨ Get a good idea of how many records you will be accessing. Log into your productive system, and use SE80 -> Dictionary Objects (press Edit), enter the table name you want to see, and press Display. Go to Utilities -> Table Contents to query the table contents and see the number of records. This is extremely useful in optimizing a program's memory allocation.
    ¨ Try to make the user interface such that the program gradually unfolds more information to the user, rather than giving a huge list of information all at once to the user.
    ¨ Declare your internal tables using OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to be accessing. If the number of records exceeds NUM_RECS, the data will be kept in swap space (not memory).
    ¨ Use SELECT a B C INTO TABLE ITAB whenever possible. This will read all of the records into the tab in one operation, rather than repeated operations that result from a SELECT A B C INTO ITAB... ENDSELECT statement. Make sure that ITAB is declared with OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to access. 
    ¨ many tables contain totals fields (such as monthly expense totals). Use these avoid wasting resources by calculating a total that has already been calculated and stored.
    ¨ Program Analysis Utility to determine the usage of variables and subroutines within a program, you can use the ABAP utility called ‘Program Analysis’ included in transaction SE38. To do so, execute transaction SE38, enter your program name, then use the path Utilities -> Program Analysis 
    ABAP PERFORMANCE IMPROVEMENTS VIA DATA DICTIONARY
    ¨ INDEX CREATION SUGGESTIONS RELATED TO DATABASE PERFORMANCE
    • The columns at the beginning of an index are the most “common”. The most “common” columns are those where reports are selecting columns with no ranges - the where clause for these columns is an “equal to” expression. Rearrange columns of an index to match the selection criteria. For example, if a select statement is written to include columns 1 and 2 with “equal to” expressions in the where clause and column 3 and 4 are selected with value ranges, then the index should be created with columns in the sequence of 1,2,3,4.
    • Columns towards the end of the index are either infrequently used in selects or are part of reporting selects that involve ranges of values.
    ¨ TABLE TYPE SUGGESTIONS RELATED TO DATABASE PERFORMANCE
    • Use VIEW tables to effectively join and “denormalize” related tables that are taking large amounts of time to select for reporting. For example, at times where highly accessed tables normalize description text into one table and the header data into another table, it may make sense to create a view table that joins the relevant fields of the two associated with a poor performing ABAP.
    ¨ For POOL tables that contain large amounts of data and are highly accessed convert the pooled table into a transparent table and add an index. POOLED tables are supposed to be collections of smaller tables that are quickly accessed from the database or are completely buffered in memory. Pooled tables containing more than a few hundred rows and are accessed many times in a report or transaction are candidates for POOL to TRANSPARENT Conversion. For example, table A053 contains tax jurisdiction condition information and are accessed more than ten times in the sales order create transaction. If the entire United States tax codes are loaded into these condition tables, the time to save a sales order increases to unacceptable levels. Converting the tax condition table to transparent and creating an index based upon the key fields, decreases processing time from minutes to seconds.
    • Do not allow the use of LIKE in an SAP SQL statement accessing a large table.
    • Use internal tables in ABAPs to reselect values once and store values in memory for sorting and searching purposes (this is an assumption stated at the beginning of this discussion).
    • Avoid logical databases when not processing all row s of a table. In fact, a logical database is merely a group of nested SAP SQL SELECT statements. In general, when processing a small number of rows in a larger table is required, the use of internal tables and NOT using a logical database or nested selects will be much better for performance.
    **Please reward suitable points***
    With Regards
    Navin Khedikar

  • Help with SQL queries following migration

    Hi there,
    I have just migrated from MS SQL Server database to Oracle 10g database using the Oracle SQL Developer.
    My application is using JDBC to access the database, and there are heaps of SQL statements that need to be verified and tested. I've found a number of SQL compatibility issues from my testing of the Oracle database and I hope you can help me the following.
    1. Case sensitivity
    Is it possible to not enforce case sensitivity (by default) when performing a select query?
    If this is not possible, all the SQL statements will need to be changed to evaluate column based on uppercase.
    2. Trailing white space
    Is it possible to not evaluate trailing white space (by default) when performing a select query?
    For example, suppose a table column studentNo has trailing spaces (after database migration), e.g. 'A182D '
    when performing query - select * from student where studentNo = 'A182D'
    no results can be found
    3. Issue with Where condition containing with '' = ''
    There are quite a number of SQL statements with Where condition containing '' = ''.
    For example, the following SQL query doesn't return any results even though there are matching suburb that starts with 'ST'. These types of queries are mostly used in dynamic generated queries.
    select * from Address where (suburb like 'ST%') and ('' = '' or country = '')
    Any help or advice will be greatly appreciated.
    Regards,
    Jason Gordon

    As justin mentioned setting those NLS parameters will make oracle not to use your regular index. for that you must create a function based index. See example below.
    SQL> create index t_idx on t (name)
      2  /
    Index created.
    SQL> exec dbms_stats.gather_table_stats(user,'T',cascade=>true)
    PL/SQL procedure successfully completed.
    SQL> explain plan for
      2  select * from t where name = 'karthick'
      3  /
    Explained.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 2946670127
    | Id  | Operation        | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |       |     1 |     9 |     1   (0)| 00:00:01 |
    |*  1 |  INDEX RANGE SCAN| T_IDX |     1 |     9 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - access("NAME"='karthick')
    13 rows selected.
    SQL> delete from plan_table
      2  /
    2 rows deleted.
    SQL> alter session set NLS_COMP=ANSI;
    Session altered.
    SQL> alter session set NLS_SORT=BINARY_CI;
    Session altered.
    SQL> explain plan for
      2  select * from t where name = 'karthick'
      3  /
    Explained.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 1601196873
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     9 |     5   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| T    |     1 |     9 |     5   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter(NLSSORT("NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('6B61727
                  46869636B00') )
    14 rows selected.
    SQL> create index t_idx_1 on t(NLSSORT(name,'NLS_SORT=BINARY_CI'))
      2  /
    Index created.
    SQL> exec dbms_stats.gather_table_stats(user,'T',cascade=>true)
    PL/SQL procedure successfully completed.
    SQL> /
    create index t_idx_1 on t(NLSSORT(name,'NLS_SORT=BINARY_CI'))
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    SQL> delete from plan_table
      2  /
    2 rows deleted.
    SQL> explain plan for
      2  select * from t where name = 'karthick'
      3  /
    Explained.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 2580036035
    | Id  | Operation                   | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |         |     3 |    27 |     2   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T       |     3 |    27 |     2   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | T_IDX_1 |     3 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access(NLSSORT("NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('6B6172746869636B00') )Thanks,
    Karthick.

  • Help tuning SQL queries

    Hi,
    I need your advise on the following queries (using Oracle EBS tables). I runs more than one hour for the subquery part only. I would like to achieve much faster result. I appreciate if anyone can help me tuning this query.
    SELECT item_id, item_code, org_id,
    CASE
    WHEN COUNT (a) = 6
    THEN 1
    WHEN COUNT (a) = 5
    THEN 2
    WHEN COUNT (a) = 3 OR COUNT (a) = 4
    THEN 3
    WHEN COUNT (a) = 1 OR COUNT (a) = 2
    THEN 4
    END "MC"
    FROM (SELECT oel.inventory_item_id item_id, msi.segment1 item_code,
    oel.ship_from_org_id org_id, SUM (oel.ordered_quantity) a,
    TO_CHAR (oel.request_date, 'Mon-YYYY') b
    FROM mtl_system_items_b msi,
    mtl_item_categories mic,
    oe_order_headers_all oeh,
    oe_order_lines_all oel
    WHERE oeh.header_id = oel.header_id
    AND oel.request_date BETWEEN TRUNC (ADD_MONTHS (LAST_DAY (SYSDATE), -7)) + 1
    AND TRUNC (ADD_MONTHS (LAST_DAY (SYSDATE), -1)) + 1
    AND msi.creation_date < TRUNC (ADD_MONTHS (LAST_DAY (SYSDATE), -7)) + 1
    AND oel.ship_from_org_id = msi.organization_id
    AND oeh.header_id = oel.header_id
    AND oel.inventory_item_id = msi.inventory_item_id
    AND msi.inventory_item_id = mic.inventory_item_id
    AND msi.organization_id = mic.organization_id
    AND mic.category_set_id = 1
    AND mic.category_id = 178
    AND oel.org_id = oeh.org_id
    GROUP BY oel.inventory_item_id,
    msi.segment1,
    oel.ship_from_org_id,
    TO_CHAR (oel.request_date, 'Mon-YYYY'))
    GROUP BY item_id, item_code, org_id
    Here is the explain plan for the query, seems OK, but the query took so much time.
    Plan
    SELECT STATEMENT CHOOSECost: 3,955 Bytes: 38 Cardinality: 1                                              
         15 SORT GROUP BY Cost: 3,955 Bytes: 38 Cardinality: 1                                         
              14 VIEW APPS. Cost: 3,955 Bytes: 38 Cardinality: 1                                    
                   13 SORT GROUP BY Cost: 3,955 Bytes: 91 Cardinality: 1                               
                        12 FILTER                          
                             11 NESTED LOOPS Cost: 3,908 Bytes: 91 Cardinality: 1                     
                                  8 NESTED LOOPS Cost: 3,907 Bytes: 82 Cardinality: 1                
                                       5 NESTED LOOPS Cost: 1,303 Bytes: 1,612 Cardinality: 31           
                                            2 TABLE ACCESS BY INDEX ROWID INV.MTL_ITEM_CATEGORIES Cost: 59 Bytes: 11,818 Cardinality: 622      
                                                 1 INDEX SKIP SCAN NON-UNIQUE INV.MTL_ITEM_CATEGORIES_N1 Cost: 42 Cardinality: 622
                                            4 TABLE ACCESS BY INDEX ROWID INV.MTL_SYSTEM_ITEMS_B Cost: 2 Bytes: 33 Cardinality: 1      
                                                 3 INDEX UNIQUE SCAN UNIQUE INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Cardinality: 1
                                       7 TABLE ACCESS BY INDEX ROWID ONT.OE_ORDER_LINES_ALL Cost: 84 Bytes: 30 Cardinality: 1           
                                            6 INDEX RANGE SCAN NON-UNIQUE ONT.OE_ORDER_LINES_N3 Cost: 2 Cardinality: 94      
                                  10 TABLE ACCESS BY INDEX ROWID ONT.OE_ORDER_HEADERS_ALL Cost: 1 Bytes: 9 Cardinality: 1                
                                       9 INDEX UNIQUE SCAN UNIQUE ONT.OE_ORDER_HEADERS_U1 Cardinality: 1           
    Thanks in advance,
    Dapid Candra

    Check out these links on how to post proper tuning requests.
    {message:id=1812597}
    {thread:id=863295}
    After a quick look at your execution plan I noticed you have a lot of steps that report a cardinality of 1. Do you know if statistics have been gathered recently on these tables? If not, you probably should.

  • Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database"

    Hi, Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database" ?
    When I use Connect Object Explorer, the "Connect to Server" dialog box which pops up has only 4 selections in the Server Type Drop Down List. They are Database Engine, Analysis Services, Reporting Services & Integration Services. I have read
    somewhere that there should be a compact database option. but I do not see it.
    What I would like to do is use free form SQL Queries against the tables in "SQL Server Compact 4.0 Local Database" .
    Once I have validated these queries, then I will use them in my Visual Studio 2012 C#, ASP.NET application. I created the Local Database using Visual Studio 2012 for use by my application.
    Thank you for your help..
    diana4

    Hello,
    With SSMS 2005 we have had the Option to work with SQL CE database files, but not with higher Version of SSMS.
    You can use the free SQL CE Toolbax instead; see
    http://sqlcetoolbox.codeplex.com/
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Join two source tables and replicat into a target table with BLOB

    Hi,
    I am working on an integration to source transaction data from legacy application to ESB using GG.
    What I need to do is join two source tables (to de-normalize the area_id) to form the transaction detail, then transform by concatenate the transaction detail fields into a value only CSV, replicate it on the target ESB IN_DATA table's BLOB content field.
    Based on what I had researched, lookup by join two source tables require SQLEXEC, which doesn't support BLOB.
    What alternatives are there and what GG recommend in such use case?
    Any helpful advice is much appreciated.
    thanks,
    Xiaocun

    Xiaocun,
    Not sure what you're data looks like but it's possible the the comma separated value (CSV) requirement may be solved by something like this in your MAP statement:
    colmap (usedefaults,
    my_blob = @STRCAT (col02, ",", col03, ",", col04)
    Since this is not 1:1 you'll be using a sourcedefs file, which is nice because it will do the datatype conversion for you under the covers (also a nice trick when migrating long raws to blobs). So col02 can be varchar2, col03 a number, and col04 a clob and they'll convert in real-time.
    Mapping two tables to one is simple enough with two MAP statements, the harder challenge is joining operations from separate transactions because OGG is operation based and doesn't work on aggregates. It's possible you could end up using a combination of built in parameters and funcations with SQLEXEC and SQL/PL/SQL for more complicated scenarios, all depending on the design of the target table. But you have several scenarios to address.
    For example, is the target table really a history table or are you actually going to delete from it? If just the child is deleted but you don't want to delete the whole row yet, you may want to use NOCOMPRESSDELETES & UPDATEDELETES and COLMAP a new flag column to denote it was deleted. It's likely that the insert on the child may really mean an update to the target (see UPDATEINSERTS).
    If you need to update the LOB by appending or prepending new data then that's going to require some custom work, staging tables and a looping script, or a user exit.
    Some parameters you may want to become familiar with if not already:
    COLS | COLSEXCEPT
    COLMAP
    OVERRIDEDUPS
    INSERTDELETES
    INSERTMISSINGUPDATES
    INSERTUPDATES
    GETDELETES | IGNOREDELETES
    GETINSERTS | IGNOREINSERTS
    GETUPDATES | IGNOREUPDATES
    Good luck,
    -joe

  • Can someone pls Help me: How to create a Fake target table(Dummy)  in DAC

    Hi There,
    Can someone pls Help me in creating a Fake target table(Dummy) in DAC?
    Thanks,
    Raghu

    Raghu
    You need to create a task so that you can hook sources and targets together.
    First, Design --> Tables tab --> New --> Below 'Edit' -->Table Type (Source) for your source tables.
    Design --> Tables tab --> New --> Below 'Edit' -->Check warehouse and Table Type (Fact or Fact Temporary) for your target tables.
    Points if helpful
    Kris

  • Need help in SQL table creation

    Hi All,
    I created a table a month back.Now i need to create another table of the same structure.
    Is there any way so dat i can get the script of the table which i created earlier and use the same to create another.
    Or is there another way so that we can create a table with same structure of the existing table.
    Please help.
    Regards,
    Mohan

    Check out the [DBMS_METADATA.GET_DDL|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_metada.htm#i1019414] function.
    Example:
    SQL> SET LONG 5000
    SQL> SELECT DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT') FROM DUAL;
    DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT')
      CREATE TABLE "SCOTT"."EMP"
       (    "EMPNO" NUMBER(4,0),
            "ENAME" VARCHAR2(10),
            "JOB" VARCHAR2(9),
            "MGR" NUMBER(4,0),
            "HIREDATE" DATE,
            "SAL" NUMBER(7,2),
            "COMM" NUMBER(7,2),
            "DEPTNO" NUMBER(2,0),
             CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS"  ENABLE,
             CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
              REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS"Edited by: Centinul on Jan 11, 2010 8:01 AM

  • One target table is loading from two different source but same columns but one source is in a database and other is in a flat file.

    Hope you all are doing good.
    I have a business issue to be implemented in ODI 11G. Here it is. I am trying to load a target table from two sources having same coulmn names. But one source is in file format and other is in Oracle Database.
    This is what i think i will create two mappings in the same interface using Union between the sources. But i am not sure how the interface would connect to different logical architecture to connect to two different sources.
    Thanks,
    SM

    You are on the right track, this can all be done in a single interface. Do the following
    1) Pull your file data model into the source designer and and your target table model to the target pane.
    2) Map all the relevant columns
    3) In the source designer create a new dataset and choose the UNION join type (this will create a separate tab in the source designer pane)
    4) Select the new dataset tab in the source designer pane and pull your source oracle table data model into the source designer. Map all the relevant columns to the target
    5) Make sure that your staging location is defined on a relational technology i.e. in this case the target would be an ideal candidate as that is where ODI will stage the data from both file and oracle source and perform the UNION before loading to the target
    If you want to look at some pretty screenshots showing the steps above take a look at http://odiexperts.com/11g-oracle-data-integrator-part-611g-union-minus-intersect/

  • Problem occured when create a tree table for master-detail view objects using SQL queries?

    I am programming a tree table for master-detail view objects using SQL queries and these 2 view objects are not simple singel tables queries, and 2 complex SQL are prepared for master and view objects. see below:
    1. Master View object (key attribute is SourceBlock and some varaible bindings are used for this view object.)
    SELECT  cntr_list.SOURCE_BLOCK,                   
            sum(                   
             case when cntr_list.cntr_size_q = '20'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr20 ,                   
            sum(                   
             case when cntr_list.cntr_size_q = '40'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr40 ,                   
             sum(                   
             case when cntr_list.cntr_size_q = '45'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr45                    
    FROM (       
        SELECT yb1.BLOCK_M as SOURCE_BLOCK,       
               scn.CNTR_SIZE_Q,        
               count(scn.CNTR_SIZE_Q) AS cntr_qty        
        FROM  SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2       
        WHERE       
        scm.cmr_n = scn.cmr_n             
        AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')                 
        OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))                 
        AND scm.shift_mode_c = :ShiftModeCode                           
        AND scm.end_terminal_c = :TerminalCode      
        AND scm.start_terminal_c = yb1.terminal_c                  
        AND scm.start_block_n = yb1.block_n                  
        AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n                  
        AND scm.end_terminal_c = yb2.terminal_c                  
        AND scm.end_block_n = yb2.block_n                  
        AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n           
        AND scn.status_c not in (1, 11)             
        AND scn.shift_type_c = 'V'             
        AND scn.source_c = 'S'       
        GROUP BY yb1.BLOCK_M, scn.CNTR_SIZE_Q       
    ) cntr_list       
    GROUP BY cntr_list.SOURCE_BLOCK
    2. Detail View object (key attributes are SourceBlock and EndBlock and same varaible bindings are used for this view object.)
    SELECT  cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK,                
            sum(                     
             case when cntr_list.cntr_size_q = '20'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr20 ,                     
            sum(                     
             case when cntr_list.cntr_size_q = '40'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr40 ,                     
             sum(                     
             case when cntr_list.cntr_size_q = '45'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr45                      
    FROM (         
        SELECT yb1.BLOCK_M as SOURCE_BLOCK,     
               yb2.BLOCK_M as END_BLOCK,  
               scn.CNTR_SIZE_Q,          
               count(scn.CNTR_SIZE_Q) AS cntr_qty          
        FROM  SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2         
        WHERE         
        scm.cmr_n = scn.cmr_n               
        AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')                   
        OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))                   
        AND scm.shift_mode_c = :ShiftModeCode                             
        AND scm.end_terminal_c = :TerminalCode        
        AND scm.start_terminal_c = yb1.terminal_c                    
        AND scm.start_block_n = yb1.block_n                    
        AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n                    
        AND scm.end_terminal_c = yb2.terminal_c                    
        AND scm.end_block_n = yb2.block_n                    
        AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n             
        AND scn.status_c not in (1, 11)               
        AND scn.shift_type_c = 'V'               
        AND scn.source_c = 'S'         
        GROUP BY yb1.BLOCK_M, yb2.BLOCK_M, scn.CNTR_SIZE_Q         
    ) cntr_list         
    GROUP BY cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK
    3. I create a view link to create master-detail relationship for these 2 view objects.
    masterview.SourceBlock (1)->detailview.SourceBlock (*).
    4. I create a tree table using these 2 view objects with master-detail relationship.
    When I set default value for variable bindings of these 2 view objects and the matching records exist, tree table can work well. I can expand the master row to display detail row in UI.
    But I need to pass in dymamic parameter value for variable bindings of these 2 view objects, tree table cannnot work again. when I expand the master row and no detail row are displayed in UI.
    I am sure that I pass in correct parameter value for master/detail view objects and matching records exist.
    Managed Bean:
            DCIteratorBinding dc = (DCIteratorBinding)evaluteEL("#{bindings.MasterView1Iterator}");
            ViewObject vo = dc.getViewObject();
            System.out.println("Before MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
            System.out.println("Before MasterView1Iterator ShiftModeCode="+ vo.ensureVariableManager().getVariableValue("ShiftModeCode"));
            vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
            vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
            vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
            vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
            vo.executeQuery();
            System.out.println("MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
            DCIteratorBinding dc1 = (DCIteratorBinding)evaluteEL("#{bindings.DetailView1Iterator}");
            ViewObject vo1 = dc1.getViewObject();
            System.out.println("Before DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
            System.out.println("Before DetailView1Iterator ShiftModeCode="+ vo1.ensureVariableManager().getVariableValue("ShiftModeCode"));
            vo1.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
            vo1.ensureVariableManager().setVariableValue("DateTo", dateTo);
            vo1.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
            vo1.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
            vo1.executeQuery();
            System.out.println("after DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
    5.  What's wrong in my implementation?  I don't have no problem to implement such a tree table if using simple master-detail tables view object, but now I have to use such 2 view objects using complex SQL for my requirement and variable bindings are necessary for detail view object although I also think a bit strange by myself.

    Hi Frank,
    Thank you and it can work.
    public void setLowHighSalaryRangeForDetailEmployeesAccessorViewObject(Number lowSalary,
                                                                              Number highSalary) {
            Row r = getCurrentRow();
            if (r != null) {
                RowSet rs = (RowSet)r.getAttribute("EmpView");
                if (rs != null) {
                    ViewObject accessorVO = rs.getViewObject();
                    accessorVO.setNamedWhereClauseParam("LowSalary", lowSalary);
                    accessorVO.setNamedWhereClauseParam("HighSalary", highSalary);
                executeQuery();
    but I have a quesiton in this way. in code snippet, it is first getting current row of current master VO to determine if update variables value of detail VO. in my case, current row is possibly null after executeQuery() of master VO and  I have to change current row manually like below.
    any idea?
                DCIteratorBinding dc = (DCIteratorBinding)ADFUtil.evaluateEL("#{bindings.SSForecastSourceBlockView1Iterator}");
                ViewObject vo = dc.getViewObject();           
                vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
                vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
                vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
                vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
                vo.executeQuery();
                vo.setCurrentRowAtRangeIndex(0);
                ((SSForecastSourceBlockViewImpl)vo).synchornizeAccessorVOVariableValues();

  • Please sugges the link helpful for writing efficient sql queries

    Please suggest any good resource that is weblink which can help me in optimizing sql queries. especially while writing select statements improve the execution time of the sql query.
    Thanx in advance
    prasanth

    in general I found books from O'Reilly very helpful (not only for Oracle, but for Unix too).
    Moreover there is pretty good Oracle Documentation available.
    After all, it's not only about writing good queries, but also about setting up data-models, indexes, primary keys, etc.
    Look for a real slow computer, take a lot of data, then try writing your speedy queries. This is the school of hard knocks, on the long run it's the best training.

  • Sql server table as Target table

    Hi folks,
    I want to use sql server database table as target table in oracle warehouse builder.Is it possible in oracle warehouse builder 10.2.0.2.8.
    If their is any work arounds please let me know....
    Regards
    Kumar

    Hi Kumar,
    no, the target db must be oracle.
    Regards,
    Carsten.

Maybe you are looking for

  • Open Session: unexpected error

    Hi everybody, I'm using BO XI R3.0 and since couple of last days I'm having problem with opening Universe Designer. The message I'm getting is "Open session: unexpected error". This happens after I provide user name and password for the access to the

  • ITunes 10.6.1.7 won't open on my laptop. Help!

    I have tried various "fixes" that I have found on different blogs and help forums. I have tried uninstalling and reinstalling the program, typing in "netsh winsock reset" on some command page, and also getting rid of "Bonjour" prompts or something li

  • IPhoto 08 Bugs & Alterations...

    This is sooo slow. Am editing full screen on a second monitor which wasn't fantastically speedy in '06 but now it's taking me 10 seconds to save & move on to the next photo (10 megapixel camera) where it used to take me 2-3. Sick of the spinning beac

  • Hard drive crash...sync iPhone with iTunes Questions

    http://discussions.apple.com/thread.jspa?messageID=10891082#10891082 any info is helpful thanks

  • Scripting in solaris bourne shell

    I was wondering how would it be possible to match a string in a text file and then to choose a value present there. For exapmle; there is a line in a text file that reads ACT=ajbg110;PCN=55768;IUYT_ghTTY=88999yt;....... I need to make a script that i