SQL LOGIC

I have a question regarding a SQL statement that I wrote. The following SQL statement brings back no records:
SELECT PROP_BOOK_SI.EMP_ID,
AMPEMP.CLOCK_NUMBER,
AMPEMP.LAST_NAME,
AMPEMP.FIRST_NAME
FROM PROP_BOOK_SI
LEFT JOIN AMPEMP
ON AMPEMP.EMP_ID = PROP_BOOK_SI.EMP_ID
LEFT JOIN ENDED_MISSION
ON ENDED_MISSION.EMP_ID = PROP_BOOK_SI.EMP_ID
WHERE PROP_BOOK_SI.EMP_ID != ENDED_MISSION.EMP_ID
AND PROP_BOOK_SI.AUDIT_DATE IS NULL
However, if I write the SQL statement in this fashion, it brings back records:
(SELECT PROP_BOOK_SI.EMP_ID,
AMPEMP.CLOCK_NUMBER,
AMPEMP.LAST_NAME,
AMPEMP.FIRST_NAME
FROM PROP_BOOK_SI
LEFT JOIN AMPEMP
ON AMPEMP.EMP_ID = PROP_BOOK_SI.EMP_ID
LEFT JOIN ENDED_MISSION
ON ENDED_MISSION.EMP_ID = PROP_BOOK_SI.EMP_ID
WHERE PROP_BOOK_SI.AUDIT_DATE IS NULL)
MINUS+
(SELECT
PROP_BOOK_SI.EMP_ID,
AMPEMP.CLOCK_NUMBER,
AMPEMP.LAST_NAME,
AMPEMP.FIRST_NAME
FROM PROP_BOOK_SI
LEFT JOIN AMPEMP
ON AMPEMP.EMP_ID = PROP_BOOK_SI.EMP_ID
LEFT JOIN ENDED_MISSION
ON ENDED_MISSION.EMP_ID = PROP_BOOK_SI.EMP_ID
WHERE PROP_BOOK_SI.EMP_ID = ENDED_MISSION.EMP_ID)
Logically, it appears to me that both SQL statements are the same. Why the difference in output?
Edited by: 969700 on Nov 5, 2012 10:19 PM

I don't exactly understand the human logic you need to implement - please, explain your purpose. Do you need to return the result of the left join, where the rows doesn't match and the resulting outer joined field contains null?
If so, try smth like this:
SELECT PROP_BOOK_SI.EMP_ID,
AMPEMP.CLOCK_NUMBER,
AMPEMP.LAST_NAME,
AMPEMP.FIRST_NAME
FROM PROP_BOOK_SI
LEFT JOIN AMPEMP
ON AMPEMP.EMP_ID = PROP_BOOK_SI.EMP_ID
LEFT JOIN ENDED_MISSION
ON ENDED_MISSION.EMP_ID = PROP_BOOK_SI.EMP_ID
WHERE (ENDED_MISSION.EMP_ID IS NULL AND PROP_BOOK_SI.EMP_ID IS NOT NULL)
AND PROP_BOOK_SI.AUDIT_DATE IS NULL
It must return all pairs where fields doesn't match and exclude rows with both null fields
Edited by: apiminov on 05.11.2012 23:47

