Value of aggrigate of procedure - Get Oracle on the comparison of two-column based

Hi all
I've written a procedure that accepts an input parameter and returns a refcursor.
The logic used in the procedure is:
The procedure is used to display the summary and the report in detail. When the input parameter has more than one saperated comma then it will act as a synthesis report, and when there is just a value as input, then it will act like a detailed report.
The input parameter is as "AA12345, BB45434, HJ89736," the first two characters is Brand_id and the rest of the 5 character is the propery_id.
The aggrigation of aggrigation query is:
Select Month_name, Year, sum (REVPAR), Sum (ADR) in the FIS_KPI_TREND where
Brand_id = 'AA' and SIte_id = '12345' Month_name group, year;
The above query will worke fine for detail report when there is just a value for the entry as 'AA12345 '.

The problem is coming to the summary report when I need to get the value of aggrigated for all the brand and the site which is entered in the input parameter.
So I changed the query in the form:
Select Month_name, Year, sum (REVPAR), Sum (ADR) in the FIS_KPI_TREND where
Brand_id | SIte_id in ('AA12345', 'BB45434', 'HJ89736') of the Group of Month_name, year;
(I use parser function to parse a comma saperated values.)

By doing this, I get the desired result, but the performance has decrised that the Index is based on Brand_id and Site_id but I'm using Brand_ID | Site_id for my research.

The one you suggest another way to rewrite this query so that it can take the index and not give me the output of sesired.

Database used: Oracle 10 g

Thanks in advance.
Sumit Narayan

Published by: Sumit Narayan, 11 April 2010 22:00

I'd be inclined to do something like that to analyze the list separated by commas, that allows you to join without the concatenation of the columns as you do now.

ME_XE?select
  substr(column_value, 1, 2)            as brand_id,
  substr(column_value, 3, length(column_value))   as site_id
from table(sys.ODCIVARCHAR2LIST('AA12345','BB45434','HJ89736'));
  2    3    4
BRAND_ID   SITE_ID
---------- ----------
AA         12345
BB         45434
HJ         89736

3 rows selected.

Elapsed: 00:00:00.20
ME_XE?

ME_XE?select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE  10.2.0.1.0  Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

5 rows selected.

Elapsed: 00:00:00.39
ME_XE?

So for your case...

Select
  f.Month_name,
  f.Year,
  sum(f.REVPAR),
  Sum(f.ADR)
from FIS_KPI_TREND f, table(sys.ODCIVARCHAR2LIST('AA12345','BB45434','HJ89736')) t
where f.Brand_id = t.brand_id
and   f.SIte_id  = t.site_id
group by f.Month_name, f.Year;

Published by: Tubby 11 April 2010 22:12

Tags: Database

