Query return data on  prioritize basis

Hi All
I have the following tables:
Create Table
CREATE TABLE PARENT_MST ( PARENT_LINE_TYPE VARCHAR2(30),
DETAIL_LINE_TYPE VARCHAR2(30));
CREATE TABLE MASTER_DTL ( DETAIL_ID NUMBER(5),
DETAIL_LINE_TYPE VARCHAR2(30));
Insert in Table
INSERT INTO PARENT_MST
(PARENT_LINE_TYPE,DETAIL_LINE_TYPE)
VALUES
('HEALTH','EH');
INSERT INTO PARENT_MST (PARENT_LINE_TYPE ,DETAIL_LINE_TYPE)
VALUES
('HEALTH','DRG');
INSERT INTO PARENT_MST (PARENT_LINE_TYPE,DETAIL_LINE_TYPE)
VALUES
('HEALTH', 'HOSE');
INSERT INTO PARENT_MST (PARENT_LINE_TYPE, DETAIL_LINE_TYPE)
VALUES
('HEALTH','VIS');
INSERT INTO MASTER_DTL
(DETAIL_ID,DETAIL_LINE_TYPE)
VALUES
(1,'HEALTH');
INSERT INTO MASTER_DTL
(DETAIL_ID,DETAIL_LINE_TYPE)
VALUES
(2,'DRG');
My requirement is that I have such kind of query in which system first check the DETAIL_LINE_TYPE in table MASTER_DTL and if that specific DETAIL_LINE_TYPE is exist then return it and if not exist in table MASTER_DTL then go to PARENT_MST and check with PARENT_MST.DETAIL_LINE_TYPE and if match then return its PARENT_LINE_TYPE but cannot repeat PARENT_LINE_TYPE .
For example:
in case for 'EH' system return 'HEALTH' because 'EH' is not exist in MASTER_DTL.DETAIL_LINE_TYPE.
in case 'DRG' system return DRG because DRG is exist in MASTER_DTL table
in case 'HOSE' system does not return 'HEALTH' because HEALTH already exist so query does not return any thing
in case 'VIS' system does not return 'HEALTH' because HEALTH already exist so query does not return any thing
My desire output is something like this:
DRG
HEALTH---------
I have the following query in my package and want to use the same query with some modification in my package. Is there any possibility that we can write desired code after column name like this:
select DETAIL_LINE_TYPE  (  some code here as per requirement   )
from MASTER_DTL
where DETAIL_LINE_TYPE
  in
  ('EH',
  'DRG',
  'HOSE',
  'VIS'
Existing Query
select DETAIL_LINE_TYPE
from MASTER_DTL
where DETAIL_LINE_TYPE
in
('EH',
'DRG',
'HOSE',
'VIS'
);

Thanks for the replies and accept my apology for not clarification things. Let me try to clear it in more detail.
I already have one query in my package that is below :
Query
select DETAIL_LINE_TYPE from MASTER_DTL
where DETAIL_LINE_TYPE
in
('EH',
'DRG',
'HOSE',
'VIS'
My requirement is that system first check the values in field MASTER_DTL.DETAIL_LINE_TYPE
by using the provided list that is ('EH', 'DRG', 'HOSE', 'VIS' ) and if value not find in table MASTER_DTL.DETAIL_LINE_TYPE then system check that value in other table that is PARENT_MST.DETAIL_LINE_TYPE and if system find the value then instead of returning PARENT_MST.DETAIL_LINE_TYPE value, system return corresponding PARENT_LINE_TYPE value but if the PARENT_LINE_TYPE already return then system does not return anything.
For example:
I have to process 4 DETAIL_LINE_TYPE ('EH', 'DRG', 'HOSE', 'VIS' ) .
First system try to search 'EH' in table MASTER_DTL.DETAIL_LINE_TYPE and if not found then try to search it in table PARENT_MST.DETAIL_LINE_TYPE and if found then return its corresponding PARENT_MST.PARENT_LINE_TYPE.
Same steps involved in 'HOSE', 'VIS' but in case of 'DRG' the query found DRG in table MASTER_DTL.DETAIL_LINE_TYPE and no need to check the value in PARENT_MST table. I think if I use distinct then I will not get duplicate records so for the time being ignore checking of duplication.
Please let me know if you have any question.
Regards
Shumail

Similar Messages

  • 'Driver]Parameter missing' Error while trying to pass parameter to MS query & Return Data to Microsoft Excel

    I am trying to set up a parameter query using ODBC-Microsoft Query
    to BMC Remedy The ODBC connection is "AR System ODBC Data Source".
    I want to pass a parameter to modified date field and get all the remedy tickets for which the modified date is<= to the passed parameter date.
    So in MS query, SQL- 
    the query looks like
     WHERE ("Trouble Ticket"."Create Date">={ts '2014-10-01 00:00:00'}) AND ("Trouble Ticket"."Modified-date"<=?)
    I am getting the data fetched from database in the MS query window, but unfortunately
    When I click File-Return Data to Microsoft Excel, its showing an error: Driver]Parameter missing
    I set the connection properties- parameter-Prompt for value using the following string.
    Please help

    Hi,
    Based on the error message, I recommend we try the suggestion: Replace all "..."  with [...]
    http://www.pcreview.co.uk/forums/error-parameter-query-odbc-remedy-bmc-software-com-t3232964.html
    Then, if you want to connect the Remedy's oracle database, please see the thread:
    http://www.tek-tips.com/viewthread.cfm?qid=1123112
    We may try the workaround: Write an Excel macro which connects to the database and fetch the data based on the SQL query.
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    If you have further question about write macro, I recommend you post the question to the MSDN forum for Excel
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Query returns data from previous month. Need to have it return data for the entire year

    This is the part of the query that returns data by month:
    (YEAR(`rereport`.`market_reports_5`.start_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)AND MONTH(`rereport`.`market_reports_5`.start_date) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH))
    How can I get it to return data for the year.
    TIY

    How about omitting the MONTH part:
    (YEAR(`rereport`.`market_reports_5`.start_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Why Doesn't Query Return Date Values On Eval Table?

    Using Oracle 11.2.0.1 with XMLType Secure File Table named Eval.
    An interesting situation is occurring when attempting to query. A couple of things are going on.
    These queries do not have registered schemas.
    1. This query works fine
    SELECT xmlcast(xmlquery('declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";
    declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03";
    $p/eval/derivedFacts/ns7:derivedFact/ns7:defId' passing e.object_value AS "p" RETURNING CONTENT)
    AS varchar2(100)) "Definition ID"
    FROM eval e;When adding a condition in the query to get defId=52657, get all nulls - even though this record exists - see sample data below.
    SELECT xmlcast(xmlquery('declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";
    declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03";
    $p/eval/derivedFacts/ns7:derivedFact[/ns7:defId=888]/ns7:defId' passing e.object_value AS "p" RETURNING CONTENT)
    AS varchar2(100)) "Definition ID"
    FROM eval e;
    <?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?><eval createdById="1957" acmeMemberId="3df55bd8-b3a6-4ba3-85e7-e8a188b7b4ed" category="external" eval_dt="2012-02-11T23:45:10.266Z" evalId="876d4035-aaf9-4f09-ae40-43498ec4973b" xmlns="http://www.cigna.com/acme/domains/eval/2010/03" xmlns:ns2="http://www.cigna.com/acme/domains/derived/fact/2010/03" xmlns:ns3="http://www.cigna.com/acme/domains/common/2010/03">
       <derivedFacts>
          <ns2:derivedFact>
             <ns2:defId>52657</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52657:1</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52600</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52600:2</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>null</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52599</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52599:1</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>INT</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>51400</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51400:1</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>integer</ns2:type>
                <ns2:value>34</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52177</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52177:3</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>null</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52075</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52075:1</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>M</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>51391</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51391:1</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>51473</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51473:1</ns2:defUrn>
             <ns2:factSource>CCDR Product</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>date</ns2:type>
                <ns2:value>2011-01-01</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>51474</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51474:1</ns2:defUrn>
             <ns2:factSource>CCDR Product</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>date</ns2:type>
                <ns2:value>9999-12-31</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52151</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52151:3</ns2:defUrn>
             <ns2:factSource>CCDR Product</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>51048</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51048:5</ns2:defUrn>
             <ns2:factSource>CCDR ProfileFact</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>60380</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:60380:1</ns2:defUrn>
             <ns2:factSource>CCDR ProfileFact</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
       </derivedFacts>
    </eval>Seem to be missing something conceptually, as to why this is not working.
    2. When replacing defId with origInferred_dt and adjust for the datatype; the query returns all nulls
    SELECT xmlcast(xmlquery('declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";
    declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03";
    $p/eval/derivedFacts/ns7:derivedFact/ns7:origInferred_dt' passing e.object_value AS "p" RETURNING CONTENT)
    AS TIMESTAMP WITH TIME ZONE) "Original Inferred Date"
    FROM croutreach.eval e;Same here, seem to be missing something conceptually...
    Ultimately hoping to get this query to correctly work:
    SELECT xmlcast(xmlquery('declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";
    declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03";
    $p/eval/derivedFacts/ns7:derivedFact[/ns7:defId=52657]/ns7:origInferred_dt' passing e.object_value AS "p" RETURNING CONTENT)
    AS TIMESTAMP WITH TIME ZONE) "Original Inferred Date"
    FROM croutreach.eval e;Any assistance would be much appreciated to say the least! :)
    Regards,
    Rick Blanchard

    Hi Rick,
    Ultimately hoping to get this query to correctly work:
    SELECT xmlcast(xmlquery('declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";
    declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03";
    $p/eval/derivedFacts/ns7:derivedFact[/ns7:defId=52657]/ns7:origInferred_dt' passing e.object_value AS "p" RETURNING CONTENT)
    AS TIMESTAMP WITH TIME ZONE) "Original Inferred Date"
    FROM croutreach.eval e;
    Remove the initial slash in the predicate [ns7:defId=...] :
    xmlcast(
      xmlquery(
        'declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03"; (::)
         declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03"; (::)
         $p/eval/derivedFacts/ns7:derivedFact[ns7:defId=52657]/ns7:origInferred_dt'
         passing e.object_value AS "p"
         RETURNING CONTENT
      AS TIMESTAMP WITH TIME ZONE
    ) "Original Inferred Date"

  • SQL query returning data inconsitantly

    I am running Oracle 8i and have create a stored procedure that has a cursor in it. The select statement for the cursor returns 15 records that I loop through and insert into another table. At the beginning of the loop, just before the insert statement, I have also created DBMS output that will return the time stamp. This more or less tells me how long each loop takes to complete. The loop processes 14 of the 15 records in less than a minute. The last loop takes over two hours to complete. I have also tried running this stored proc in another environment. In that environment the cursor should process 3555 records. It processes 2650 in five minutes or less. It then takes about 115 minutes to process the last 905. Does anyone have any ideas as to why this may be occurring? Could there be a bottleneck somewhere? What DB/table settings can I look at? Thanks in advance for you ideas.

    Please check the query plan in this environment and that environment also(It processes 2650 in five minutes or less)

  • Report Queries & Layouts, PDF, only first query returns data

    Hi all,
    When I use Standard report printing from APEX 3.1 and a Report Layout and Report Queries (more than one report query), I only get output from the first query in PDF format. If I use XML format I get output from all queries. Does APEX 3.1 allow the use of multiple report queries when printing in Standard mode to PDF?
    Thanks,
    Mike

    Mike,
    Do you have other report queries where you get more than one result set? Or do you face this issue in all cases? One scenario where you could potentially run into this kind of a situation could be if you selected "Include application and session information" when creating the report query, created your layout based on the resulting XML structure and then later, including application and session information was de-selected, resulting into a simpler XML structure.
    Regards,
    Marc

  • Query referencing session state not consistently returning data

    Hi,
    I have a form that summarizes expense data by category for employees, per fiscal year, fiscal period, and project.
    Clicking on a button next to a particular category takes the user to a new page that should display the detail of those expenses, based on expense_code.
    The expense_code is passed via URL to the second page, and the query region for the detail has the following source:
    select exp_code, JRNL_ID_NO, DESCRIPTION, REFERENCE, CUR_PER_TRAN, CUM_YTD
    from fgspec_ac where exp_code between :P118_EXPENSE_CODE_FROM and :P118_EXPENSE_CODE_TO and project=:P114_PROJECT and fis_year=:P114_FIS_YEAR and fis_period=:P114_FIS_PERIOD
    :P118_EXPENSE_CODE_FROM and :P118_EXPENSE_CODE_TO are passed via URL, and the :P114_% fields reference data on the initial form.
    The problem is that when I click on the button to bring up the detail for the first time, the query returns no rows. If I return to the original form and click on the button a second time, the query the displays the required data. This behavior is consistent, regardless of expense category, fiscal period, etc. The first time I try to access detail, no records returned, but the second time, it works.
    I have used the 'SESSION' link to debug and view the session state in each case, and the results are IDENTICAL whether the query returns data or not. That is, all 5 variables contain the exact same data.
    Do you know what I might be doing wrong?
    Thanks,
    Michelle

    Hi guys,
    Thanks very much for your replies. In fact, I have tried both methods. Yes, I am navigating from page 114 to 118, and passing values to page 118 from page 114 (ie: P114_PROJECT passes to P118_PROJECT, etc...). In my query, I have tried referencing both, with the same results.
    When checking values in session state (by using the 'SESSION' link), values from page 114 are available in both cases (when the query returns rows and when it does not). It is very strange behavior.
    I have been developing with HTMLDB for over a year now, and never seen anything like it!!! I will try loading this on HTMLDB.oracle.com, and see if it replicates, and if so, maybe you can have a look...............
    Thanks!
    Michelle

  • InfoSet Query no data returned

    Hi,
    I've created InfoSet Query and Query respectively for the same InfoSet. However, only Query returns data and the InfoSet Query returns no data.
    Best regards,
    ts

    Hi Venkat,
    This is BW forum and never post/include your issue in other threads.
    if your facing problem about plant data then please post your issue at SAP MM forum.
    MM forum link can find below link.
    SCN Site Index 
    How to create a discussion:
    http://scn.sap.com/docs/DOC-46003
    Thanks

  • SQL statement doesn't return data

    Hi,
    Please I am facing a problem where I took the sql statement from an oracle report and I'm applying it on TOAD 9.0 but it is not returning any data. The thing is that on the application the report returns data but as I checked on the TOAD it showed that some tables have no data.
    How is this possible??
    Do I need to apply some code before I apply my select statement??
    Hope you can help here,
    Thanks in Advance,
    Ashraf

    Hi Ashraf,
    As it should be if a Query in Report is returning data so should the same query return data if used either in Toad or SQL Plus.
    In your report do check if you have any parameters and do this parameters have any default values and are you using the same parameters.
    Also do check the source of the Report which the application is executing and the one from where you are using the Query is same.
    Best Regards
    Arif Khadas

  • Query is returning data very slowly

    Hi,
    Please advise for the solution. Thanks in advance.
    The problem is that the queries returning data very very slow.
    Let me explain further, There is one major table that is storing master data (Main Transaction) and its detail data (Child Records) and further detail of the detail data (Child Records of the Child Records) and so on sometimes upto 5 or 6 levels in the same ONE big table called "TRANSACTIONS_TABLE" table.
    Therefore, mostly my quries are self joins like
    SELECT /*+ FIRST_ROWS(10) */ JUDG.ID JUDG_ID,
    SE.ID SE_ID,
    CS.ID CS_ID,
    CS.CS_DATE,
    CS.CS_J_ID,
    CS.CT_ID,
    C.ID C_ID,
    C.TRANSACTIOIN_TYPE_ID C_TRANSACTIOIN_TYPE_ID,
    C.TRANSACTIOIN_NO,
    C.TRANSACTIOIN_YEAR,
    C.TRANSACTIOIN_DATE,
    C.SUBJECT,
    C.UNIT_ID,
    (SELECT U.NAME_N FROM ORG U WHERE U.ID = C.UNIT_ID) PRC_UNIT_DESC,
    C.E4 NO_AL_QAZYA_ID,
    SELECT T.DESCRIPTION
    FROM prc_charge_categories T
    WHERE T.ID = TO_NUMBER(C.E4)
    ) NO_AL_QAZYA,
    C.CREATED_BY
    FROM TRANSACTIOINSACTION_TABLE C,TRANSACTIOINSACTION_TABLE SE, TRANSACTIOINSACTION_TABLE JUDG, DEF_TABLE CS
    WHERE C.ID = SE.PARENT_ID
    AND SE.ID = J.PARENT_ID
    AND SE.TRANSACTIOIN_TYPE_ID = 63755
    AND J.TRANSACTIOIN_TYPE_ID = 63424
    AND J.E1 = '3'
    AND CS.ID = TO_NUMBER(SE.E9);
    23 rows selected in 48.672 seconds
    I run the below query on this table
    select transaction_type_id,count(*) total_rows
    from transactions_table
    group by transaction_type_id
    order by 2 desc;
    transact total_rows
    114893     1192544
    63755     774132
    62270     682361
    63424     633046
    65220     515605
    67728     457831
    84928     378754
    58806     296351
    64240     277624
    65244     275267
    67224     152061
    112610     123796
    67434     116100
    65824     88787
    61369     76196
    62269     74821
    61740     67085
    56448     56185
    65703     55336
    99601     54552
    64423     49368
    61478     43187
    101689     39372
    61652     38196
    67136     27713
    61364     25790
    97961     23610
    65380     19811
    56353     18910
    65618     18309
    57041     16808
    98137     15837
    101794     14618
    100127     14118
    98916     13691
    112735     13082
    117349     11930
    69334     11462
    99064     10291
    67811     10151
    69402     9142
    112753     8243
    95950     7390
    68902     6900
    119474     6693
    65659     5972
    68360     5862
    66198     5690
    118340     5161
    62012     4490
    71088     4050
    112040     3864
    57315     3047
    112031     2957
    57289     2891
    112039     2523
    112038     2446
    114254     2269
    55550     2242
    119926     2225
    69650     2135
    65033     1343
    119078     811
    69788     780
    115133     774
    116390     578
    114968     549
    65575     521
    64290     412
    120026     403
    67388     359
    116340     249
    66847     228
    98524     144
    68214     138
    120459     105
    118777     92
    79395     87
    116039     79
    65768     67
    118376     58
    120906     57
    55848     52
    58983     50
    61195     48
    68134     29
    66645     24
    55992     23
    69037     21
    70379     21
    56674     20
    112019     20
    68911     18
    70206     17
    66028     16
    114335     11
    69555     7
    55849     6
    57122     6
    65034     5
    60496     5
    57273     4
    56286     4
    55563     4
    56972     3
    55542     3
    70654     3
    55999     3
    56721     3
    57138     2
    117802     2
    57005     2
    61058     2
    116351     2
    57096     2
    57075     2
    95136     1
    115210     1
    117601     1
    68298     1
    56939     1
    65935     1
    61739     1
    65611     1
    71249     1
    57010     1
    95024     1
    68406     1
    57097     1
    122206     1
    57062     1
    132 rows selected in 5.266 seconds
    Immediately, I again run this same query
    132 rows selected in 5.079 seconds
    then again
    132 rows selected in 2.672 seconds
    then again
    132 rows selected in 4.438 seconds
    then again
    132 rows selected in 2.684 seconds
    The structure of this table is
    CREATE TABLE transactions_table
    ID NUMBER NOT NULL,
    PARENT_ID NUMBER,
    TRANSACTION_TYPE_ID NUMBER NOT NULL,
    TRANSACTION_YEAR NUMBER(4),
    TRANSACTION_NO NUMBER(8),
    TRANSACTION_DATE DATE NOT NULL,
    C1 VARCHAR2(255 BYTE),
    C2 VARCHAR2(255 BYTE),
    C3 VARCHAR2(255 BYTE),
    LONG_C1 VARCHAR2(4000 BYTE),
    LONG_C2 VARCHAR2(4000 BYTE),
    LONG_C3 VARCHAR2(4000 BYTE)
    TABLESPACE TS16K_DATA
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 3144M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;
    CREATE UNIQUE INDEX MOJ.EVN_PK_I ON transactions_table
    (ID)
    NOLOGGING
    TABLESPACE TS16K_INDX
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 168M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    NOPARALLEL;
    CREATE INDEX EVN_EVN_TYP_I ON transactions_table
    (TRANSACTION_TYPE_ID)
    NOLOGGING
    TABLESPACE TS16K_INDX
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 136M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    NOPARALLEL;
    There are 150 COLUMNS in this table and out of which there are 33 columns data type is VARCHAR2(4000 BYTE) and others NUMBER datatype and some are VARCHAR2(255 BYTE)
    As from above, the index on TRANSACTION_TYPE_ID is not unique and not bit map but a normal index.
    Further there are no partitions for this table.
    Many of the database views based on this table return results after several minutes.
    * Around 5000 to 8000 rows are entered in this table on daily basis and is it feasible to create partitions and modify indexes to bit map and vice versa where ever required because already this table is having 54 Indexes including composite ones.
    Please help and advise.

    When your query takes too long ...
    HOW TO: Post a SQL statement tuning request - template posting

  • Query in ASWE XML code doesn't return data

    Hello, since people on the Oracle Metalink site are to lazy to give an answer to this question. I'll try it via this forum. Here we go:
    I'm developing wireless applications running on Oracle9i Application Server Wireless Edition. I'v tried to implement the employee sample from Oracle Online Mobile Studio (studio.oraclemobile.com). The sample name is employee.jsp. This sample combines XML code with JSP.
    (code at the end of the text)
    When I test the sample I get no query results.
    When you take the first option for example, (search by dept number) the query result will not be displayed. I think it has something to do with the "executeQuery" line.
    rset = stmt.executeQuery("select * from EMP where EMPNO='" + empNum + "'");
    After giving the following input (employeenumber) 7369 (which excists in the
    database). I get the following errors:
    The panama server log returns the following error:
    1/14/02 5:19:28 PM NOTIFY : [Thread-13]
    core.XSLTransformerImpl.getXSLProc(XSLTransformerImpl.java:120)
    Create 10 number of XSL-processor for TINY_HTML
    1/14/02 5:19:35 PM NOTIFY : [Thread-15]
    adapter.URLAdapter.invoke(URLAdapter.java:240)
    URL = http://host/portal/test/employee.jsp
    1/14/02 5:19:37 PM NOTIFY : [Thread-17] adapter.URLAdapter.invoke(URLAdapter.java:240)
    URL =http://host/portal/test/employee.jsp?choice=empNum
    1/14/02 5:19:49 PM NOTIFY : [Thread-19]adapter.URLAdapter.invoke(URLAdapter.java:240)
    URL =http://host/portal/test/employee.jsp?&empNum=7369
    1/14/02 5:19:50 PM ERROR : [Thread-19]rt.common.Controller.reportServiceInvocationError(Controller.java:707)
    Service Invocation Error: Stream closed.
    The jserv.log returns the following error:
    [14/01/2002 17:19:50:431 CET] Invalid column name
    java.sql.SQLException: Invalid column name
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
    at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:4383)
    at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:667)
    at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1374)
    at portal.test._employee._jspService(_employee.java:201)
    at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java)
    at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java)
    at oracle.jsp.JspServlet.doDispatch(JspServlet.java)
    at oracle.jsp.JspServlet.internalService(JspServlet.java)
    at oracle.jsp.JspServlet.service(JspServlet.java)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
    at org.apache.jserv.JServConnection.processRequest(JServConnection.java:402)
    at org.apache.jserv.JServConnection.run(JServConnection.java:260)
    at java.lang.Thread.run(Thread.java:479)
    Does this have something to do with the encoding of the query result in the select statement? As you can see the variable is in the requeststring (URL = http://host/portal/test/employee.jsp?&empNum=7369)
    My database connection works fine (I've also tested the query using SQL plus and the SQL adapter also works).
    Is this the right statement?: ("select * from EMP where EMPNO='" + empNum + "'");
    I can not do anything with the error in the jserv.log (java.sql.SQLException: Invalid column name).
    The columnname EMPNO excists in the example table. The query in SQL plus gives a result.
    Can someone give my any suggestions?
    Thanks in advance.
    Thomas Wesseling, UCC
    ### Code of employee.jsp ###
    <?xml version="1.0" encoding="UTF-8"?>
    <SimpleResult>
    <SimpleContainer>
    <%@ page language="java" import="java.sql.*, java.util.*, java.text.* "%>
    <%
    //URL variables
    String choice = request.getParameter("choice");
    String empNum = request.getParameter("empNum");
    String lastName = request.getParameter("lastName");
    String jobTitle = request.getParameter("jobTitle");
    String deptNum = request.getParameter("deptNum");
    String notFoundMsg = null; //String for containing varying not found msg
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@172.16.0.51:1521:ora816", "scott", "tiger");
    Statement stmt = conn.createStatement();
    ResultSet rset = null;
    //**** Start of service - first card ****
    if (choice==null && empNum==null && lastName==null &&
    jobTitle==null && deptNum==null)
    %>
    <SimpleMenu title="Employee Search by:">
    <SimpleMenuItem target="employee.jsp?choice=empNum">Employee Number</SimpleMenuItem>
    <SimpleMenuItem target="employee.jsp?choice=lastName">Name</SimpleMenuItem>
    <SimpleMenuItem target="employee.jsp?choice=jobTitle">Job Title</SimpleMenuItem>
    <SimpleMenuItem target="employee.jsp?choice=deptNum">Dept Number</SimpleMenuItem>
    </SimpleMenu>
    <%
    //**** SECOND CARD - which search criteria ****
    if (choice!=null)
    if (choice.equals("empNum") && empNum == null)
    %>
    <!-- show search by employee number -->
    <SimpleForm target="employee.jsp?">
    <SimpleFormItem name="empNum" format="*N">Enter Employee Number: </SimpleFormItem>
    </SimpleForm>
    <%
    else if (choice.equals("lastName") && lastName == null)
    %>
    <!-- show search by last name -->
    <SimpleForm target="employee.jsp?">
    <SimpleFormItem name="lastName" format="*A">Enter Last Name: </SimpleFormItem>
    </SimpleForm>
    <%
    else if (choice.equals("jobTitle") && jobTitle == null)
    %>
    <!-- show search by job title -->
    <SimpleForm target="employee.jsp?">
    <SimpleFormSelect name="jobTitle" title="Enter Job Title:">
    <SimpleFormOption value="CLERK">Clerk</SimpleFormOption>
    <SimpleFormOption value="SALESMAN">Salesman</SimpleFormOption>
    <SimpleFormOption value="MANAGER">Manager</SimpleFormOption>
    <SimpleFormOption value="ANALYST">Analyst</SimpleFormOption>
    <SimpleFormOption value="PRESIDENT">President</SimpleFormOption>
    </SimpleFormSelect>
    </SimpleForm>
    <%
    else if (choice.equals("deptNum") && deptNum == null)
    %>
    <!-- show search by dept number -->
    <SimpleForm target="employee.jsp?">
    <SimpleFormItem name="deptNum" format="*N">Enter Dept Number: </SimpleFormItem>
    </SimpleForm>
    <%
    //**** THIRD CARD - query DB based on criteria ****
    //**** empNum entered as search criteria ****
    if (empNum != null) //empNum is entered as search criteria- NEED TO TEST FOR NON-int
    rset = stmt.executeQuery("select * from EMP where EMPNO='" + empNum + "'");
    if (rset.next()) //if rset returns data, show data
    do {
    %>
    <%@ include file="showResult.jsp" %>
    <%
    } while (rset.next());
    } //end rset.next() is true
    else
    notFoundMsg = "Employee Number " + empNum + " Not Found";
    %>
    <%@ include file="notFound.jsp" %>
    <% }
    } //end if empNum != null
    //**** lastName as search criteria ****
    else if (lastName != null)
    rset = stmt.executeQuery("select * from EMP where ENAME='" + lastName + "'");
    if (rset.next())
    do {
    %>
    <%@ include file="showResult.jsp" %>
    <%
    } while (rset.next());
    } //end rset.next is true
    else
    notFoundMsg = "Name " + lastName + " Not Found";
    %>
    <%@ include file="notFound.jsp" %>
    <% }
    } //end if lastName != null
    //**** jobTitle as search criteria ****
    else if (jobTitle != null)
    rset = stmt.executeQuery("select * from EMP where JOB='" + jobTitle + "'");
    if (rset.next())
    do {
    %>
    <%@ include file="showResult.jsp" %>
    <%
    } while (rset.next());
    } //end rset.next is true
    else
    notFoundMsg = "Job Title " + jobTitle + " Not Found";
    %>
    <%@ include file="notFound.jsp" %>
    <% }
    } //end if jobTitle != null
    //**** deptNum as search criteria ****
    else if (deptNum != null) //deptNum is entered as search criteria
    rset = stmt.executeQuery("select * from EMP where DEPTNO='" + deptNum + "'");
    if (rset.next())
    do {
    %>
    <%@ include file="showResult.jsp" %>
    <%
    } while (rset.next());
    else
    notFoundMsg = "Dept Number " + deptNum + " Not Found";
    %>
    <%@ include file="notFound.jsp" %>
    <% }
    } //end if deptNum != null
    conn.close();
    %>
    </SimpleContainer>
    </SimpleResult>
    ### Code of NotFound.jsp ###
    <SimpleText>
    <SimpleTextItem><%=notFoundMsg%></SimpleTextItem>
    <Action label="Search" type="ACCEPT" task="GO" target="employee.jsp?"></Action>
    </SimpleText>
    ### Code of ShowResult.jsp ###
    <%
    //format date from query
    java.sql.Date date = rset.getDate("HIREDATE");
    String hireDate = DateFormat.getDateInstance(DateFormat.MEDIUM).format(date);
    %>
    <SimpleText>
    <SimpleTextItem>Emp#: <%=rset.getString("EMPNO")%></SimpleTextItem>
    <SimpleTextItem>Name: <%=rset.getString("ENAME")%></SimpleTextItem>
    <SimpleTextItem>Job: <%=rset.getString("JOB")%></SimpleTextItem>
    <SimpleTextItem>Manager: <%=rset.getString("MGR")%></SimpleTextItem>
    <SimpleTextItem>Hire Date: <%=hireDate %></SimpleTextItem>
    <SimpleTextItem>Salary: <%=rset.getString("SAL")%></SimpleTextItem>
    <SimpleTextItem>Commission: <%=rset.getString("COMM")%></SimpleTextItem>
    <SimpleTextItem>Dept#: <%=rset.getString("DEPTNO")%></SimpleTextItem>
    <SimpleTextItem>Email: <%=rset.getString("EMAIL")%></SimpleTextItem>
    <SimpleTextItem>Phone: <%=rset.getString("PHONE")%></SimpleTextItem>
    <Action label="Search" type="SOFT1" task="GO" target="employee.jsp"></Action>
    <Action label="Call" type="OPTIONS" task="CALL" number="<%=rset.getString("PHONE")%>"></Action>
    </SimpleText>

    Is EMPNO really a string field and not a numeric field? Your query is like
    ... where EMPNO='1949'
    and should it perhaps be
    ... where EMPNO=1949
    ?

  • How to populate query multiple data returned as arrraylist?

    I am new to JSP and likes to know as mentioned in the subject.
    There are total 3 files.
    createUser.jsp -> Here I have to pupulate TITLE form field drop-down.
    TitleDAO.jsp -> Business logic has written to get DB records of titles.
    TitleBean.jsp -> getter/setter bean object.
    Now Here I am pasting all 3 files.
    TitleBean.java
    ===========
    package com.model;
    public class TitleBean {
         int titleID = 0;
         String title = "";
         public void TitleBean(){
              //nothing for now
         public void setTitleID(int titleID){
              this.titleID = titleID;
         public int getTitleID(){
              return this.titleID;
         public void setTitle(String title){
              this.title = title;
         public String getTitle(){
              return this.title;
    TitleDAO.java
    ============
    package com.model;
    import java.util.ArrayList;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    public class TitleDAO {
         public ArrayList<Object> getTitles() {
              Connection con = null;
              ResultSet rs = null;
              Statement stmt = null;
              //compose the SQL query
              String sql = "SELECT titleID,title FROM titleMaster ORDER BY titleID";
              // create object for returning data back to calling code
              ArrayList<Object> AL = new ArrayList<Object>();
              try {
                   //load the driver     
                   Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                   //set the connection string URL
                   String connectionUrl = "jdbc:sqlserver://localhost:1433;"
                             + "databaseName=MyFirstServletDB;user=hitesh;password=hitesh;";
                   //make connection with database
                   con = DriverManager.getConnection(connectionUrl);
                   //create the statement with connection object
                   stmt = con.createStatement();
                   //get the data into result set
                   rs = stmt.executeQuery(sql);
                   //System.out.println("Recordcount==="+rowCount);
                   //looping through result set
                   TitleBean tbObj = new TitleBean();;
                   while(rs.next()){                    
                        tbObj.setTitleID(rs.getInt("titleID"));
                        tbObj.setTitle(rs.getString("title"));
                        AL.add(tbObj);
                        System.out.println("TitleID="+rs.getString("titleID")+", Title="+rs.getString("title"));                    
                   //close all objects
                   if(rs != null) rs.close();
                   if(stmt != null) stmt.close();
                   if(con != null) con.close();
                   //set null to the objects
                   rs = null;
                   stmt = null;
                   con = null;
              } catch (ClassNotFoundException e) {
                   System.err.println("Error ClassNotFoundException: " + e.getMessage());
              catch (Exception e) {
                   System.err.println("Error: " + e.getMessage());
              return AL;
    createUser.jsp
    ===========
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1"%>
    <%@page import="com.model.TitleDAO"%>
    <%@page import="java.util.ArrayList"%>
    <%
         TitleDAO tdObj = new TitleDAO();
         ArrayList<Object> getTitlesRs = new ArrayList<Object>();
         getTitlesRs = tdObj.getTitles();
         //show values came from DAO object
         for (int i = 0; i < getTitlesRs.size(); i++) {
              out.println("<br>Object[" + i + "]=" + getTitlesRs.get(i));
    %>
    =========================
    Please guide me also if there is any other GOOD way to get data of this kind?
    Thanks in advance.
    Edited by: hiteshpatel1979 on Dec 5, 2007 4:16 AM

    Try out following way, fetch bean data from Arraylist.
    for (int i = 0; i < getTitlesRs.length; i++)
    out.println("<br>Object[" + i + "]=" + getTitlesRs.getTitleID();
    out.println("<br>Object[" + i + "]=" + getTitlesRs[i].getTitle();

  • Return Data from query, but not in datagrid.

    Using Flex Builder 2 and ColdFusion, does anyone have advice
    or examples of running a query to database and returning the
    results for display in something other than datagrid? I need more
    control over where my returned data is displaying on my
    forms.

    Hi!
    By using HTTPService class (see
    http://livedocs.adobe.com/flex/201/langref/mx/rpc/http/mxml/HTTPService.html)
    you can execute a db query script which will send the data to flex.
    The data can be any of object|array|xml|e4x|flashvars|text formats.
    You can them handle it however you want to populate whatever
    flex objet.
    Does this help ?

  • Using external parameters within MS Query returning that data right into a pivot table Excel 2010

    In Excel 2010 i was able to use the external parameters within MS Query returning that data right into a pivot table.  But the parameter on the worksheet will not save in the paremeter setting of the data connection.  And if you save it and open
    it and try to refresh the pivot table Excel stops responding and you have to force the file closed.  I found out the reason to crash is that it did not keep the parameter saved.
    Can this be fixed?

    Hi,
    Just
    checking in to see if the information of Oskar was helpful. Please
    let us know if you would like further assistance.
    Jaynet Zhang
    TechNet Community Support

  • Publisher11g - no return data with a data model from logical query

    Hi, i am usign publisher11g with obiee bi server autenthication.
    On rpd i define a security model with a user variable, a initialization block and a where over one fact table.
    When i create a answer report, bi server automatically include on the wher something like this: where user = 'name'.
    Well, when i create a publisher report and try to view data from this fact table, return no data.
    If i create a data model only with a dimension table, not over automatic where from bi server, the report return data.
    View the log nqquery, i see that the generate query include where user ='', not include the value of a session variable.
    Any idea?
    Thanks.

    I do have one question, is the member Balancesheet already in the outline?
    Yes
    **Measure
    Balance Sheet
    Profit and Loss**
    Also in the load rule did you change the dimension load settings for the accounts dimension to be parent/child for the accounts dimension.
    Field Properties -> Dimension Build Properites
    Dimension=
    Field 1 Measure; Type = Parent
    Field 2 Measure; Type = Child
    Field 2 Measure; Type = Alais
    OK
    Quite often people don't realize they have to double click on the dimension name to make sure it gets put as the dimension that gets changed.
    I'm pretty sure your issue is it is trying to do the data load and not the dim build,but that could just be the first problem
    **Click on Dimension Build Field
    Click on Dimension Build setting
    Dimension = Measure; Build Method; = Parent/ Child**
    Please advise

Maybe you are looking for

  • Saving a PDF that is open in Firefox

    After opening a PDF in Firefox, I want to save it on my computer. The problem is that the "save a copy" box, where you name the file, always opens in full-screen mode. I need the "save a copy" box to open smaller-- the same size as in most other appl

  • Java ODBC image database with MS Access

    hi , Can any one please tell me if it is possible to put and get image from MS Access database with java JDBC ODBC driver? If it is possible then what will be the data type in Access and java. Thanks in advance ��

  • DIGIVOX A/D errors when starting analog TV

    Have just install DIGIVOX, Followed instruction, first drivers, then application. When I click on A to lanch analog TV, I get these error. Cannot render audio renderer (5001) and then Cannot init Direct show interface (1001). Use win XP home Sp1. Dir

  • Not able to download Photoshop 7 on Win XP. Are they compatible?

    Is Photoshop 7 the same as CS 7?

  • TS1702 Some magazines not readable in Newstand

    WebMd & TV Guide magazine have a haze over the pages in Newstand. Which makes them unreadable. I have 2 other magazines which are perfectly readable. I have contacted the magazine Company for help to no avail.  I am addressing this issue to your staf