Similar Messages

  • BPC Sql logic and security

    Hello.
    I have set up my Category dimension to be a R/W dimension. Then I set one of the Category dimension members as "Read Only". When I then try to write to that member from an input schedule I correctly receive an error that I do not have the permissions to do so. But if I run a data package written in BPC sql logic I'm able to write to the mentioned member. The logic contains a XDIM_MEMBERSET statement where this member, among others, is included.
    So is this a bug or have I just misunderstood the way security works?

    We are running version 7 with sp5 (7.0.114) for windows. Here comes the logic (the Category member with read only access is "BID_01":
    // This script takes care of quantity calculation.
    // The quantity is calculated by dividing the cost of each employee with
    // the hour rate of the employee.
    // The script will be called from a data package with project as input parameter.
    // Delete all data of the previous quantity calculation.
    *XDIM_MEMBERSET Account=QTY
    *XDIM_MEMBERSET DataSrc=CALCULATED
    *XDIM_MEMBERSET Category=FINAL,D_CAT,BID_01,BID_02,BID_03,BID_04
    *XDIM_MEMBERSET COUNTERPARTS<>D_VEN
    *XDIM_MEMBERSET RptCurrency=NOK
    *WHEN *
    *IS *
       *REC(FACTOR=0)
    *ENDWHEN
    *COMMIT
    // Load the employee hour rates.
    *LOOKUP COST_CONTROL
          *DIM ACC_HR_RATE:ACCOUNT="HR_RATE"
          *DIM BUS_UNITS="D_CC"
          *DIM CATEGORY="D_CAT"
          *DIM CBS="D_CBS"
          *DIM CURR_INP="I_NOK"
          *DIM DATASRC="DIR_INP"
          *DIM EXP_TYPE="D_EXP"
          *DIM RPTCURRENCY="NOK"
          *DIM PROJECT="D_PRO"
          *DIM COUNTERPARTS=COUNTERPARTS.ID     // Because of a bug this line of code must be applied.
    *ENDLOOKUP
    // Perform quantity calculation.
    *XDIM_MEMBERSET Category=FINAL,D_CAT,BID_01,BID_02,BID_03,BID_04
    *XDIM_MEMBERSET Datasrc=<ALL>
    *XDIM_MEMBERSET ACCOUNT=COST,HR_RATE,D_ACC
    *XDIM_MEMBERSET COUNTERPARTS<>D_VEN
    *XDIM_MEMBERSET RptCurrency=NOK
    *WHEN ACCOUNT
    *IS "COST","D_ACC"
       *REC(FACTOR=1/LOOKUP(ACC_HR_RATE),DATASRC="CALCULATED",ACCOUNT="QTY")
    *ENDWHEN
    *COMMIT

  • SQL Logic to add Account

    Hi Expert
    please suggest SQL Logic to Add this same account for different time period for same Year
    CATEGORY RPTCURRENCY     YEAR              ACCOUNTFBENTITYCOSTCENTER FBTIME     SIGNEDDATA
    MAYF     GBP     2010     ACCPYCALC     CEGB11SED20950     2010.APR     150
    MAYF     GBP     2010     ACCPYCALC     CEGB11SED20950     2010.MAY     250
    MAYF     GBP     2010     ACCPYCALC     CEGB11SED20950     2010.FEB     -500
    Regards
    Gayu

    Hi Nilanjan
    My requirement is a to write the total value  to a FILE. When Category is MAYF then required to ADD
    ACCPYCALC  accounts for period Jan,FEB,MARCH,APR can we do this with YTD if so how please.
    MAYF GBP 2010 ACCPYCALC GB11SED20950 2010.APR 150
    MAYF GBP 2010 ACCPYCALC GB11SED20950 2010.MAY 250
    MAYF GBP 2010 ACCPYCALC GB11SED20950 2010.FEB -500
    Reageds
    Gayu

  • Adding a button to a page which initiates PL/SQL logic

    Hi,
    I would like to add a button onto an apex page which runs some pl/sql logic.
    Such as:
    Start PL/SQL   <--- This is the button
    Which does the following pl/sql (this is just an example):
    DECLARE
    v_tmp INTEGER;
    BEGIN
    SELECT 1 INTO v_tmp FROM DUAL;
    END;I have tried a couple of suggestions found within this forum, they did not work (no errors, just a "button" did not appear). I have also tried the suggestion in the APEX 2.2 Developers Guide, in section 6-10, titled "Add a Process". Again, this did not work, no errors, just no button either.
    We have rdbms 10.2.0.1.0, and 2.2.0 apex.
    Thanks! --Kate                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Wow, can't get anymore complete than a hollywood movie to demonstrate functionality. Thanks John and Tom, I think you were both saying the same thing, John just put it in a nice and easy wrapper!
    It worked great, I have never used this tool before (heard lots about it) and was literally given the request a mere few hours ago to create a page that does X when a button is pressed. Thanks to you, it's done. --Kate                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Multiple values in subreport?  How to put SQL logic into Formula editor

    Hi
    I am passing a id from main report to sub report. Based on this id i display a field in the sub report. The field can have multiple values.
    The issue i am having is in the sub report only 1 value is displayed.
    I might be missing some link
    Below is what i am trying to achieve , name can return multiple values and i am passing the id.
        select name from ism.active_ingredient where id in
        (select active_ingredient_id from ism.prod_acting where  product_id in
        (select child_member_product_id from ism.product_tree  where parent_member_product_id='8816846'))
    I have the tables and links as per the above sql and below is what i have done.
    {PRODUCT_TREE.PARENT_MEMBER_PRODUCT_ID} = {?Pm-@product_id}
    Thanks in advance
    Edited by: san-user on Jul 23, 2011 1:10 AM

    Hi
    In sub report where you are  placing ID field ?  If you are placing in Group Header / footer or report footer you will see only one value.  Try to place this in your detail section.
    Also I see that you have parameter on ID and this parameter you are trying to link to your sub report.
    --Do you have ID  parameter in your sub report ? If so, link your main report parameter to sub report parameter.
    --If not link your main report parameter to sub report database field.
    Also as a test purpose, try to save your sub report as a different report and execute with a single ID and check you are getting multipul values in your sub reort.
    Thanks,
    Sastry

  • Simulate select distinct count sql logic in query or data model

    hello experts,
    given prerequisites: DSO with flat table without any key figures - just characteristics (about 10)
    the requirement is to produce the table with all possible combinations of those characteristics with counting the hits
    - this flat table should be then loaded to another system
    exmple
    char error| char division| char time|char id xxx xxx xxx xxx xxx
    some counter should be implemented and all combinations of 10 characteristics counted
    example
    char error| char division| char time|char id xxxxx  1
    char error| empty field| empty field| |char id   5
    etc
    the output should be flat table with counts on the right - some fields will be empty depending on combinations to be counted
    what is the best way - query with RCF or some SQL statements in Transformation? how to implement the output desired
    thanks in advance

    That sounds very odd.
    Can you turn on debug tracing by adding
    -Djbo.debugoutput=console
    to the Java options of your project (Project Properties, Profiles, Development, Runner)?
    Then test the query that is output in the log in SQL*Plus and see if you get the same results.
    -SteveA (JDev Team)

  • Help with using dynamic sql logic in a view please?

    Greetings,
    I want to create a dynamic union using all the databases on server. The following works:
    declare @sqlvarchar(max)
    select
    @sql=IsNull(@sql+'union
    all ','')+'select
    * from  '+name+'.[dbo].[A]''
    inner join '+name+'.[dbo].[B]'' on
    a.f1=b.f1'
    from
    sys.databases
    where
    name
    in(select
    name
    from
    sys.databases)
    exec
    (@sql)
    The problem is I need something tangible, like a view, to query using SSAS later. I've tried to use SELECT into to load a new table with a resulting dataset. It gives me a syntax error - the dynamic part can't be combined with static. I can't use OPENQUERY
    because it all happens on the same server. Assistance would be appreciated. Thanks

    Well, you could regenerate the view each time a database is created or dropped.
    Or you can define your cube using an empty view and load the cube using SSIS, eg with
    Dimension Processing Destination.
    Or you can use something like a CLR TVF inside your view.
    David
    David http://blogs.msdn.com/b/dbrowne/

  • SQL LOGIC - How to accept USER input and use that data in SQL Logic?

    Hello Experts
    Can anyone of you please explain in detail how to acheive the above task am a begginner, it would be great help for me.
    Thanks in Advance.

    Hi,
    You mean to say, you need to use inputs from Data manager Prompts in your Script Logic.
    From Help File
    You can use the EvDTSModifyPkg task to dynamically pass a text string to logic in Data Manager.  For example, a user who wishes to dynamically pass a text string representing a year (which is a portion of the *XDIM_MEMBERSET instruction) could use the following steps:
    Using the EvDTSModifyPkg task, prompt for the year, i.e., PROMPT(TEXT,%TEXT%,"select a year")
    Pass the returned %TEXT% to the FormulaScript of the RunLogic task as follows: TASK(RUNLOGIC,FORMULASCRIPT,"*FUNCTION MYYEAR=%TEXT%u201D)
    In the Data Manager logic, use the dynamically created function as follows: *XDIM_MEMBERSET TIME=MYYEAR.INPUT.
    The logic name in the RunLogic task must be specified with the .LGF extension to enforce its validation at run time.
    BPC NW 2.0 Version Works differently.
    Hope this Helps,
    Kranthi

  • I-expenses - expense report header approver - sql logic

    Hi folks,
    I am trying to find a logic that can be used to identify the user that approved an expense report.
    I cannot use the WF_NOTIFICATIONS table as this is flushed every 90 days.
    This leaves 'AP_EXPENSE_REPORT_HEADERS_ALL.EXPENSE_CURRENT_APPROVER_ID' or 'AP_EXPENSE_REPORT_HEADERS_ALL.OVERRRIDE_APPROVER_ID' either connecting to PER_ALL_PEOPLE_F.
    The problem is that I cannot understand the logic I should use to determine which field I should use.
    Yesterday, I created a test expense report and nominated a user 'J Bloggs' as the approver, however, 'J Bloggs' did not have the necessary approval requirements, thus the report was sent to a 'A Smith' to approve.
    The EXPENSE_CURRENT_APPROVER_ID contained the PERSON_ID of 'A Smith' and the OVERRIDE_APPROVER_ID contained the PERSON_ID of 'J Bloggs'.
    At the moment, I am using the logic of use NVL(EXPENSE_CURRENT_APPROVER_ID, OVERRIDE_APPROVER_ID), however, there are some expense reports with neither field populated and with no workflow notfications I cannot find the approver.
    Anyone shed any light?
    Thanks.

    Hi Cleme,
    i-Expense approval is role based approval system.
    In workflow / AME you create a rule for flowing the approval process in a defined way.
    majourly 2 kind of approval process business follow
    1) 1 stop go
    2) Chain approval process
    in one stop go, when employee submit an expense report then it does not require any supervisor approval, all are auto approved and it only need an AP approval, which AP audit team perform i.e checking reciepts ,bills for proof and check the varified check box.
    and this completes your APEXP cycle.
    in Chain approval process it first goes to your direct supervisor, if his job/role is higher then u then it waits for his approval in case his signing limit is lower than the expense claim then approval notification goes to the 2nd super visor(supervisor's supervisor).
    In some business it's based on ammount also if 100K no approval required if 200k then only 1st supervisor approval required, like this.
    lets say your approval process goes to 2 approvers at least in workflow/ame then when goes to 2nd approver then the 1st approver id is overwriten by the 2nd supervisor id.
    In case you are planing to print a customize report like below format;
    Expense Report Expense_Claim_By Date Approved_By Amount
    Then the approver details you will get only in WF_Notifications_details table
    you need to capture the details from here only
    you can filter the notification_subject %EXPENSE_REPORT_NAME% ..
    and you will get all the lines in WF table for that particulat Expense report from start to end.
    Thanks,
    Ajit

  • Please help with the sql logic

    The below is going to be a record set from for a view from the FROM CLAUSE
    1. Find component DOCUMENT where the document type = Square Metres (DOC.UOM_STD_ID = 'METR_MTR) If any components are found, retrieve the Document records for these components ONLY.
    2. Otherwise, if no components exist with a Document type = Square Metres, look for components with a Document type of Acres (DOC.UOM_STD_ID = 'ACRE'). If found, retrieve the Space Lease records for these components ONLY.
    3. Otherwise, if the Document does not have components with a type = Square Metres or Acres, look for components with the type of (DOC.UOM_STD_ID = 'PARK'). Then retrieve the departments associated with these parking components.
    For Space Lease records above, retrieve the associated Org ID (SPACE.SPORG).
    Return all departments where
    the associated Org Type (ORG.ORGCLASS) = 'NON'
    or the associated Org Type (ORG.ORGCLASS) = 'GD'
    Thank you

    maybe something like:
    SQL> select emp.empno, emp.ename, emp.deptno
      2    from emp,
      3         (select case when (select 1 from emp where deptno = 10 and rownum  = 1) = 1 then 1
      4                      when (select 2 from emp where deptno = 60 and rownum  = 1) = 2 then 2
      5                      else 3
      6                 end case_col
      7            from dual) d1
      8   where deptno = decode(d1.case_col,1,10,
      9                                     2,60,
    10                                     3,70);
         EMPNO ENAME          DEPTNO
          7839 KING               10
          7782 CLARK              10
          7934 MILLER             10
    SQL> in you code it will be something like:
    select ...
       from document t1,        
            (select case when (select 1 from document doc where DOC.UOM_STD_ID = 'METR_MTR' and rownum  = 1) = 1 then 1
                         when (select 1 from document doc where DOC.UOM_STD_ID = 'ACRE' and rownum  = 1) = 2 then 2
                         else 3
                    end case_col
               from dual) d1
    where t1.uom_std_id = decode(d1.case_col,1,'METR_MTR',
                                             2,'ACRE',
                                             3,'PARK',
                                               null);note: untested

  • SQL logic help for pl/sql block

    Hi All,
    I need your suggestions and comments for the below issue:
    I have two tables: table A and table B
    Table A has two columns as id and counts:
    Id Counts
    99 10
    999 13
    9999 7
    Table B has two columns as Id and order:
    Id Order
    99 1
    999 2
    9999 3
    We need to update Order in Table B such that Id having highest count in table A has Order as 1 in table B and it keep on increasing the order for other Ids based on decreasing counts in table A. This will be like a job which will run daily and look for counts in table A and update Order in table B according to it.
    It seems to be simple but i am not getting it. Please help me out of this by writing some PL/SQL block.
    I will really appreciate your all comments and responses.
    Regards
    Dev

    Hi,
    Keen2Learn wrote:
    Hi All,
    I am really greatful to all fo you for all your replies and comments. I change ORDER table to ORDERS. All you replies worked for me but there is some slight change in scenario which i need to discuss with you all.
    E.g: Table A has 10 rows like below:
    Id Counts Type
    99 10 A
    999 13 A
    9999 7 C
    99 4 B
    999 2 C
    88 2 A
    77 1 C
    777 3 B
    777 5 A
    888 2 CIf you'd like help, please post CREATE TABLE and INSERT statements for your sample data (including table b as it is before the UPDATE or MERGE).
    I populate data in Orders column Table B based on id, by grouping sum of counts for that id in table A.
    Id 999 has highest sum(count) as 15, so it has orders as 1 in Table B and do same for descending counts for each Id.
    Table B has 5 rows like below:
    Id Orders
    99 2
    999 1
    88 4
    777 3
    555 5
    Assume Table B as static(no new record comes in it) but only its Orders changes for each Id based on counts for that Id in Table A. As you see, Table B has id 555 which is not in Table A, so we need to update its orders to the highest number by taking its Count as 0(zero). Sorry, it's unclear what you want to do.
    Post what you'd like table b to look like after the UPDATE or MERGE.
    Right now i am doing it like this:
    declare
         cursor c1 is
         select Id, SUM (COUNT), RANK () OVER (ORDER BY SUM (COUNT)) rnk
         from TableA      AND Id IN (SELECT Id FROM TableB)
    GROUP BY Id
    ORDER BY rnk DESC;
    i NUMBER := 1;
    begin
    for curr in c1
    loop
         update TableB      
    set orders = i
         where id = curr.id;
         i := i + 1;
    end loop;
    end;I'm not sure what you're trying to do, but I'll bet you don't need PL/SQL to do it. Use a single UPDATE or MERGE statement (inside PL/SQL if necessary).
    But it is not updating orders for Id 555 in TableB.There is no row for id=555 in table b, and, according to your requirements, there never will be, because "Table B as static(no new record comes in it)". It's behaving exactly as you said you wanted it to. What's the problem?
    Please provide your suggesstions on what needs to be done to take care of this scenario. I will really appreciate your all suggesstions and comments. Please let me know if need some more explanation.Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using.

  • Question Regarding SQL logic error!

    Hello everyone,
    I get the following error when executing an Informatica mapping with teh following SQL in the Source Qualifier.
    error - OR- 00936: missing expression.
    Can anyone help please!
    SELECT
    PS_CUSTOMER.SETID
    , PS_CUSTOMER.CUST_ID
    , PS_CUSTOMER.CUST_STATUS
    , PS_CUSTOMER.ADD_DT
    , PS_CUSTOMER.NAME1
    , PS_CUSTOMER.TAXPAYER_ID
    , PS_CUSTOMER.WEB_URL
    , PS_CUSTOMER.LAST_MAINT_OPRID
    , PS_CUSTOMER.DATE_LAST_MAINT
    , PS_CUST_SIC_CODES.SIC_CD_QUAL
    , PS_CUST_SIC_CODES.SIC_CODE
    , PS_CUST_CGRP_LNK.CUST_GRP_TYPE
    , PS_CUST_CGRP_LNK.CUSTOMER_GROUP
    , PS_CUST_CGRP_LNK.LASTUPDDTTM
    , PS_CUST_ID_NBRS.STD_ID_NUM
    , PS_CUSTOMER.SUBCUST_QUAL1
    FROM PS_CUSTOMER
    select SIC1.SETID, SIC1.CUST_ID, MAX(SIC1.SIC_CODE) SIC_CODE, SIC1.SIC_CD_QUAL
    from PS_CUST_SIC_CODES SIC1
    where SIC1.SIC_CD_QUAL =
    ( select MAX(SIC_CD_QUAL)
    from PS_CUST_SIC_CODES SIC2
    where SIC2.CUST_ID = SIC1.CUST_ID
    and SIC2.SETID = SIC1.SETID
    group by SETID, CUST_ID, SIC1.SIC_CD_QUAL
    ) PS_CUST_SIC_CODES
    select A.CUST_ID, A.SETID, A.CUST_GRP_TYPE
    , MAX(A.CUSTOMER_GROUP) CUSTOMER_GROUP, A.LASTUPDDTTM
    from PS_CUST_CGRP_LNK A
    where A.CUST_GRP_TYPE =
    SELECT MAX(CUST_GRP_TYPE)
    FROM PS_CUST_CGRP_LNK B
    WHERE A.CUST_ID = B.CUST_ID
    AND A.SETID = B.SETID
    AND A.LASTUPDDTTM = B.LASTUPDDTTM
    AND B.LASTUPDDTTM =
    SELECT MAX(LASTUPDDTTM)
    FROM PS_CUST_CGRP_LNK C
    WHERE C.CUST_ID = B.CUST_ID
    AND C.SETID = B.SETID
    GROUP BY CUST_ID, SETID, CUST_GRP_TYPE, LASTUPDDTTM
    ) PS_CUST_CGRP_LNK
    select SETID, CUST_ID, STD_ID_NUM
    from PS_CUST_ID_NBRS
    where STD_ID_NUM_QUAL = 'DNS'
    ) PS_CUST_ID_NBRS
    WHERE
    { PS_CUSTOMER
    LEFT OUTER JOIN
    PS_CUST_SIC_CODES ON
    PS_CUSTOMER.SETID = PS_CUST_SIC_CODES.SETID
    AND PS_CUSTOMER.CUST_ID = PS_CUST_SIC_CODES.CUST_ID
    LEFT OUTER JOIN
    PS_CUST_CGRP_LNK ON
    PS_CUSTOMER.SETID = PS_CUST_CGRP_LNK.SETID
    AND PS_CUSTOMER.CUST_ID = PS_CUST_CGRP_LNK.CUST_ID
    LEFT OUTER JOIN
    PS_CUST_ID_NBRS ON
    PS_CUSTOMER.SETID = PS_CUST_ID_NBRS.SETID
    AND PS_CUSTOMER.CUST_ID = PS_CUST_ID_NBRS.CUST_ID
    ORDER BY PS_CUSTOMER.CUST_ID , PS_CUSTOMER.SETID
    Thanks,
    Ajay.

    Kramer wrote:
    Hi
    So.. do we have to pay for the feature regarding sql tuning advisor?
    Can we use the dbms_sqltune package for free in oracle?
    No, you need the license. Please read below,
    http://download.oracle.com/docs/cd/E11882_01/license.112/e10594/options.htm#CIHFIHFG
    I `m doing below test on my Linux. I installed an oracle on it and only for study purpose so didn`t pay.
    As you can see. I got no output.
    SQL> exec dbms_sqltune.execute_tuning_task('TASK_1634');
    PL/SQL procedure successfully completed.
    SQL> select dbms_sqltune.report_tuning_task('TASK_1634') from dual;
    DBMS_SQLTUNE.REPORT_TUNING_TASK('TASK_1634')
    GENERAL INFORMATION SECTION
    Please read the below link to learn how to use the STA.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16638/sql_tune.htm
    HTH
    Aman....

  • Need Help writing SQL Logic

    I get a monthly data feed in excel with pcpid and memberid information.I'm supposed to get member detail information for all the members associated only with the pcpid in the spreadsheet
    How do i write a query so that i associate a memberid only with the pcpid given in the spreadsheet
    The problem iam having is when i write a query to bring the member information by providing pcpid in list , i get multiple records for a member as the member might earlier be associated with another PCPid
    Data From Excel
    Member No PCP ID
    101 A
    102 B
    103 C
    104 D
    When i insert these values in to the query to get remaining member Details below is how the data looks
    Member No PCP ID
    101 A
    101 B
    101 D
    102 A
    102 B
    103 A
    103 C
    104 B
    104 D
    Please Advice.
    thanks.

    SQL and PL/SQL FAQ
    I have no idea what data is in the DB & no idea what the result set should be or why?

  • Help with sql logic

    I have two tables some_table1 and some_table2
    desc some_table1
    Name Type
    ID NOT NULL VARCHAR2(16)
    NAME VARCHAR2(25)
    desc some_table2
    Name Type
    ID NOT NULL VARCHAR2(16)
    STATUS VARCHAR(20);
    The requirement is to concatenate INATIVE status value to ID with status = 'INACTIVE' in some_table2.
    eg if id in some_table1 and some_table2 = 1 and status in some_table2 = 'INACTIVE', I will have to append
    'INACTIVE' || some_table1 name, the question is some_table1 have a lots of names that the length is already 25
    characters, the requirement want Inative||' '||name inrespective of the name length, I am not allow to increase the name datatype length , but can reduce name to allow for the Inactive||' '||
    declare
    cursor c1 IS
    select cst1.id,cst1.name,cst2.status
    from some_table1 cst1, some_table2 cst2
    where cst1.orgid = cst2.orgid
    and cst2.status = 'INACTIVE';
    c1_data c1%rowTYpe;
    BEGIN
    OPEN c1;
    LOOP
    FETCH C INTO c1_data ;
    EXIT WHEN C1%NOTFOUND;
    UPDATE some_table1
    SET NAME = c1_data.status||' '|| c1_data.name
    where id = c1_data.id;
    END LOOP;
    CLOSE;
    END;
    ORA-12899: value too large for column "TEST"."ID"."NAME" (actual: 34, maximum: 25)
    I want to be able to fit the update in inrespctive of the name length, I need a logic to truncate the name so as not to exceed the maximum size.
    Thank you.

    I found the solution. sometable2.status||' '||substr(sometable1.name,1,25-9) since inactive with a space is 9 xters.
    Thank you everyone.
    Edited by: Ade2 on Feb 11, 2009 5:26 PM

  • Need some help with SQL logic

    Hi all,
    I have the following query:
    select x.area_id
            , x.ORG_id
            , x. product               
            , case when x.param_info_key in (400, 410, 420, 430, 440)
                         then x.new_value
                end as facility_average_price
            , case when x.param_info_key in (660, 670,680,690,700)
                         then x.new_value
                end as royalty_rate_adjustment     
    from
         select d.area_id
                 , d.ORGANIZATION_NUMBER org_id
                 , d.PARAM_INFO_KEY
                 , i.PARAM_INFO_NAME
                 , case when d.param_info_key in (400)
                                      then 'Gas'
                          when d.param_info_key in (410, 700) 
                                  then 'Ethane'
                          when d.param_info_key in (420, 680)
                                  then 'Propane'
                          when d.param_info_key in (430, 690)
                                  then 'Butane'     
                          when d.param_info_key in (440, 670)
                                  then 'Pentane'                                                                              
                    end as product
                 ,  d.old_value
                 , d.new_value
                 , m.CHANGE_DATE_TIME
                 , max(m.CHANGE_DATE_TIME) over(partition by area_id, organization_number,d.param_info_key) max_change_date
                 , m.PERIOD_KEY
                 , m.change_comment
         from accruals2.accrual_parm_chng_hist_detail d
               , accruals2.accrual_parm_chng_hist_master m
               , accruals2.accrual_period p
               , accruals2.accrual_param_info i
         where d.PARM_CHNG_HIST_MASTER_KEY = m.PARM_CHNG_HIST_MASTER_KEY
                and m.PERIOD_KEY = p.PERIOD_KEY
                and d.PARAM_INFO_KEY = i.PARAM_INFO_KEY
                and d.param_info_key in (400, 410, 700, 680, 430, 690, 440, 670)
                and area_id = 1013
                and p.ACCOUNTING_DATE = date '2010-04-30'
    ) x
    where x.change_date_time = x.max_change_date     
    order by x.area_id, x.org_id
           , x.product,  x.PARAM_INFO_KEYIt returns a data set that looks like this:
    AREA_ID     ORG_ID     PRODUCT     FACILITY_AVERAGE_PRICE     ROYALTY_RATE_ADJUSTMENT
    1013          1     Butane          0.08     
    1013          1     Butane                                             0.0015
    1013          1     Ethane          0.06     
    1013          1     Ethane                                             0.003
    1013          1     Gas               -0.1     
    1013          1     Pentane          0.09     
    1013          1     Pentane                                             0.006
    1013          1     Propane                                             0.007                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    And...............?

Maybe you are looking for

  • Need Info on RDA-enabled data source based on FM

    Hi, I need Info on RDA-enabled data source based on Function Module. How to implement it? Thanks & Regards, Rashmi.

  • What application do I need to use to download Dreamweaver?

    I'm getting a message which says "This Link needs to be opened with an application"  which application do I need to choose?

  • CF8 Standard and Oracle

    I recently had a server die that was running an old old cf4.5 enterprise with oracle. I just purchased the coldfusion 8 standard (no $ for enterprise right now) and I need to connect to the oracle database. Is there any instructions on doing this? pl

  • Sun Java Web Server 6.1SP4 deadlock, stops responding

    Hi, i have a java web app on a Java Web SErver 6.1SP4 and when there are a lot of users the web server hangs, it stops responing. After a while (from 2 to 15 minutes) it start responding again. This serves neither dinamic nor static content. CPU usag

  • How can I import photos into a specific album?

    Wow, I have been using Applescript for 15 years but I can't get this to work. I just want to make a script that brings a JPG image into iPhoto '09 into a specific album, but it seems set against letting me, and I can't find specific examples of what