Similar Questions

  • the data of a column based on the value of color.

    Hi guys,.

    I use APEX 4.0.2

    I'm changing the color of the column 'calling_date' so it would be blue when it is equal to sysdate. I typed this code in the Source of the interactive report region.
     case
       when calling_date = sysdate then '<span style="color: #3399FF;">' || to_char(calling_date) || '</span>'
       else to_char(calling_date)
    end CALLING_DATE 
    And then I changed the "display AS text" column 'Standard report Column '.

    But wouldn't change the color!

    Kind regards

    Published by: Fateh June 2, 2011 12:38

    >
    I applied it, but he gave me like a tank I can't order according to date of color.

    case
       when trunc (calling_date,'DD') =  trunc(sysdate,'DD') then
     '' || to_char(calling_date) || ''
       else to_char(calling_date)
    

    If I remove "TO_Char", I get this error:

    incompatible data types: expected DATE got TANK

    Tony Miller, thank you. I followed the instructions on your link, but I got the same error:

    incompatible data types: expected DATE got TANK
    >

    Tyler method uses * columns * 2 in a standard State:

    select
             calling_date
           , case
               when trunc (calling_date,'DD') =  trunc(sysdate,'DD') then '#3399FF'
               else 'inherit'
             end color
    ...
    

    then combined using an HTML Expression:

    #CALLING_DATE#
    

    It is not available in an interactive report (not sure if this information was clearly in the op?)

    In the IR, generate a HTML comment at the cutting edge of the column that supplies the required using the semantics of character sort order:

    select
    ...
           , case
               when trunc(calling_date,'DD') =  trunc(sysdate,'DD')
               then
                 '' || to_char(calling_date) || ''
               else
                 '' || to_char(calling_date) || ''
             end calling_date
    ...
    
  • Requirement of Beeping - how to get subtotals for each combination of 2 columns val

    Hi gurus, Experts and all,.

    Help me please with my reporting requirement, on how to code this in PIF. Thank you.

    Requirement: I need to get the subtotals for each value of the combination of two columns.

    Columns example: team group AMOUNT

    Sample column values: placed Team1 100
    Group b... Team2... 200

    GroupA - Team1 Subtotals = 500 (value of the sample only)
    GroupA - Team2 Subtotals = 400 (value of the sample only)
    Group b - Team1 Subtotals = 600 (value of the sample only)
    Group b - Team2 Subtotals = 200 (value of the sample only)

    GrandTotal = 1700

    Thank you.

    Jean Paul
    BEEP newbie

    Published by: user10955574 on October 28, 2010 05:40
    
     -  - 
    
    

    output for data

    GROUPA - TEAM1 - 200
    GROUPB - TEAM1 - 300
    GROUPC - TEAM2 - 400
    GROUPD - TEAM2 - 500
    GROUPA - TEAM3 - 600
    GROUPB - TEAM3 - 700
    GROUPC - TEAM4 - 800
    GROUPD - TEAM4 - 900
    GROUPA - TEAM5 - 1000
    
  • Comparison of two values Datetime, but only the part of everyone's schedule

    Hello. I have two Datetime objects on my form. Both are formatted and only display the HH:MIPM. I have a validation requirement where I have to check if: TimeA is higher (: TimeB - 30 minutes). What would be the best way to build an IF condition allows to assess both these Datetime variables and determines if the time portion to: TimeA is greater than the time portion of: TimeB - 30 minutes? The part 'date' Datetime value should not be taken into account in the comparison.

    Any help would be greatly appreciated.

    Published by: Buechler on April 13, 2010 10:43

    If you really want to ignore the date and to assess the time, I would like to convert it each date to CHAR formatted as time column and convert it back dated to essentially match the date part. You can then perform a calculation of standard date to get the time difference and check if the difference is more than 30 minutes. For example:

    DECLARE
       TIME_B  DATE := To_Date(To_Char(:DATA_BLOCK.TIME_B,'HH24:MI:SS'),'HH24:MI:SS');
       TIME_A  DATE := To_Date(To_Char(:DATA_BLOCK.TIME_A,'HH24:MI:SS'),'HH24:MI:SS');
    BEGIN
       IF ( ABS(TIME_B  - TIME_A) > .021 ) THEN
          /* If you divide 30/1440 you get the numeric equivilent of 30 minutes. (.021) */
          -- Differnece is greater than 30 minutes!
          -- Do Something Here....
       ELSE
          -- Difference is LESS than 30 minutes!
          -- Do Something here....
       END IF;
    END;
    

    I hope this helps.
    Craig...

  • get data from two columns in a column

    Hello

    I need to display the data in two columns in a column, that I would also like to insert a space between the data in two columns in the output

    can I use something like this?

    (IMPORTER_NAME +' ' + IMPORTER_ADDRESS) as a 'place '.

    Your fence.

    to concatenate in oracle using pipes:

    (IMPORTER_NAME||' '||IMPORTER_ADDRESS) as "Location"
    
  • Execution of the procedure of Oracle APEX

    Hello

    I've written a procedure ' create or replace PROCEDURE process_csvfile (p_filename IN VARCHAR2); " et I want to execute this procedure to Oracle Apex.


    PROCEDURE:

    create or replace PROCEDURE process_csvfile(p_filename IN VARCHAR2)
    AS
    statement1 varchar2(1000);
    statement2 varchar2(1000);
    statement3 varchar2(1000);
    
    begin
    dbms_output.put_Line(p_filename );
    statement1:= 'alter table adb.external_bcc_test location ( '  ||chr(39)|| p_filename||chr(39)|| ')' ;
    dbms_output.put_line(statement1);
    EXECUTE immediate statement1;
    dbms_output.put_line('statement1-> completed');
    EXECUTE immediate 'truncate table ADB.ADB_BCC_TEST';
    dbms_output.put_line('statement2-> completed');
    statement3:='insert /*+ append */ into ADB.ADB_BCC_TEST(BCC_ID,BCC_ADD,"NO_OF_BCC(GEO)") select * from adb.external_BCC_test';
    dbms_output.put_line(statement3);
    EXECUTE immediate statement3;
    dbms_output.put_line('statement3 insert-> completed');
    
    EXCEPTION
    WHEN OTHERS
    then
    raise;
    END;
    
    

    I created the button and the action as a dynamic Action where I wrote below PL/SQ as dynamic Action to perform this procedure


    BEGIN
    
    process_csvfile;
    END;
    
    


    But I get an error" " " ORA-06550: line 4, column 3: PLS-00306: wrong number or types of arguments in the call to 'PROCESS_CSVFILE' ORA-06550: line 4, column 3: PL/SQL: statement ignored (go to error) "

    Oracle Apex Version: 4.2.1

    Thank you

    BO.

    BO123 wrote:

    I've written a procedure ' create or replace PROCEDURE process_csvfile (p_filename IN VARCHAR2); " and I want to run this procedure from Oracle Apex.

    1. create or replace PROCEDURE process_csvfile (p_filename IN VARCHAR2)
    2. AS
    3. statement1 varchar2 (1000);
    4. statement2 varchar2 (1000);
    5. statement3 varchar2 (1000);
    6. Start
    7. dbms_output.put_Line (p_filename);
    8. statement1: = ' change the location of the table adb.external_bcc_test (' |) Chr (39) | p_filename | Chr (39) | ')' ;
    9. dbms_output.put_line (statement1);
    10. EXECUTE immediate statement1;
    11. dbms_output.put_line ('end statement1->');
    12. EXECUTE immediate ' truncate table ADB. ADB_BCC_TEST';
    13. dbms_output.put_line ('end of reporting2->');
    14. statement3: = "insert / * + append * / into ADB." ADB_BCC_TEST (BCC_ID, BCC_ADD, ' NO_OF_BCC (GEO) ') select * from adb.external_BCC_test';
    15. dbms_output.put_line (statement3);
    16. EXECUTE immediate statement3;
    17. dbms_output.put_line ('end statement3 insertion->');
    18. EXCEPTION
    19. WHILE OTHERS
    20. then
    21. lift;
    22. END;

    The treatment is an external table. How to get the source file in the specified location?

    dbms_output.put_linethe instrumentation is unnecessary in an environment of APEX (unless the apex_debug.log_dbms_output method has been called). Use apex_debug API methods instead so that information is available in debug mode.

    There is no reason to use dynamic SQL statements in lines 15-17.

    Creating a column named "NO_OF_BCC (GEO)" is not a good idea and is in conflict with the recommendation of the Oracle do not use identifiers in quotes for the names of database objects. This objects will only cause problems and confusion.

    Lines 20 to 23 are a bug. It doesn't hide where any exception occurred in fact. If there is no specific exception that must be handled in this procedure, it should not contain an exception block.

  • dbAdapter fails during the call to procedure package oracle object type in the parameter out

    JDeveloper 1.1.1.6

    Oracle 11g

    Existing package procedure is defined with the table of objects in input parameters and.

    Package myPackage

    procedure processRecon (numero_projet VARCHAR2,

    INST_ID select NUMBER,

    recon_type VARCHAR2,

    gis_design_stock GMPVT. GMPVT_GIS_DESIGN_STOCK_T,

    stock_uop GMPVT. GMPVT_STOCK_CODES_T,

    x_status OUT VARCHAR2,

    x_escalation OUT VARCHAR2,

    x_recon_error ON GMPVT. GMPVT_GIS_RECON_ERR_T) IS

    GMPVT. GMPVT_GIS_RECON_ERR_T is an array of GMPVT objects. GMPVT_GIS_RECON_ERR, who has 12 fields including the new I added it.

    I have added a new field to the GMPVT object. GMPVT_GIS_DESIGN_STOCK, where GMPVT. GMPVT_GIS_DESIGN_STOCK_T is a table of GMPVT. GMPVT_GIS_DESIGN_STOCK, no problems encountered during the test.

    Next, I added a new field for the object of type GMPVT. GMPVT_GIS_RECON_ERR, the following error below occurs when the DBAdapter is called

    < Summary > Exception occurred when the link was invoked. Exception occurred during invocation of the JCA binding: "JCA binding run operation 'processStockRecon' failed due to the reference: Interaction processing error." Error in the processing of applications from running. GMP_SOA_RECON_PKG. Interaction of the PROCESSRECON API. An error occurred during the processing of the interaction to invoke APPS. GMP_SOA_RECON_PKG. PROCESSRECON API. Cause: java.lang.ArrayIndexOutOfBoundsException: 12 check to make sure that the XML file containing the data of the parameter matches the parameter definition in the XSD. This exception is considered non reproducible, probably due to an error of modeling. ". The called JCA adapter threw an exception of resource. Please review the error message above carefully to determine a resolution. < / Summary >

    I confirmed that the XSD for the stored procedure has in fact change, which has been generated by JDeveloper as I refreshed the database adapter.

    The statement "Cause: java.lang.ArrayIndexOutOfBoundsException: 12" I can't that assume somehow SOA has 12 parameters but the 12 setting was not saved.

    Any thoughts on what I might be missing. I can provide more information if necessary.

    Hello

    This problem has been resolved. Not deployed SOA composite and then deployed to the server of the SOA. For some reason, SOA has been either you see does not changes in the file XSD (cached?) or the XSD was not get updated.

    Thank you

  • Pass the value to an ODI procedure

    Hello
    I need to pass the value of a variable ODI ODI procedure.
    Let me tell you what I did:
    (1) first make an ODI procedure and passing the name of the variable of ODI that I spend in the options of the procedures such as #V_Test.
    (2) now, I did the screenplay for this procedure.
    (3) next I used the scenario of the procedure in other ODI package and also added that the variables I have to spend in the procedures.
    (4) but now when I'm passing the values of the variables in this package, procedures is not accept the values.

    Please suggest.

    Thank you

    Select the scenario, and then go to the Properties tab. You will get an additional variable that you want to pass.
    Provide your value of the variable y

  • Create Procedure in Oracle

    Hello
    I am new to Oracle and the need to create the stored procedure to set the view, than what the user wants - procedure, that they need "to spend a bunch of settings", as of the day etc. I don't know does make sence for that in sp, set rather seen as you like, and probably that there is still possibility to pass all params in there without creating procedure. And it's just advice, not materialized.

    I'm not "see an option to apply the settings in the menu 'New View' on my SQL_Developer." So MS will probably be the best solution?

    My opinion:

    Create view v1 in select * from tt1 where union date=@today
    Select * from tt2 where date=@today union;

    Maybe someone can share any sample sp how to create the procedure, I can not compile without error:
    CREATE OR REPLACE PROCEDURE usp_v1 AS
    BEGIN
    Create view v1 in select * from tt1 where union date=@today
    Select * from tt2 where date=@today union;
    END usp_v1;
    Error (4.3): PLS-00103: encountered the symbol "CREATE" when waiting for one of the following values: begin case declare exit for goto rise back loop mod null pragma select update while < ID > < one between double quote delimited identifiers of > < a variable binding > < < close current delete fetch locking open insert commit rollback savepoint SQLExecute fusion forall hose set

    Also, what is the best book of the Oracle for beginner developer market? I couldn't find too much on www.


    All TX

    D

    RUN IMMEDIATELY CREATE VIEW...

  • can I export and import my database to oracle via the stored procedure?

    Hi all

    I need to export my database using the stored procedure, the stored procedure is called by the java application and it works well
    Now I still get the "ULTIMATE QUESTION", could export and import the database using the stored procedure?

    Really thanks for the reply.

    Kind regards

    Kahlil

    Hello

    I think you can use DBMS_DATAPUMP (10.1 +), see [DBMS_DATAPUMP | http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_datpmp.htm#i1007277], for examples, see [http://www.psoug.org/reference/dbms_datapump.html]

    Kind regards

  • Where does FireFox get the default value for a preference of. What is the format of the file that contains the default value?

    Where does FireFox get the default value for a preference of. What is the format of the file that contains the default value? I need the actual default value for an individual preference.
    Topic: config shows some default values, but I need the source from which everything: config returns to the default value.
    Any help in this direction is greatly appreciated.

    User Agent

    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x 64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)

    The preferences that are not hidden if they have by default are stored in two JavaScript text files in the Firefox program folder
    You can open them in a tab in Firefox through these links:
    resource:///defaults/pref/firefox.js
    resource:///greprefs/all.js

    (702598/forum/1/702598)

  • Failed to get information on the license ORACLE 'Support identifier'

    Untitled1.jpgUntitled.jpg



    I can not get the ORACLE "Support id" license information : CSI 20061868

    I tried to register this CSI number on the My Oracle Support (https://support.oracle.com) Web page, but it shows error: cannot add support identifier. Support identifier 20061868 is not valid or does not allow recording. To reference the snap attached (CSINUMBER.jpg and CSINUMBER1.jpg)


    How I can get the conditions terms and conditions, level of support, support period etc. between our company and Oracle on the CSI 20061868

    Cecile

    Hello

    This is not the place to ask.

    You must contact your Oracle representative or agent to see what it takes to turn that CSI.

    Kind regards

    Bashar

  • Get and set the value to allow selected rolling Shuffle and facing page

    Hello world

    I work with the page and spread,

    For now, I want to value page spead shuffle and type of document.

    but I just find the function to get and set the value for the Document Pages allow Shuffle using the

    InterfacePtr < IPageLayoutPrefs > iPageLayoutPrefs (static_cast < IPageLayoutPrefs * > (: QueryPreferences (IID_IPAGELAYOUTPREFERENCES, iDocument)))

    It has no function to set and get the value of enable selected rolling Shuffle and facing page

    No one knows about it?

    I thank in advance

    There is no code for this example in the SDK or internet. Just understand and apply the concept.

    Find the code for the shuffle spread and together following spread shuffle...

    // Get active spread
    UIDRef GetActiveSpread() {
        UIDRef spreadRef = UIDRef::gNull;
    
        InterfacePtr layoutData(Utils()->QueryFrontLayoutData());
        if(layoutData) {
      spreadRef = layoutData->GetSpreadRef();
      }
    
      return spreadRef;
    }
    
    // Get spread shuffle of passed in spread
    bool16 GetSpreadShuffle(UIDRef& spreadRef) {
        InterfacePtr spread(spreadRef, UseDefaultIID());
        if(!spread)
      return kFalse;
    
      InterfacePtr iBoolData(spread, IID_IISLANDSPREAD);
        if(iBoolData) {
            return iBoolData->GetBool();
        }
    
        return kFalse;
    }
    
    // Set spread shuffle of passed in spread
    // @param bValue: kTrue = no shuffle, kFalse = allow shuffle
    ErrorCode SetSpreadShuffle(UIDRef spreadRef, bool16 bValue) {
        ErrorCode status = kFailure;
    
        InterfacePtr spreadCmd(CmdUtils::CreateCommand(kSetIslandSpreadCmdBoss));
        if(!spreadCmd)
            return status;
    
        spreadCmd->SetItemList(UIDList(spreadRef));
    
        InterfacePtr iBoolData(spreadCmd, UseDefaultIID());
        if(iBoolData) {
            iBoolData->Set(bValue);
        }
    
        status = CmdUtils::ProcessCommand(spreadCmd);
        return status;
    }
    
  • Is it possible a 0 is displayed after the decimal point when the value is rounded? (I get: 20-20, 1;) "I need 20, 0-20, 1).

    Using the effect of text "cursor", I am able to view replace "30 ° C" "35.5 ° C". My question is: is it possible a 0 is displayed after the decimal point when the value is rounded? (I get: 20-20, 1;) "I need 20, 0-20, 1). I use this code:

    Temp = effect ("Slider Control") ("Slider");

    sliderValue = Math.round(temp*10)/10;

    [sliderValue + ' ° C ' "']

    Here is the solution:

    numDecimals = 1;

    Temp = effect ("Slider Control") ("Slider");

    sliderValue = (Math.round(temp*10)/10).toFixed(numDecimals);

    sliderValue + "° C";

  • Starting from two data tables, how do you get the values in two columns using values in a column (values get col. If col. A is not null values and get the pass. B if col. A is null)?

    Two tables provided, how you retrieve the values in two columns using values in a column (the pass get values. If col. A is not null values and get the pass. B if col. A is null)?

    Guessing

    Select nvl (x.col_a, y.col_b) the_column

    from table_1 x,.

    table_2 y

    where x.pk = y.pk

    Concerning

    Etbin

Maybe you are looking for

  • Unable to pair re Apple Watch 1st gen

    Hi guys,. I have a first gen 38 mm Apple Watch alu and 6s with 9.3.1 iPhone. Until now they work very well together, but Sunday I reset the watch and since then one can not re pairit with the phone. Once I chose the language on the watch, it gives me

  • HP Officejet 7310xi all in one: printer keeps repeating transport jam

    My printer do not print and indicates a carriage jam and told me to open the door and a cart clear jam but there is nothing there, and there is no paper jam. I tried to unplug the machine, its restart, restrting my MAC and the message still flashes.

  • Read the string between two characters

    I have an xml file that is saved to a text file, and the XML was not in Labview. I want to be able to read each line of the text file and display the text that is between ' > '. I'll leave the text as an attachment file.

  • Firefox IOS contains 6 connected devices when none are connected

    When you try to synchronize Firefox in IOS I get 'Not Sync not available'. When I press the "Clock", under "Synchronized devices" icon it said "6 device (s)". I only have my laptop and Ipad which I am trying to sync? Why Firefox IOS think I have 6 de

  • Windows Mail doesn't load/connect. Tried troubleshooting, but nothing works.

    My windows email account does not, connect even though I have access to the internet.   I have reset the router/modem, but don't know enough to do much else.  This is the error message I get: The connection to the server has failed. Account: 'windows