Concatenation in SQL query

i have a doubt with the concatenation in a SQL query;
When i give something like:-
select 'drop table '|| tname from tab -- 1st statement
it works but when i give this as below:-
select 'drop table '|| tname from tab ';', --2nd statement
it gives a message like "SQL command not ended properly".
from statement --1, i was getting like a " ; " can start after a SQL word.
I hope, my question is clear. Please help, in solving the doubt.
regards.

This should be:
select 'drop table '|| tname ||';' from tab;

Similar Messages

  • Export to Excel from Report region (pl/sql returning sql query)

    Hello all,
    I have encountered an interesting problem. I have an HTMLDB application with a lot of sql reports coded straight inside the report region. In order to better organize my reports, I decided to
    1. make all my report regions of type "Pl/Sql function returning SQL query"
    2. create a package inside my database schema which houses all reports as pl/sql functions returning VARCHAR2, the string returned being the report query
    3. just calling "return package_name.function_name" from inside my report region of type "Pl/sql function returning SQL query".
    This technique seemed to work perfectly. The reports were being returned as expected. I was then asked to provide the "Export to Excel" capability to all my reports. This seemed like a piece of cake using HTML DB's "Export to Excel" extension. However, the "export to excel" does not function correctly when my reports are inside a package in the database. HTML DB tries to export but inside the excel spreadsheet, instead of seeing row data, I see:
    <pre>failed to parse SQL query:
    ORA-00936: missing expression
    <!-- select a.username, b.table_name, 'View Row Data' from schema_browser_user_list a, all_tables b where a.user_id = and a.username = b.owner order by b.table_name asc
    --!>
    </pre>
    I am building my query string inside of my package functions by using a combination of literal strings and concatenating them with some parameter values being passed in. It seems that the HTML DB engine which exports the report to excel does not properly understand the concatenation of variables as can be seen by the empty space to the right of the equal sign in the "a.user_id = " clause. Does anybody have any input as to whether this is a known issue or if I am doing something wrong? Thanks a lot for your time.
    - Kenny R.

    James,
    Thanks for the quick reply. I think you mis-understood what I'm doing. All I'm doing is creating packaged functions which return VARCHAR2. The VARCHAR2 that they return is the report query. With this technique, I no longer have to type the query into the HTML DB report region. Instead, I make the report region a "Pl/sql function returning sql query" and make the following call: return package_name.function_name(some_application_items passed in as parameters)
    This makes for a much more organized html db app. The problem is that the "export to excel" function does not correctly interpret the VARCHAR2 that my packaged functions are returning. Is this a better explanation? Thanks again for your time.
    - Kenny R.

  • Converting SQL Report Region to PLSQL Function Body Returning SQL Query

    All:
    I want to convert my SQL Report Region to a PLSQL-generated SQL Report Region so that I can eliminate where clauses dynamically and speed up my app, and also so that I can provide additional sorting options.
    <br><br>
    My problem is that I have lots of embedded single quotes that already are coded as 3 single quotes in the SQL Report Region. I am not sure at all how to code them within the PLSQL.
    <br><br>
    As example, here is one column from my query:
    <br><br>
    select decode(nvl(g.date_sub_1,g.date_rec_1), null, decode(g.article, 0, 'E', 1, 'U'), '< a href="javascript:unElevate( ' ' ' || g.grid || ' ' ',' ' ' || g.natca || ' ' ')">' || decode(g.article, 0, 'E', 1, 'U') || '< /a>') "Reverse" from g_table g
    <br><br>
    (Note that I added spaces within the code so it would display properly in the browser.)
    <br><br>
    To clarify, that's a double quote before javascript, and then 3 single quotes before the first concatenation group, then 3 single quotes after the second concatenation group, then 3 single quotes before the third, 3 single quotes after the fourth followed by an end-paren followed by a double quote etc.
    <br><br>
    My question is, what do I do with these triple-single quotes within PLSQL? Probably a no-brainer for the experienced folks, but I am thinking like a mobius strip at this point.
    <br><br>
    Bill
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Scott,
    I think that feature was made for my situation! I keep getting
    Function returning SQL query: Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the generic columns checkbox below the region source to proceed without parsing.
    (ORA-20001: Unable to bind :43 verify length of item is 30 bytes or less. Use v() syntax to reference items longer than 30 bytes. ORA-01006: bind variable does not exist)
    I did chop the query up into little bits, i.e.
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    return p_sql;
    But I'm not sure what I'm supposed to do here.
    Thank you.
    Bill

  • PL/SQL function body returning SQL query - ORA-06502: PL/SQL: numeric or value error

    I'm attempting to dynamically generate a rather large SQL query via the "PL/SQL function body returning SQL query" report region option.  The SQL query generated will possibly be over 32K.  When I execute my page, I sometimes receive the "ORA-06502: PL/SQL: numeric or value error" which points to a larger than 32K query that was generated.  I've seen other posts in the forum related to this dynamic SQL size limitation issue, but they are older (pre-2010) and point to the 32K limit of the DNS (EXECUTE IMMEDIATE) and DBMS_SQL.  I found this post (dynamic sql enhancements in 11g) which discusses 11g no longer having the 32K size limitation for generating dynamic SQL.  Our environment is on 11gR2 and using ApEx 4.2.1.  I do not know which dynamic SQL method -- DNS or DBMS_SQL -- ApEx 4.2.1 is using.  Can someone clarify for me which dynamic SQL method ApEx uses to implement the "PL/SQL function body returning SQL query" option?
    As a test, I created a page on apex.oracle.com with a report region with the following source:
    declare
      l_stub varchar2(25) := 'select * from sys.dual ';
      l_sql  clob := l_stub || 'union all ';
      br     number(3) := 33;
    begin
      while length ( l_sql ) < 34000 loop
        l_sql := l_sql || l_stub || 'union all ';
      end loop;
      l_sql := l_sql || l_stub;
      for i in 1 .. ceil ( length ( l_sql ) / br ) loop
        dbms_output.put_line ( dbms_lob.substr ( l_sql, br, ( ( i - 1 ) * br ) + 1 ) );
      end loop;
      return l_sql;
    end;
    The dbms_output section is there to be able to run this code in SQL*Plus and confirm the size of the SQL is indeed larger than 32K.  When running this in SQL*Plus, the procedure is successful and produces a proper SQL statement which can be executed.  When I put this into the report region on apex.oracle.com, I get the ORA-06502 error.
    I can certainly implement a work-around for my issue by creating a 'Before Header' process on the page which populates an ApEx collection with the data I am returning and then the report can simply select from the collection, but according to documentation, the above 32K limitation should be resolved in 11g.  Thoughts?
    Shane.

    What setting do you use in your report properties - especially in Type and in Region Source?
    If you have Type="SQL Query", then you should have a SELECT statement in the Region Source. Something like: SELECT .... FROM ... WHERE
    According to the ERR-1101 error message, you have probably set Type to "SQL Query (PL/SQL function body returning SQL query)". In this situation APEX expects you to write a body of a PL/SQL function, that will generate the text of a SQL query that APEX should run. So it can be something like:
    declare
    mycond varchar2(4000);
    begin
    if :P1_REPORT_SEARCH is not null THEN
    mycond:='WHERE LAST_NAME like :P1_REPORT_SEARCH ||''%''';
    end if;
    return 'select EMPLOYEE_ID, FIRST_NAME, LAST_NAME from EMPLOYEES ' ||mycond;
    end;
    And for escaping - are you interested in escaping the LIKE wildcards, or the quotes?
    For escaping the wildcards in LIKE function so that when the user enters % you will find a record with % and not all functions, look into the SQL Reference:
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm
    (You would than need to change the code of your function accordingly).
    If you are interested in escaping the quotes, try to avoid concatenating the values entered by the user into the SQL. If you can, use bind variables instead - as I have in my example above. If you start concatenating the values into the text of SQL, you are open to SQLInjection - user can enter anything, even things that will break your SQL. If you really need to allow users to choose the operator, I would probably give them a separate combo for operators and a textfield for values, than you could check if the operator is one of the allowed ones and create the condition accordingly - and than still use bind variable for inserting the filtering value into the query.

  • Can't  write right sql query by two tables

    Hello
    Everyone,
    I am trying to get a sql query by two tables,
    table:container
    <pre class="jive-pre">
    from_dest_id     number
    ship_from_desc     varchar
    to_dest_id     number
    </pre>
    table: label_fromat (changeless)
    <pre class="jive-pre">
    SORT_ORDER     number
    PREFIX     varchar2
    VARIABLE_NAME varchar2
    SUFFIX varchar2
    LF_COMMENT varchar2
    </pre>
    the sql which i need is
    a. table CONTAINER 's each column should have LABLE_FORMAT 's PREFIX before and SUFFIX back ,and these columns is connected
    example : the query output should be like this :
    <pre class="jive-pre">
    PREFIX||from_dest_id||SUFFIX ||PREFIX||ship_from_desc||SUFFIX ||PREFIX|| to_dest_id||SUFFIX
    </pre>
    every PREFIX and SUFFIX are come from LABEL_FORMAT's column VARIABLE_NAME (they are different)
    column SORT_ORDER decide the sequence, for the example above: Column from_dest_id order is 1, ship_from_desc is 2,to_dest_id is 3
    b. table LABEL_FORMAT's column VARIABLE_NAME have values ('from_dest_id','ship_from_desc','to_dest_id')
    If table CONTAINER only have one record i can do it myself,
    But actually it is more than one record,I do not know how to do
    May be this should be used PL/SQL,or a Function ,Cursor ,Procedure
    I am not good at these
    Any tips will be very helpful for me
    Thanks
    Saven

    Hi, Saven,
    Presenting data from multiple rows as a single string is called String Aggregation . This page:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    shows many ways to do it, suited to different requirements, and different versions of Oracle.
    In Oracle 10 (and up) you can do this:
    SELECT     REPLACE ( SYS_CONNECT_BY_PATH ( f.prefix || ' '
                                   || CASE  f.variable_name
                                        WHEN 'FROM_DEST_ID'
                                       THEN  from_dest_id
                                       WHEN 'SHIP_FROM_DESC'
                                       THEN  ship_from_desc
                                       WHEN 'TO_DEST_ID'
                                       THEN  to_dest_id
                                      END
                                   || ' '
                                   || f.suffix
                               , '~?'
              , '~?'
              )     AS output_txt
    FROM          container     c
    CROSS JOIN     label_format     f
    WHERE          CONNECT_BY_ISLEAF     = 1
    START WITH     f.sort_order     = 1
    CONNECT BY     f.sort_order     = PRIOR f.sort_order + 1
         AND     c.from_dest_id     = PRIOR c.from_dest_id
    saven wrote:If table CONTAINER only have one record i can do it myself,
    But actually it is more than one record,I do not know how to do In that case, why did you post an example that only has one row in container?
    The query above assumes
    something in container (I used from_dest_id in the example above) is unique,
    you don't mind having a space after prefix and before from_dest_id,
    you want one row of output for every row in container, and
    you can identify some string ('~?' in the example above) that never occurs in the concatenated data.

  • SQL query problem with sorting

    Hi,
    I have question regarding sql query . Right now I am getting the results like this if i use this sql query
    select ID,Name,Desc,Priority from emp order by Priority ;
    Priority is varchar field. I don't want to change the Priority field and cannot add a new column in the table. Because i don't have permission to do that.
    ID Name Desc Priority
    =============================================
    234 paul paul desc Highest
    3452 mike mike desc High
    4342 smith smith desc Low
    6565 kelly kelly desc Low
    9878 nate nate desc Medium
    3223 deb deb desc High
    ============================================
    I need a query to get the results like that.
    ID Name Desc Priority
    =============================================
    234 paul paul desc Highest
    3452 mike mike desc High
    3223 deb deb desc High
    9878 nate nate desc Medium
    4342 smith smith desc Low
    6565 kelly kelly desc Low
    ============================================
    If any one knows about this one, please let me know.
    Thanks,
    Bala

    You are aware that there are differences in the SQL implementation between Sqlserver and Oracle? You could try something like this, if there's a INSTR function:
    ORDER BY INSTR('Highest,High,Medium,Low,', Priority || ',')You may have to change the "Priority || ," to a "Priority + ','), if string concatenation is done differently in sqlserver. Don't know about the ('), maybe you need (").
    C.

  • Force index not getting picked up while running the SQL Query

    Hi All,
    We are facing an issue with one SQL Query. We have created a custom Index and we are using that index in our query by using the following syntax:
    /*+INDEX(ol XXEXH_ORDER_LINES_N2)*/
    Where
    ol – Table Alias Name
    XXEXH_ORDER_LINES_N2 – Index Name
    But still the index is not getting picked up in the Explain Plan.
    If any one of you have faced a similar issue then please let us know how you had resolved it.
    Appreciate your help.
    DB version:10.2.0.4
    Apps version: 11.5.10.2.0
    Thanks.

    The query and plan are given as:
    SELECT
    /*+INDEX(ol XXEXH_ORDER_LINES_N2)*/
    ol.header_id,
    ol.line_id,
    ol.line_type_id,
    ol.flow_status_code,
    ol.last_update_date,
    ol.inventory_item_id,
    ol.ship_from_org_id,
    oh.order_number,
    ttv.NAME,
    msib.segment1,
    msib.item_type,
    fl.segment1 || '-' || fl.segment2 || '-' || fl.segment3 || '-' || fl.segment4 current_loc,
    ship_to.country
    || '-'
    || NVL (ship_to.state, ship_to.province)
    || '-'
    || DECODE (ship_to.county,
    NULL, ship_to.city,
    ship_to.county
    || DECODE (ship_to.country,
    NULL, NULL,
    '-' || ship_to.city
    ) new_loc,
    mmt.transaction_type_id,
    mtt.transaction_type_name,
    DECODE (mil.segment1,
    UPPER ('Field%'), 'PLEASE VALIDATE FIELD LOCATION',
    hou.country
    || '-'
    || DECODE (mil.segment1,
    UPPER ('Field%'), NULL,
    hou.region_2
    || '-'
    || DECODE (mil.segment1,
    UPPER ('Field%'), NULL,
    hou.region_1
    || '-'
    || DECODE (mil.segment1,
    UPPER ('Field%'), NULL,
    hou.town_or_city
    ) rma_loc,
    ship_su.attribute1 oper_loc,
    msib.organization_id --SC#5878
    ,fa.asset_number --SC#5878
    ,fdh.code_combination_id --SC#5878
    ,fa.asset_id parent_asset_id
    FROM fnd_flex_values_vl ffvv,
    fnd_flex_value_sets ffvs,
    mtl_item_locations mil,
    --hr_organization_units_v hou,
    hr_organization_units o,
    -- hr_lookups l,
    -- hr_lookups l2,
    hr_locations hou,
    hr_locations_all_tl lot,
    mtl_transaction_types mtt,
    mtl_material_transactions mmt,
    hz_locations ship_to,
    hz_cust_acct_sites ship_cas,
    hz_cust_site_uses ship_su,
    hz_party_sites ship_ps,
    fa_distribution_history fdh,
    fa_locations fl,
    fa_additions fa,
    mtl_system_items_b msib,
    oe_transaction_types_tl ttv,
    oe_order_headers oh,
    oe_order_lines ol
    WHERE ol.org_id = TO_NUMBER (fnd_profile.VALUE ('ORG_ID')) --SC#5878
    AND ol.flow_status_code = 'CLOSED'
    AND TRUNC(ol.last_update_date) BETWEEN '01-SEP-2010' AND '31-OCT-2010'
    AND ol.header_id = oh.header_id
    AND ol.line_type_id = ttv.transaction_type_id
    AND ol.inventory_item_id = msib.inventory_item_id
    AND ol.ship_from_org_id = msib.organization_id
    AND msib.item_type = 'REN'
    AND SUBSTR(fa.asset_number,1,DECODE(INSTR(fa.asset_number,'-'),0,LENGTH(fa.asset_number),INSTR(fa.asset_number,'-')-1)) = msib.segment1 -- SC#11824 / added for fetching all assets with any suffix/ on 20-JUL-2011 by MPRAKAS
    AND fdh.asset_id(+) = fa.asset_id
    AND fdh.location_id = fl.location_id(+)
    AND fdh.date_ineffective IS NULL
    AND ol.ship_to_org_id = ship_su.site_use_id
    AND ship_su.cust_acct_site_id = ship_cas.cust_acct_site_id
    AND ship_cas.party_site_id = ship_ps.party_site_id
    AND ship_ps.location_id = ship_to.location_id
    AND mmt.inventory_item_id = ol.inventory_item_id --added new condition
    AND mmt.organization_id = ol.ship_from_org_id --added new condition
    AND mmt.trx_source_line_id = ol.line_id
    AND mmt.transaction_quantity > 0
    AND mmt.transaction_type_id = mtt.transaction_type_id(+)
    AND mtt.transaction_type_name(+) = 'RMA Receipt'
    AND o.organization_id(+) = mmt.organization_id
    AND mil.inventory_location_id(+) = mmt.locator_id
    AND ffvs.flex_value_set_name = 'HCCA_AFF_LOCATION' --added new condition
    AND ffvv.flex_value_set_id = ffvs.flex_value_set_id(+)
    AND ffvv.flex_value(+) = ship_su.attribute1
    AND ttv.LANGUAGE = 'US'
    AND (ol.ordered_item_id IS NULL OR ol.ordered_item_id > 0)
    AND NVL (ol.ship_to_org_id, 1) > 0
    AND NVL (hou.location_id, 1) > 0
    AND o.location_id = hou.location_id(+)
    AND NVL (hou.business_group_id, NVL (hr_general.get_business_group_id, -99)) = NVL (hr_general.get_business_group_id, -99)
    AND hou.location_id = lot.location_id
    AND lot.LANGUAGE = USERENV ('LANG')
    AND (fa.asset_id = fa.parent_asset_id OR fa.parent_asset_id IS NULL)
    Plan
    SELECT STATEMENT ALL_ROWSCost: 4,065 Bytes: 958 Cardinality: 2                                                                                                                                   
         125 CONCATENATION                                                                                                                              
              62 NESTED LOOPS OUTER Cost: 3,140 Bytes: 479 Cardinality: 1                                                                                                                         
                   59 FILTER                                                                                                                    
                        58 NESTED LOOPS OUTER Cost: 3,139 Bytes: 441 Cardinality: 1                                                                                                               
                             55 NESTED LOOPS Cost: 3,131 Bytes: 420 Cardinality: 1                                                                                                          
                                  52 NESTED LOOPS OUTER Cost: 3,130 Bytes: 390 Cardinality: 1                                                                                                     
                                       49 NESTED LOOPS OUTER Cost: 3,128 Bytes: 377 Cardinality: 1                                                                                                
                                            46 NESTED LOOPS Cost: 3,127 Bytes: 351 Cardinality: 1                                                                                           
                                                 44 HASH JOIN Cost: 3,126 Bytes: 342 Cardinality: 1                                                                                      
                                                      42 NESTED LOOPS Cost: 2,443 Bytes: 324 Cardinality: 1                                                                                 
                                                           40 NESTED LOOPS Cost: 2,443 Bytes: 315 Cardinality: 1                                                                            
                                                                38 NESTED LOOPS Cost: 2,443 Bytes: 306 Cardinality: 1                                                                       
                                                                     36 NESTED LOOPS Cost: 2,443 Bytes: 298 Cardinality: 1                                                                  
                                                                          33 NESTED LOOPS Cost: 2,442 Bytes: 268 Cardinality: 1                                                             
                                                                               31 NESTED LOOPS Cost: 2,441 Bytes: 259 Cardinality: 1                                                        
                                                                                    28 NESTED LOOPS Cost: 2,438 Bytes: 238 Cardinality: 1                                                   
                                                                                         25 NESTED LOOPS Cost: 2,437 Bytes: 207 Cardinality: 1                                              
                                                                                              22 NESTED LOOPS Cost: 2,436 Bytes: 194 Cardinality: 1                                         
                                                                                                   19 NESTED LOOPS Cost: 2,435 Bytes: 184 Cardinality: 1                                    
                                                                                                        16 NESTED LOOPS Cost: 2,433 Bytes: 168 Cardinality: 1                               
                                                                                                             13 NESTED LOOPS Cost: 2,432 Bytes: 154 Cardinality: 1                          
                                                                                                                  10 NESTED LOOPS Cost: 2,430 Bytes: 126 Cardinality: 1                     
                                                                                                                       7 NESTED LOOPS Cost: 2,427 Bytes: 102 Cardinality: 1                
                                                                                                                            4 NESTED LOOPS Cost: 779 Bytes: 34,028 Cardinality: 724           
                                                                                                                                 2 TABLE ACCESS BY INDEX ROWID TABLE APPLSYS.FND_FLEX_VALUE_SETS Cost: 2 Bytes: 28 Cardinality: 1      
                                                                                                                                      1 INDEX UNIQUE SCAN INDEX (UNIQUE) APPLSYS.FND_FLEX_VALUE_SETS_U2 Cost: 1 Cardinality: 1
                                                                                                                                 3 TABLE ACCESS FULL TABLE AR.HZ_CUST_SITE_USES_ALL Cost: 777 Bytes: 13,756 Cardinality: 724      
                                                                                                                            6 TABLE ACCESS BY INDEX ROWID TABLE ONT.OE_ORDER_LINES_ALL Cost: 3 Bytes: 55 Cardinality: 1           
                                                                                                                                 5 INDEX RANGE SCAN INDEX ONT.OE_ORDER_LINES_N2 Cost: 2 Cardinality: 1      
                                                                                                                       9 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_MATERIAL_TRANSACTIONS Cost: 3 Bytes: 24 Cardinality: 1                
                                                                                                                            8 INDEX RANGE SCAN INDEX INV.MTL_MATERIAL_TRANSACTIONS_N1 Cost: 2 Cardinality: 1           
                                                                                                                  12 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_SYSTEM_ITEMS_B Cost: 2 Bytes: 28 Cardinality: 1                     
                                                                                                                       11 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Cardinality: 1                
                                                                                                             15 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_CUST_ACCT_SITES_ALL Cost: 1 Bytes: 14 Cardinality: 1                          
                                                                                                                  14 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_CUST_ACCT_SITES_U1 Cost: 0 Cardinality: 1                     
                                                                                                        18 TABLE ACCESS BY INDEX ROWID TABLE ONT.OE_ORDER_HEADERS_ALL Cost: 2 Bytes: 16 Cardinality: 1                               
                                                                                                             17 INDEX UNIQUE SCAN INDEX (UNIQUE) ONT.OE_ORDER_HEADERS_U1 Cost: 1 Cardinality: 1                          
                                                                                                   21 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_PARTY_SITES Cost: 1 Bytes: 10 Cardinality: 1                                    
                                                                                                        20 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_PARTY_SITES_U1 Cost: 0 Cardinality: 1                               
                                                                                              24 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ALL_ORGANIZATION_UNITS Cost: 1 Bytes: 13 Cardinality: 1                                         
                                                                                                   23 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ORGANIZATION_UNITS_PK Cost: 0 Cardinality: 1                                    
                                                                                         27 TABLE ACCESS BY INDEX ROWID TABLE ONT.OE_TRANSACTION_TYPES_TL Cost: 1 Bytes: 31 Cardinality: 1                                              
                                                                                              26 INDEX UNIQUE SCAN INDEX (UNIQUE) ONT.OE_TRANSACTION_TYPES_TL_U1 Cost: 0 Cardinality: 1                                         
                                                                                    30 TABLE ACCESS BY INDEX ROWID TABLE APPLSYS.FND_FLEX_VALUES Cost: 3 Bytes: 21 Cardinality: 1                                                   
                                                                                         29 INDEX RANGE SCAN INDEX APPLSYS.FND_FLEX_VALUES_N1 Cost: 2 Cardinality: 1                                              
                                                                               32 INDEX UNIQUE SCAN INDEX (UNIQUE) APPLSYS.FND_FLEX_VALUES_TL_U1 Cost: 1 Bytes: 9 Cardinality: 1                                                        
                                                                          35 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_LOCATIONS_ALL Cost: 1 Bytes: 30 Cardinality: 1                                                             
                                                                               34 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_LOCATIONS_PK Cost: 0 Cardinality: 1                                                        
                                                                     37 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ALL_ORGANIZATION_UNTS_TL_PK Cost: 0 Bytes: 8 Cardinality: 1                                                                  
                                                                39 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_LOCATIONS_ALL_TL_PK Cost: 0 Bytes: 9 Cardinality: 1                                                                       
                                                           41 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_LOCATIONS_ALL_TL_PK Cost: 0 Bytes: 9 Cardinality: 1                                                                            
                                                      43 TABLE ACCESS FULL TABLE FA.FA_ADDITIONS_B Cost: 683 Bytes: 670,734 Cardinality: 37,263                                                                                 
                                                 45 INDEX UNIQUE SCAN INDEX (UNIQUE) FA.FA_ADDITIONS_TL_U1 Cost: 1 Bytes: 9 Cardinality: 1                                                                                      
                                            48 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_TRANSACTION_TYPES Cost: 1 Bytes: 26 Cardinality: 1                                                                                           
                                                 47 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_TRANSACTION_TYPES_U1 Cost: 0 Cardinality: 1                                                                                      
                                       51 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_ITEM_LOCATIONS Cost: 2 Bytes: 13 Cardinality: 1                                                                                                
                                            50 INDEX RANGE SCAN INDEX (UNIQUE) INV.MTL_ITEM_LOCATIONS_U1 Cost: 1 Cardinality: 1                                                                                           
                                  54 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_LOCATIONS Cost: 1 Bytes: 30 Cardinality: 1                                                                                                     
                                       53 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_LOCATIONS_U1 Cost: 0 Cardinality: 1                                                                                                
                             57 TABLE ACCESS BY INDEX ROWID TABLE FA.FA_DISTRIBUTION_HISTORY Cost: 8 Bytes: 126 Cardinality: 6                                                                                                          
                                  56 INDEX RANGE SCAN INDEX FA.FA_DISTRIBUTION_HISTORY_N2 Cost: 2 Cardinality: 6                                                                                                     
                   61 TABLE ACCESS BY INDEX ROWID TABLE FA.FA_LOCATIONS Cost: 1 Bytes: 38 Cardinality: 1                                                                                                                    
                        60 INDEX UNIQUE SCAN INDEX (UNIQUE) FA.FA_LOCATIONS_U1 Cost: 0 Cardinality: 1                                                                                                               
              124 NESTED LOOPS OUTER Cost: 925 Bytes: 479 Cardinality: 1                                                                                                                         
                   121 FILTER                                                                                                                    
                        120 NESTED LOOPS OUTER Cost: 924 Bytes: 441 Cardinality: 1                                                                                                               
                             117 NESTED LOOPS Cost: 916 Bytes: 420 Cardinality: 1                                                                                                          
                                  115 HASH JOIN Cost: 915 Bytes: 411 Cardinality: 1                                                                                                     
                                       113 NESTED LOOPS OUTER Cost: 231 Bytes: 393 Cardinality: 1                                                                                                
                                            110 NESTED LOOPS OUTER Cost: 229 Bytes: 380 Cardinality: 1                                                                                           
                                                 107 NESTED LOOPS Cost: 228 Bytes: 354 Cardinality: 1                                                                                      
                                                      104 NESTED LOOPS Cost: 225 Bytes: 330 Cardinality: 1                                                                                 
                                                           102 NESTED LOOPS Cost: 224 Bytes: 321 Cardinality: 1                                                                            
                                                                99 NESTED LOOPS Cost: 222 Bytes: 293 Cardinality: 1                                                                       
                                                                     96 NESTED LOOPS Cost: 221 Bytes: 263 Cardinality: 1                                                                  
                                                                          93 NESTED LOOPS Cost: 220 Bytes: 253 Cardinality: 1                                                             
                                                                               90 NESTED LOOPS Cost: 218 Bytes: 237 Cardinality: 1                                                        
                                                                                    87 NESTED LOOPS Cost: 217 Bytes: 223 Cardinality: 1                                                   
                                                                                         84 NESTED LOOPS Cost: 216 Bytes: 192 Cardinality: 1                                              
                                                                                              81 NESTED LOOPS Cost: 210 Bytes: 137 Cardinality: 1                                         
                                                                                                   78 NESTED LOOPS Cost: 28 Bytes: 118 Cardinality: 1                                    
                                                                                                        75 NESTED LOOPS Cost: 22 Bytes: 97 Cardinality: 1                               
                                                                                                             73 NESTED LOOPS Cost: 22 Bytes: 88 Cardinality: 1                          
                                                                                                                  71 NESTED LOOPS Cost: 22 Bytes: 79 Cardinality: 1                     
                                                                                                                       69 NESTED LOOPS Cost: 22 Bytes: 71 Cardinality: 1                
                                                                                                                            66 NESTED LOOPS Cost: 19 Bytes: 58 Cardinality: 1           
                                                                                                                                 64 TABLE ACCESS BY INDEX ROWID TABLE APPLSYS.FND_FLEX_VALUE_SETS Cost: 2 Bytes: 28 Cardinality: 1      
                                                                                                                                      63 INDEX UNIQUE SCAN INDEX (UNIQUE) APPLSYS.FND_FLEX_VALUE_SETS_U2 Cost: 1 Cardinality: 1
                                                                                                                                 65 TABLE ACCESS FULL TABLE HR.HR_LOCATIONS_ALL Cost: 17 Bytes: 30 Cardinality: 1      
                                                                                                                            68 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ALL_ORGANIZATION_UNITS Cost: 3 Bytes: 13 Cardinality: 1           
                                                                                                                                 67 INDEX RANGE SCAN INDEX HR.HR_ORGANIZATION_UNITS_FK3 Cost: 1 Cardinality: 5      
                                                                                                                       70 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ALL_ORGANIZATION_UNTS_TL_PK Cost: 0 Bytes: 8 Cardinality: 1                
                                                                                                                  72 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_LOCATIONS_ALL_TL_PK Cost: 0 Bytes: 9 Cardinality: 1                     
                                                                                                             74 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_LOCATIONS_ALL_TL_PK Cost: 0 Bytes: 9 Cardinality: 1                          
                                                                                                        77 TABLE ACCESS BY INDEX ROWID TABLE APPLSYS.FND_FLEX_VALUES Cost: 6 Bytes: 2,667 Cardinality: 127                               
                                                                                                             76 INDEX RANGE SCAN INDEX APPLSYS.FND_FLEX_VALUES_N2 Cost: 2 Cardinality: 127                          
                                                                                                   80 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_CUST_SITE_USES_ALL Cost: 182 Bytes: 19 Cardinality: 1                                    
                                                                                                        79 INDEX RANGE SCAN INDEX APPS.HCCA_HZ_CUST_SITE_USES_ALL_N1 Cost: 1 Cardinality: 489                               
                                                                                              83 TABLE ACCESS BY INDEX ROWID TABLE ONT.OE_ORDER_LINES_ALL Cost: 6 Bytes: 55 Cardinality: 1                                         
                                                                                                   82 INDEX RANGE SCAN INDEX ONT.OE_ORDER_LINES_N2 Cost: 2 Cardinality: 4                                    
                                                                                         86 TABLE ACCESS BY INDEX ROWID TABLE ONT.OE_TRANSACTION_TYPES_TL Cost: 1 Bytes: 31 Cardinality: 1                                              
                                                                                              85 INDEX UNIQUE SCAN INDEX (UNIQUE) ONT.OE_TRANSACTION_TYPES_TL_U1 Cost: 0 Cardinality: 1                                         
                                                                                    89 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_CUST_ACCT_SITES_ALL Cost: 1 Bytes: 14 Cardinality: 1                                                   
                                                                                         88 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_CUST_ACCT_SITES_U1 Cost: 0 Cardinality: 1                                              
                                                                               92 TABLE ACCESS BY INDEX ROWID TABLE ONT.OE_ORDER_HEADERS_ALL Cost: 2 Bytes: 16 Cardinality: 1                                                        
                                                                                    91 INDEX UNIQUE SCAN INDEX (UNIQUE) ONT.OE_ORDER_HEADERS_U1 Cost: 1 Cardinality: 1                                                   
                                                                          95 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_PARTY_SITES Cost: 1 Bytes: 10 Cardinality: 1                                                             
                                                                               94 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_PARTY_SITES_U1 Cost: 0 Cardinality: 1                                                        
                                                                     98 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_LOCATIONS Cost: 1 Bytes: 30 Cardinality: 1                                                                  
                                                                          97 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_LOCATIONS_U1 Cost: 0 Cardinality: 1                                                             
                                                                101 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_SYSTEM_ITEMS_B Cost: 2 Bytes: 28 Cardinality: 1                                                                       
                                                                     100 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Cardinality: 1                                                                  
                                                           103 INDEX UNIQUE SCAN INDEX (UNIQUE) APPLSYS.FND_FLEX_VALUES_TL_U1 Cost: 1 Bytes: 9 Cardinality: 1                                                                            
                                                      106 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_MATERIAL_TRANSACTIONS Cost: 3 Bytes: 24 Cardinality: 1                                                                                 
                                                           105 INDEX RANGE SCAN INDEX INV.MTL_MATERIAL_TRANSACTIONS_N1 Cost: 2 Cardinality: 1                                                                            
                                                 109 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_TRANSACTION_TYPES Cost: 1 Bytes: 26 Cardinality: 1                                                                                      
                                                      108 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_TRANSACTION_TYPES_U1 Cost: 0 Cardinality: 1                                                                                 
                                            112 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_ITEM_LOCATIONS Cost: 2 Bytes: 13 Cardinality: 1                                                                                           
                                                 111 INDEX RANGE SCAN INDEX (UNIQUE) INV.MTL_ITEM_LOCATIONS_U1 Cost: 1 Cardinality: 1                                                                                      
                                       114 TABLE ACCESS FULL TABLE FA.FA_ADDITIONS_B Cost: 683 Bytes: 670,734 Cardinality: 37,263                                                                                                
                                  116 INDEX UNIQUE SCAN INDEX (UNIQUE) FA.FA_ADDITIONS_TL_U1 Cost: 1 Bytes: 9 Cardinality: 1                                                                                                     
                             119 TABLE ACCESS BY INDEX ROWID TABLE FA.FA_DISTRIBUTION_HISTORY Cost: 8 Bytes: 126 Cardinality: 6                                                                                                          
                                  118 INDEX RANGE SCAN INDEX FA.FA_DISTRIBUTION_HISTORY_N2 Cost: 2 Cardinality: 6                                                                                                     
                   123 TABLE ACCESS BY INDEX ROWID TABLE FA.FA_LOCATIONS Cost: 1 Bytes: 38 Cardinality: 1                                                                                                                    
                        122 INDEX UNIQUE SCAN INDEX (UNIQUE) FA.FA_LOCATIONS_U1 Cost: 0 Cardinality: 1

  • HTML-DB 1.6 SQL Query (Concatenate two columns)

    Hi everyone,
    My query look like this. But I got this message
    ORA-01403: no data found
    Sql query(.....returning ... sql
    What I can do ? I want to concatenate my two columns in one.
    <pre>
    -----Résultats de la recherche
    BEGIN
    DECLARE
    requete varchar2(5000);
    v_code_type varchar2(2000);
    v_ordre varchar2(500);
    BEGIN
    :P1_NOM_BENEFICIAIRE := REPLACE(:P1_NOM_BENEFICIAIRE,' ', '%');
    :P1_NOM_BENEFICIAIRE := REPLACE(:P1_NOM_BENEFICIAIRE,'-', '%');
    requete := 'SELECT
    (FEUI.NOM_BENEFICIAIRE || ''--'' || FEUI.PRENOM_BENEFICIAIRE) ABC,
    FEUI.VALEUR_ID_BENEFICIAIRE,
    FEUI.MONTANT,
    FEUI.CODE_TYPE_DECLARATION,
    FEUI.ANNEE_FISCALE,
    FEUI.CODE_ENTITE,
    FEUI.ID_FEUILLET_IMPOT,
    FEUI.ID_AMENDEMENT,
    FEUI.NO_RELEVE_ORIGINAL_PROV,
    FEUI.ACRONYME_ID_BENEFICIAIRE,
    TYPD.SIGNIFICATION
    FROM
    S29_FEUILLET_IMPOT FEUI,
    S29_TYPE_DECLARATION TYPD
    WHERE
    (TYPD.CODE = FEUI.CODE_TYPE_DECLARATION) AND
    (ANNEE_FISCALE = :P1_ANNEE_FISCALE) AND
    (CODE_ENTITE LIKE ''%'' || SUBSTR(:P1_CODE_ENTITE,1,3) || ''%'') OR
    (CODE_ENTITE = SUBSTR(:P1_CODE_ENTITE,1,3))
    AND
    ((:P1_NAS IS NULL) OR (:P1_NAS = VALEUR_ID_BENEFICIAIRE))
    AND
    ((:P1_NEQ IS NULL) OR (:P1_NEQ = VALEUR_ID_BENEFICIAIRE))
    AND
    ((:P1_NOM_BENEFICIAIRE IS NULL) OR
    ((UPPER(NOM_BENEFICIAIRE) || UPPER(PRENOM_BENEFICIAIRE))
    LIKE ''%'' || UPPER(:P1_NOM_BENEFICIAIRE) || ''%'') OR
    ((UPPER(PRENOM_BENEFICIAIRE) || UPPER(NOM_BENEFICIAIRE))
    LIKE ''%'' || UPPER(:P1_NOM_BENEFICIAIRE) || ''%'') OR
    ((UPPER(RAISON_SOCIALE_LIGNE_1) || UPPER(RAISON_SOCIALE_LIGNE_2))
    LIKE ''%'' || UPPER(:P1_NOM_BENEFICIAIRE) || ''%'') OR
    ((UPPER(RAISON_SOCIALE_LIGNE_2) || UPPER(RAISON_SOCIALE_LIGNE_1))
    LIKE ''%'' || UPPER(:P1_NOM_BENEFICIAIRE) || ''%'') OR
    (UPPER(SUBSTR(COORDONNEE_BENEFICIAIRE_SYGBEC,1,80))
    LIKE ''%'' || UPPER(:P1_NOM_BENEFICIAIRE) || ''%'')
    IF (:P1_CODE_RELEVE = 'A') OR
    (:P1_CODE_RELEVE = 'M') OR
    (:P1_CODE_RELEVE = 'C') THEN
    v_code_type := '(
    (FEUI.CODE_TYPE_DECLARATION = ''A'') OR
    (FEUI.CODE_TYPE_DECLARATION = ''M'') OR
    (FEUI.CODE_TYPE_DECLARATION = ''C'')
    else
    v_code_type :=
    (:P1_CODE_RELEVE = CODE_TYPE_DECLARATION) OR
    (:P1_CODE_RELEVE = ''%'')
    end if;
    WWV_FLOW.DEBUG('V_CODE_TYPE EST EGALE A :' || v_code_type);
    v_ordre := 'ORDER BY NOM_BENEFICIAIRE, VALEUR_ID_BENEFICIAIRE,
    ID_FEUILLET_IMPOT, ID_AMENDEMENT';
    requete := requete || ' AND ' || v_code_type || v_ordre;
    RETURN requete;
    END;
    END;
    </pre>
    Thanks. Bye

    Thank you Scott,
    I'm sorry, I should present you a reduce sql command.
    I had construct my "long" sql command without concatenation. But, I decide to add a column just beside the other column.
    After sending my message on OTN, I tried something else, I decided to copy my sql command without concatenation in an other region. I changed my sql command in the new region by adding my new column and this ''--'' and it works very well. Sometimes, It's really difficult to understand why it doesn't.
    Thanks. Bye,

  • Determining the parameters passed in a Discoverer Report through SQL query

    Hi,
    I want to know the parameters passed in a Discoverer Report through a SQL query.
    i.e if we pass the Report name (Workbook Name) then we get the paramaters used .
    Is there any way we can do this.
    Any help will be really appreciated.
    Thanx in advance
    Ankur

    Hi
    You can indeed get the parameters from the EUL5_QPP_STATS table, although they are extremely difficult to get at.
    Look at this script:
    SELECT
    QS.QS_DOC_OWNER    USER_NAME,
    QS.QS_DOC_NAME     WORKBOOK,
    QS.QS_DOC_DETAILS  WORKSHEET,
    TRUNC(QS.QS_CREATED_DATE) DOC_DATE,
    *(LENGTH(TO_CHAR(EUL5_GET_ITEM_NAME(QS.QS_ID)))+1)/9 ITEMS,*
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),1,  6)) ITEM1,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),10, 6)) ITEM2,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),19, 6)) ITEM3,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),28, 6)) ITEM4,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),37, 6)) ITEM5,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),46, 6)) ITEM6,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),55, 6)) ITEM7,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),64, 6)) ITEM8,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),73, 6)) ITEM9,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),82, 6)) ITEM10,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),91, 6)) ITEM11,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),100,6)) ITEM12,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),109,6)) ITEM13,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),118,6)) ITEM14,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),127,6)) ITEM15,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),136,6)) ITEM16,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),145,6)) ITEM17,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),154,6)) ITEM18,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),163,6)) ITEM19,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),172,6)) ITEM20
    FROM
    EUL5_QPP_STATS QS--,
    --   APPS.FND_USER          USR
    WHERE
    --   QS.QS_DOC_OWNER = '#' || USR.USER_ID AND
    *(LENGTH(TO_CHAR(EUL5_GET_ITEM_NAME(QS.QS_ID)))+1)/9 < 21*
    AND QS.QS_CREATED_DATE > '01-JAN-2007'
    What this does is return the first 20 items used in a worksheet. It does this by passing 6 characters at a time out of a cusror made up by concatenating QS_DBMP0 to QS_DBMP7 to get the Dimensions and then again by concatenating QS_MBMP0 to QS_MBMP7 to get the Measures. Having got that cursor it then takes each 6 characters and passes them to a nibble algorithm to decode the actual item. The code is extremely difficult to follow.
    I mention this because other fields in the same table are QS_JBMP0 to QS_JBMP7 which I believe are Joins, and QS_FBMP0 to QS_FBMP7 which look like Filters (aka parameters) being used. I think the QS stands for Query Statistics and BMP for bitmap. Somewhere in the EUL5.SQL script is the key to unlocking this.
    Good luck. The reason I say this will become apparent when you look inside EUL5.SQL.
    Best wsihes
    Mcihael

  • How to modify a SQL query?

    Hi all,
    I am using Crystal Reports version 10. I have a number of reports that have been written by a software vendor wherby the name of the database they were connected to when the report was written is coded into the FROM command of the reports SQL query, eg "GCUK_2" in the of the SQL snippet below.
    SELECT "Clients"."NAME", "Quotes"."QUOTE_ID", "Quote_Items"."UPRICE", "Quote_Items"."QTY", "Quote_Items"."UOM", "Quote_Items"."QUSAGE_ID", "Report_Control"."QUSAGEID", "Quote_Items"."STANDARD", "Quote_Items"."SECT_FLAG", "Quote_Items"."DISPORDER", "Quotes"."DESCRIPT", "Report_Control"."SECT_NAME", "Quote_Items"."CNT", "Category_and_Type"."TYPEDESC", "Quote_Items"."DESCRIPT", "Report_Control"."DISP_SORT"
    FROM   ((("GCUK_2"."schedwin"."QTE_CTRL" "Report_Control" INNER JOIN "GCUK_2"."schedwin"."QUSAGE" "Quote_Items" ON "Report_Control"."QUSAGEID"="Quote_Items"."QUSAGE_ID") LEFT OUTER JOIN "GCUK_2"."schedwin"."QUOTES" "Quotes" ON
    I have tried setting the Datasource Location, but it doesn't change the query at all. I have read on another forum that you can generate another SQL query using the Database Expert, Current Connections, then right click the Add Command for the database you want to create a SQL command. Is this the only way to update the database names in the query?
    Thanks,
    Scott.

    Hi Sourashree,
    Thanks for that. All the reports were created by the vendor using tables as opposed to the command object. I would have thought that changing the datasource would automatically cause Crystal to rewrite the SQL query syntax, but this doesn't appear to be the case.
    Yes, I've noticed that modifying the record selection will change the sql query. The only way I can see to change the database name in the query is to change to the desired databsource and then remove and re-insert the tables, which will then update the query with the correct name. However, this seems to be a convoluted way of changing the db name in the query.

  • Discoverer Report showing Null VS Show SQL query showing results !!!

    I created a simple Cross Tab Discoverer report from a custom SQL which has a calculation for balances. The output is giving all null values even though there are balances. The output doesn't seem right. So I copied the query from Tools-->Show SQL and ran the query in the TOAD where I'm showing balances for the report. I don't understand why it is not showing in the discoverer. Please help.
    Thanks
    Edited by: PA1B on Jan 27, 2010 11:40 AM

    Sorry for late reply.
    Below is the Show SQL query. I don't think the query is application dependent. C_1 is my calculation.
    SELECT o279709.SEGMENT3 as E279727,
    o279709.SEGMENT4 as E279728,
    CASE WHEN o279709.CURRENCY_CODE = 'USD' AND o279709.TRANSLATED_FLAG <> 'Y' THEN SUM(o279709.ENDING_BAL) ELSE 0 END as C_1,
    GROUPING_ID(o279709.CURRENCY_CODE,o279709.SEGMENT3,o279709.SEGMENT4,o279709.TRANSLATED_FLAG) as GID
    FROM ( --Foriegn Entity USD Balances
    SELECT                B.SEGMENT1,
                                       B.SEGMENT2,     
                                       B.SEGMENT3,
                                  (select distinct substr(cat.COMPILED_VALUE_ATTRIBUTES,5,1) from apps.fnd_flex_values cat
                   where FLEX_VALUE_SET_ID = (select bat.FLEX_VALUE_SET_ID from apps.fnd_id_flex_structures_vl aat, apps.fnd_id_flex_segments_vl bat
                                                                                                                       where bat.id_flex_code = 'GL#' and
                                                                                                                            bat.id_flex_code = aat.id_flex_code and
                                                                                                                            aat.APPLICATION_ID = bat.APPLICATION_ID and
                                                                                                                            aat.APPLICATION_ID = 101 and
                                                                                                                            bat.SEGMENT_NAME = 'Prime Account' and
                                                                                                                            aat.id_flex_num = bat.id_flex_num
                                                                                                                            and bat.id_flex_num in (select distinct chart_of_accounts_id from apps.gl_code_combinations gat
                                                                                                                                                                              where gat.code_combination_id = A.code_combination_id))
                                       and cat.flex_value = b.segment3) ACCT_TYPE ,
                                       B.SEGMENT4,
                                       B.SEGMENT5,
                                       B.SEGMENT6,
                                       B.SEGMENT7,
                                       B.SEGMENT8,
                                       B.SEGMENT9,
                                       B.SEGMENT10,
                                       B.SEGMENT11,
                                       B.SEGMENT12,
                                       B.SEGMENT13,
                                       C.NAME,
    A.SET_OF_BOOKS_ID,
                                       A.CURRENCY_CODE,A.TRANSLATED_FLAG,
                                  SUM(NVL(A.BEGIN_BALANCE_DR,0) - NVL(A.BEGIN_BALANCE_CR,0)) BEG_BAL,
                                  SUM(NVL(A.PERIOD_NET_DR,0)) DEBITS,
    SUM( NVL(A.PERIOD_NET_CR,0)) CREDITS ,
    A.PERIOD_NAME,
                                  SUM(NVL(A.BEGIN_BALANCE_DR,0) - NVL(A.BEGIN_BALANCE_CR,0))+ SUM(NVL(A.PERIOD_NET_DR,0) - NVL(A.PERIOD_NET_CR,0)) ENDING_BAL
    FROM                     APPS.GL_BALANCES A ,
                                       APPS.GL_CODE_COMBINATIONS B,
                                       APPS.GL_SETS_OF_BOOKS     C
    WHERE                     A.CODE_COMBINATION_ID = B.CODE_COMBINATION_ID
    --AND                           A.PERIOD_NAME = 'SEP-09'
    AND                          C.SET_OF_BOOKS_ID = A.SET_OF_BOOKS_ID
    --AND                           A.TRANSLATED_FLAG <> 'Y'
    --AND                           B.SEGMENT1 = '83101'
    --AND                           B.SEGMENT3 = '14602'
    --AND                           A.SET_OF_BOOKS_ID = 77
    --AND                           A.CURRENCY_CODE = 'USD'
    GROUP BY           A.CODE_COMBINATION_ID,
                                  B.SEGMENT1,
                                       B.SEGMENT2,     
                                       B.SEGMENT3,
                                       B.SEGMENT4,
                                       B.SEGMENT5,
                                       B.SEGMENT6,
                                       B.SEGMENT7,
                                       B.SEGMENT8,
                                       B.SEGMENT9,
                                       B.SEGMENT10,
                                       B.SEGMENT11,
                                       B.SEGMENT12,
                                       B.SEGMENT13,          
                                       A.CURRENCY_CODE,
                                       A.TRANSLATED_FLAG,
                                       C.NAME,A.PERIOD_NAME,
    A.SET_OF_BOOKS_ID
    ) o279709
    WHERE (o279709.PERIOD_NAME = 'DEC-09')
    AND (o279709.SET_OF_BOOKS_ID <> 72)
    AND (o279709.SEGMENT12 = '000')
    AND (o279709.SEGMENT3 IN ('10101','10301','10502','12001'))
    AND (o279709.SEGMENT1 IN ('82901','82902','82903','83001','83003','83201'))
    GROUP BY GROUPING SETS(( o279709.CURRENCY_CODE,o279709.SEGMENT3,o279709.SEGMENT4,o279709.TRANSLATED_FLAG ),( o279709.SEGMENT3,o279709.SEGMENT4 ),( o279709.SEGMENT3 ))
    HAVING (GROUP_ID()=0)
    ORDER BY GID DESC;
    Thanks,
    PA1
    Edited by: PA1B on Jan 29, 2010 12:50 PM

  • Error while executing a sql query for select

    HI All,
    ORA-01652: unable to extend temp segment by 128 in tablespace PSTEMP i'm getting this error while i'm executing the sql query for selecting the data.

    I am having 44GB of temp space, while executing the below query my temp space is getting full, Expert please let us know how the issue can be resolved..
    1. I dont want to increase the temp space
    2. I need to tune the query, please provide your recomendations.
    insert /*+APPEND*/ into CST_DSA.HIERARCHY_MISMATCHES
    (REPORT_NUM,REPORT_TYPE,REPORT_DESC,GAP,CARRIED_ITEMS,CARRIED_ITEM_TYPE,NO_OF_ROUTE_OF_CARRIED_ITEM,CARRIED_ITEM_ROUTE_NO,CARRIER_ITEMS,CARRIER_ITEM_TYPE,CARRIED_ITEM_PROTECTION_TYPE,SOURCE_SYSTEM)
    select
    REPORTNUMBER,REPORTTYPE,REPORTDESCRIPTION ,NULL,
    carried_items,carried_item_type,no_of_route_of_carried_item,carried_item_route_no,carrier_items,
    carrier_item_type,carried_item_protection_type,'PACS'
    from
    (select distinct
    c.REPORTNUMBER,c.REPORTTYPE,c.REPORTDESCRIPTION ,NULL,
    a.carried_items,a.carried_item_type,a.no_of_route_of_carried_item,a.carried_item_route_no,a.carrier_items,
    a.carrier_item_type,a.carried_item_protection_type,'PACS'
    from CST_ASIR.HIERARCHY_asir a,CST_DSA.M_PB_CIRCUIT_ROUTING b ,CST_DSA.REPORT_METADATA c
    where a.carrier_item_type in('Connection') and a.carried_item_type in('Service')
    AND a.carrier_items=b.mux
    and c.REPORTNUMBER=(case
    when a.carrier_item_type in ('ServicePackage','Service','Connection') then 10
    else 20
    end)
    and a.carrier_items not in (select carried_items from CST_ASIR.HIERARCHY_asir where carried_item_type in('Connection') ))A
    where not exists
    (select *
    from CST_DSA.HIERARCHY_MISMATCHES B where
    A.REPORTNUMBER=B.REPORT_NUM and
    A.REPORTTYPE=B.REPORT_TYPE and
    A.REPORTDESCRIPTION=B.REPORT_DESC and
    A.CARRIED_ITEMS=B.CARRIED_ITEMS and
    A.CARRIED_ITEM_TYPE=B.CARRIED_ITEM_TYPE and
    A.NO_OF_ROUTE_OF_CARRIED_ITEM=B.NO_OF_ROUTE_OF_CARRIED_ITEM and
    A.CARRIED_ITEM_ROUTE_NO=B.CARRIED_ITEM_ROUTE_NO and
    A.CARRIER_ITEMS=B.CARRIER_ITEMS and
    A.CARRIER_ITEM_TYPE=B.CARRIER_ITEM_TYPE and
    A.CARRIED_ITEM_PROTECTION_TYPE=B.CARRIED_ITEM_PROTECTION_TYPE
    AND B.SOURCE_SYSTEM='PACS'
    Explain Plan
    ==========
    Plan
    INSERT STATEMENT ALL_ROWSCost: 129 Bytes: 1,103 Cardinality: 1                                                        
         20 LOAD AS SELECT CST_DSA.HIERARCHY_MISMATCHES                                                   
              19 PX COORDINATOR                                              
                   18 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002 :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                         
                        17 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                    
                             15 HASH JOIN RIGHT ANTI NA PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,098 Cardinality: 1                               
                                  4 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 63 Bytes: 359,283 Cardinality: 15,621                          
                                       3 PX SEND BROADCAST PARALLEL_TO_PARALLEL SYS.:TQ10001 :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                     
                                            2 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                
                                                 1 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621           
                                  14 NESTED LOOPS ANTI PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 40,256,600 Cardinality: 37,448                          
                                       11 HASH JOIN PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 6,366,160 Cardinality: 37,448                     
                                            8 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1002               
                                                 7 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 1 Bytes: 214 Cardinality: 2           
                                                      6 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 1 Bytes: 214 Cardinality: 2      
                                                           5 INDEX FULL SCAN INDEX CST_DSA.IDX$$_06EF0005 Cost: 1 Bytes: 214 Cardinality: 2
                                            10 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448                
                                                 9 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448           
                                       13 TABLE ACCESS BY INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT CST_DSA.HIERARCHY_MISMATCHES :Q1002Cost: 0 Bytes: 905 Cardinality: 1                     
                                            12 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT SYS.HIERARCHY_MISMATCHES_IDX3 :Q1002Cost: 0 Cardinality: 1                
                             16 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT CST_DSA.IDX$$_06EF0001 :Q1002Cost: 1 Bytes: 5 Cardinality: 1

  • Issue in creation of group in oim database through sql query.

    hi guys,
    i am trying to create a group in oim database through sql query:
    insert into ugp(ugp_key,ugp_name,ugp_create,ugp_update,ugp_createby,ugp_updateby,)values(786,'dbrole','09-jul-12','09-jul-12',1,1);
    it is inserting the group in ugp table but it is not showing in admin console.
    After that i also tried with this query:
    insert into gpp(ugp_key,gpp_ugp_key,gpp_write,gpp_delete,gpp_create,gpp_createby,gpp_update,gpp_updateby)values(786,1,1,1,'09-jul-12',1,'09-jul-12',1);
    After that i tried with this query.but still no use.
    and i also tried to assign a user to the group through query:
    insert into usg(ugp_key,usr_key,usg_priority,usg_create,usg_update,usg_createby,usg_updateby)values(4,81,1,'09-jul-12','09-jul-12',1,1);
    But still the same problem.it is inserting in db.but not listing in admin console.
    thanks,
    hanuman.

    Hanuman Thota wrote:
    hi vladimir,
    i didn't find this 'ugp_seq'.is this a table or column?where is it?
    It is a sequence.
    See here for details on oracle sequences:
    http://www.techonthenet.com/oracle/sequences.php
    Most of the OIM database schema is created with the following script, located in the RCU distribution:
    $RCU_HOME/rcu/integration/oim/sql/xell.sql
    there you'll find plenty of sequence creation directives like:
    create sequence UGP_SEQ
    increment by 1
    start with 1
    cache 20
    to create a sequence, and
    INSERT INTO UGP (UGP_KEY, UGP_NAME, UGP_UPDATEBY, UGP_UPDATE, UGP_CREATEBY, UGP_CREATE,UGP_ROWVER, UGP_DATA_LEVEL, UGP_ROLE_CATEGORY_KEY, UGP_ROLE_OWNER_KEY, UGP_DISPLAY_NAME, UGP_ROLENAME, UGP_DESCRIPTION, UGP_NAMESPACE)
    VALUES (ugp_seq.nextval,'SYSTEM ADMINISTRATORS', sysadmUsrKey , SYSDATE,sysadmUsrKey , SYSDATE, hextoraw('0000000000000000'), 1, roleCategoryKey, sysadmUsrKey, 'SYSTEM ADMINISTRATORS', 'SYSTEM ADMINISTRATORS', 'System Administrator role for OIM', 'Default');
    as a sequence usage example.
    Regards,
    Vladimir

  • Using a SQL Query in an Alert and Matching a String

    I've created an alert in 12.0.4 using a SQL Query and the field that I'm trying to match is a string.  Originally the query returned multiple rows but when the alert still didn't fire, I modified the query WHERE clause to return only one row:
    NAME                                RESPONSE
    Are area lights working?            No
    My expression in the metric is RESPONSE.  In the Monitor I'm matching a string equal to No.  (Do I need double quotes around the matchvalue?  Single quotes?  No quotes?)  The metric is in the 15min scan group, the role is xMII Developers and I'm in that role. The monitor alert string is ' =  '.  Both metric and monitor are active and I've subscribed to the monitor.  Other alerts in the 15min scan group (all based on tag queries) are firing off properly.
    Why is nothing showing up in the Alert Log?
    David Macindoe

    David,
    Did you figure out the answer?  If not, I will try to find someone to address your question.
    Mike

  • Use realational operators in an SQL query??????

    does any one knows how to use realational operators in an SQL query??????
    i wud like to do something like
    select decode(2<3,sysdate,sydate +1) from dual
    but i know decode does not supports relational operators......
    thanx and Regards
    amyt

    You can use a CASE statement which does support relational operators, or if you must use DECODE, then you can use something like:
    SELECT DECODE(SIGN(2 - 3),-1,sysdate,sysdate - 1)
    FROM dual;The SIGN function returns -1 if the expression is < 0, 1 if the expression is > 0 and 0 if the expression is 0. This works for numeric comparisions. You can use the GREATEST or LEAST functions in a similar fashion for character comparisions.
    TTFN
    John

Maybe you are looking for