Unable to build SQL query for one parameter at multiple locations

Hi,
Below one is the sample SQL in which I used :p_organization_id at 3 positions
First one at in the main where clause
Second one after START WITH
Third one is after CONNECT BY PRIOR
SELECT bs.assembly_item_id
,msia.segment1 a_item
,SYS_CONNECT_BY_PATH(msi.segment1, '---->') "Path",
bc.component_item_id,
bc.disable_date,
bc.item_num,
mp.organization_code organization_code,
LEVEL,
bc.attribute1 reference_no,
msi.segment1 item_number,
msi.description description
FROM inv.mtl_system_items_b msi,
inv.mtl_system_items_b msia,
bom.bom_structures_b bs,
bom.bom_components_b bc,
inv.mtl_parameters mp
WHERE
bc.component_item_id = msi.inventory_item_id
AND bc.bill_sequence_id = bs.bill_sequence_id
AND bs.assembly_item_id = msia.inventory_item_id
and msi.segment1 = 'P5200802-DB100'
AND bs.organization_id = msia.organization_id
AND msia.organization_id = msi.organization_id
AND msi.organization_id = mp.organization_id
AND mp.organization_code = :p_organization_id
AND NVL(TRUNC(bc.disable_date),TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
START WITH msia.segment1 = '24310003-13.1' AND mp.organization_code = :p_organization_id
CONNECT BY PRIOR bc.component_item_id = bs.assembly_item_id
AND mp.organization_code = :p_organization_id
ORDER SIBLINGS BY bc.item_num
My question is how to use single parameter value that should go in the multiple positions in the SQL.
Please suggest if this can archived either in the Discoverer Admin / Desktop in detail.
Regards,
Chiranjeevi Meda

Hi,
The only way you can use SQL with a connect by in Discoverer is to either put the SQL in a view or put the SQL in a custom folder. Either way you will not be able to pass parameter directly from Desktop/Plus to the view or custom folder.
The solution probably is to use session parameters and replace the :p_organization_id in the 3 positions with SYS_CONTEXT('DISCO_CONTEXT', 'ORGANIZATION_ID') once you have defined your DISCO_CONTEXT namespace and ORGANIZATION_ID session parameter.
See these threads for more information. (Re: Passing multiple parameters into Custom Folder... http://learndiscoverer.blogspot.com/2008/11/metalink-note-304192.html)
Rod West

Similar Messages

  • How to build sql query for view object at run time

    Hi,
    I have a LOV on my form that is created from a view object.
    View object is read-only and is created from a SQL query.
    SQL query consists of few input parameters and table joins.
    My scenario is such that if input parameters are passed, i have to join extra tables, otherwise, only one table can fetch the results I need.
    Can anyone please suggest, how I can solve this? I want to build the query for view object at run time based on the values passed to input parameters.
    Thanks
    Srikanth Addanki

    As I understand you want to change the query at run time.
    If this is what you want, you can use setQuery Method then use executeQuery.
    http://download.oracle.com/docs/cd/B14099_19/web.1012/b14022/oracle/jbo/server/ViewObjectImpl.html#setQuery_java_lang_String_

  • SQL query for join table and multiple values

    Trying to join two tables , Emphours and EmpStatus to get
    result which gives each emplyees hour 
    worked each day
    in past  say 1 year in what status. I need result similar to table 3 , Hours Can also be grouped per week
    all I need Is Each employees hours in each week and his status and position at that time if possible
    any help will be highly appreciated. Thank you 
    note: payday is every other Friday- week runs from Saturday through Friday
    EmpStatus Table tracks when employees status changed
    EmpHours
    employee
    workday
    payday
    hours
    position
    101
    1/1/2014
    1/3/2014
    8
    assistant
    101
    1/3/2014
    1/3/2014
    8
    assistant
    101
    1/4/2014
    1/17/2014
    8
    assistant
    101
    1/5/2014
    1/17/2014
    8
    assistant
    101
    1/7/2014
    1/17/2014
    8
    assistant
    101
    1/8/2014
    1/17/2014
    8
    assistant
    101
    1/9/2014
    1/17/2014
    8
    assistant
    101
    1/11/2014
    1/17/2014
    8
    assistant
    101
    1/13/2014
    1/17/2014
    8
    assistant
    101
    1/14/2014
    1/17/2014
    8
    assistant
    101
    1/18/2014
    2/14/2014
    8
    assistant
    102
    1/1/2014
    1/3/2014
    7
    manager
    102
    1/25/2014
    1/31/2014
    7
    manager
    102
    1/26/2014
    1/31/2014
    7
    manager
    102
    1/28/2014
    1/31/2014
    7
    manager
    102
    1/31/2014
    1/31/2014
    7
    manager
    103
    1/1/2014
    1/3/2014
    5
    intern
    103
    1/31/2014
    1/31/2014
    6
    intern
    104
    1/14/2014
    1/17/2014
    5
    supervisor
    104
    1/30/2014
    1/31/2014
    6
    supervisor
    EmpStatus
    employee
    start_date
    status
    101
    1/1/2014
    parttime
    101
    1/18/2014
    fulltime
    102
    1/1/2014
    seasonal
    102
    1/18/2014
    fulltime
    103
    1/1/2014
    partime
    103
    1/18/2014
    fulltime
    104
    1/4/2014
    parttime
    104
    1/18/2014
    fulltime
    Table 3
    employee
    status
    hours
    position
    workday
    weekend
    payday
    101
    parttime
    8
    assistant
    1/1/2014
    1/3/2014
    1/3/2014
    101
    parttime
    8
    assistant
    1/3/2014
    1/3/2014
    1/3/2014
    101
    parttime
    8
    assistant
    1/4/2014
    1/10/2014
    1/17/2014
    101
    parttime
    8
    assistant
    1/5/2014
    1/10/2014
    1/17/2014
    101
    parttime
    8
    assistant
    1/7/2014
    1/10/2014
    1/17/2014
    101
    parttime
    8
    assistant
    1/8/2014
    1/10/2014
    1/17/2014
    101
    parttime
    8
    assistant
    1/9/2014
    1/10/2014
    1/17/2014
    101
    parttime
    8
    assistant
    1/11/2014
    1/17/2014
    1/17/2014
    101
    parttime
    8
    assistant
    1/13/2014
    1/17/2014
    1/17/2014
    101
    parttime
    8
    assistant
    1/14/2014
    1/17/2014
    1/17/2014
    101
    fulltime
    8
    assistant
    1/18/2014
    1/24/2014
    2/14/2014
    102
    seasonal
    7
    manager
    1/1/2014
    1/3/2014
    1/3/2014
    102
    fulltime
    7
    manager
    1/25/2014
    1/25/2014
    2/14/2014
    102
    fulltime
    7
    manager
    1/26/2014
    1/26/2014
    2/14/2014
    102
    fulltime
    7
    manager
    1/28/2014
    1/28/2014
    2/14/2014
    102
    fulltime
    7
    manager
    1/31/2014
    1/31/2014
    2/14/2014
    103
    parttime
    5
    intern
    1/1/2014
    1/3/2014
    1/3/2014
    103
    fulltime
    6
    intern
    1/31/2014
    1/31/2014
    2/14/2014
    104
    parttime
    5
    supervisor
    1/14/2014
    1/17/2014
    1/17/2014
    104
    fulltime
    6
    supervisor
    1/30/2014
    1/31/2014
    1/31/2014

    Hello David,
    Try this query
    set dateformat mdy;
    declare @EmpHours table
    (Employee int,workday date,payday date,hours int,position varchar(50));
    insert into @EmpHours values
    (101,'1/1/2014','1/3/2014',8,'assistant'),
    (101,'1/3/2014','1/3/2014',8,'assistant'),
    (101,'1/4/2014','1/17/2014',8,'assistant'),
    (101,'1/5/2014','1/17/2014',8,'assistant'),
    (101,'1/7/2014','1/17/2014',8,'assistant'),
    (101,'1/8/2014','1/17/2014',8,'assistant'),
    (101,'1/9/2014','1/17/2014',8,'assistant'),
    (101,'1/11/2014','1/17/2014',8,'assistant'),
    (101,'1/13/2014','1/17/2014',8,'assistant'),
    (101,'1/14/2014','1/17/2014',8,'assistant'),
    (101,'1/18/2014','2/14/2014',8,'assistant'),
    (102,'1/1/2014','1/3/2014',7,'manager'),
    (102,'1/25/2014','1/31/2014',7,'manager'),
    (102,'1/26/2014','1/31/2014',7,'manager'),
    (102,'1/28/2014','1/31/2014',7,'manager'),
    (102,'1/31/2014','1/31/2014',7,'manager'),
    (103,'1/1/2014','1/3/2014',5,'intern'),
    (103,'1/31/2014','1/31/2014',6,'intern'),
    (104,'1/14/2014','1/17/2014',5,'supervisor'),
    (104,'1/30/2014','1/31/2014',6,'supervisor');
    --select * from @EmpHours
    declare @EmpStatus table
    (employee int,start_date date,status varchar(20));
    insert into @EmpStatus values
    (101,'1/1/2014','parttime'),
    (101,'1/18/2014','fulltime'),
    (102,'1/1/2014','seasonal'),
    (102,'1/18/2014','fulltime'),
    (103,'1/1/2014','partime'),
    (103,'1/18/2014','fulltime'),
    (104,'1/4/2014','parttime'),
    (104,'1/18/2014','fulltime');
    WITH C AS
    SELECT es.employee,es.start_date, es.status, ROW_NUMBER() OVER(partition by employee ORDER BY start_date) AS rownum
    FROM @EmpStatus ES
    CTE_RANGES as(
    SELECT cur.employee,Cur.start_date start_range, cur.status,case when nxt.start_date is null then '2099-12-31' else dateadd(d,-1,Nxt.start_date) end AS end_range
    FROM C AS Cur
    left JOIN C AS Nxt
    ON Nxt.rownum = Cur.rownum + 1 and cur.employee=nxt.employee)
    select eh.*,es.status from @EmpHours EH join CTE_RANGES Es on EH.Employee =es.employee and EH.workday between es.start_range and es.end_range
    --where es.employee=101
    You will need a calender table too which can be joined to the output of the above query to get the weekend dates.
    You can find the T-SQL code to generate the calender here
    http://stackoverflow.com/questions/19191577/t-sql-function-to-generate-calendar-table
    and posting the questions with necessary DDL , DML (like I have posted) would help us a lot. 
    Satheesh
    My Blog

  • Provide sql query for below one

    hi everyone,
    in my source table [finanace_dept] contains two columns [finance_id,r_mature_kd] with 2 million records and sample data given below.
    finance_id r_mature_kd
    1 H
    1 T
    1 T
    2 T
    3 H
    4 S
    4 T
    4 T
    5 X
    6 H
    6 L
    6 L
    6 M
    please provide sql query for below expected output.
    expected output :
    finance_id r_mature_kd
    1 H
    1 T
    4 S
    4 T
    6 H
    6 L
    6 M
    for column finance_id: '1', contains three records, but two distinct r_mature_kd hence it should retrive only two records with H,T
    for column finance_id: '2','3', contains only one record hence this records should not retrive.
    for column finance_id: '6', contains four records, but three distinct r_mature_kd hence it should retrive only two records with H,L,M
    please help on this.

    WITH T(finance_id,r_mature_kd) AS (
    SELECT 1, 'H' FROM DUAL UNION ALL
    SELECT 1, 'T' FROM DUAL UNION ALL
    SELECT 1, 'T' FROM DUAL UNION ALL
    SELECT 2, 'T' FROM DUAL UNION ALL
    SELECT 3, 'H' FROM DUAL UNION ALL
    SELECT 4, 'S' FROM DUAL UNION ALL
    SELECT 4, 'T' FROM DUAL UNION ALL
    SELECT 4, 'T' FROM DUAL UNION ALL
    SELECT 5, 'X' FROM DUAL UNION ALL
    SELECT 6, 'H' FROM DUAL UNION ALL
    SELECT 6, 'L' FROM DUAL UNION ALL
    SELECT 6, 'L' FROM DUAL UNION ALL
    SELECT 6, 'M' FROM DUAL
    SELECT  DISTINCT finance_id,r_mature_kd,C FROM(
    SELECT finance_id,r_mature_kd,COUNT(1) OVER (PARTITION BY finance_id) C
    FROM T
    WHERE C > 1
    ORDER BY 1
    FINANCE_ID
    R_MATURE_KD
    C
    1
    H
    3
    1
    T
    3
    4
    S
    3
    4
    T
    3
    6
    H
    4
    6
    L
    4
    6
    M
    4
    Ramin Hashimzade

  • Error while executing a sql query for select

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

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

  • Function returning SQL query for mutiple series in a chart

    Hi,
    I would like to know if there is a way to specify a single PL/SQL function returning the queries for multiple series in a 2D Line Flash Chart. I have multiple series in my chart that has different values in the where clause. I can write a PL/SQL function that can return all these queries in one shot. Is there anyway that I can specify this function as returning the queries for all the series in the chart?
    As an example, assume that I am using the following three queries for the series in my chart:
    select deptno, count(*) from emp where deptno = 10 group by deptno
    select deptno, count(*) from emp where deptno = 20 group by deptno
    select deptno, count(*) from emp where deptno = 30 group by deptno
    I can't write a PL/SQL function that returns a query in the multiple series syntax (SELECT link, label, series_1_value [, series_2_value [, ...]]FROM ...) as I am using an aggregate function and my where clause is different for each series.
    Thanks,
    Rupesh

    Hi Roel,
    Thanks for your reply. I am already using an analytical function (RATIO_TO_REPORT(COUNT(*)) OVER () ) in my actual report. My problem is that the query for one series differs from the other only in one where clause. I will be able to dynamically able to generate all the queries for all the series in one pl/sql function. But the chart definition screen does not allow us to define a single function that returns queries for the all the series - possibly seperated by some seperator like S1: select.... S2:select and so on.
    Regards,
    Rupesh

  • How to handle comma separated values in OLE DB Source query for a parameter variable from XML file in SSIS

    Hi,
    I am using OLE DB Source to fetch the records with Data Access Mode as SQL COMMAND which is using the below query with a parameter,
    SELECT CON.Title,CON.FirstName,EMP.MaritalStatus,EMP.Gender,EMP.Title AS Designation, EMP.HireDate, EMP.BirthDate,CON.EmailAddress, CON.Phone
    from HumanResources.Employee EMP INNER JOIN Person.Contact CON ON EMP.ContactID=CON.ContactID WHERE EMP.Title in (?) 
    In this query for the parameter I am passing the value from a variable and which is configured (XML Configuration). While passing value
    Buyer it works correctly. But while passing values Accountant,Buyer
    it is not working as expected.
    How to handle while passing such multiple values Or is it possible to pass such values or not in SSIS 2012 ?
    Kindly help me to find a solution.
    NOTE: I placed the whole query in a variable as a expression as below it is working fine.
    "select CON.Title,CON.FirstName,EMP.MaritalStatus,EMP.Gender,EMP.Title AS Designation,EMP.HireDate,EMP.BirthDate,CON.EmailAddress,CON.Phone from HumanResources.Employee EMP
    INNER JOIN Person.Contact CON ON EMP.ContactID=CON.ContactID WHERE EMP.Title in ('" + REPLACE(@[User::temp],",","','")  +"')"
    Any other solution is there ? without placing the query in a variable. May be a variable can have some limitations for no. of characters stored not sure just a thought.
    Sridhar

    Putting the whole thing into a variable is certainly a valid solution.  The other involves putting the comma delimited list into a table valued variable.
    http://gallery.technet.microsoft.com/scriptcenter/T-SQL-Script-to-Split-a-308206f3
    For an odd ball approach: 
    http://www.sqlmovers.com/shredding_multiline_column_using_xml/ .
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • How to write sql query for counting pairs from below table??

    Below is my SQL table structure.
    user_id | Name | join_side | left_leg | right_leg | Parent_id
    100001 Tinku Left 100002 100003 0
    100002 Harish Left 100004 100005 100001
    100003 Gorav Right 100006 100007 100001
    100004 Prince Left 100008 NULL 100002
    100005 Ajay Right NULL NULL 100002
    100006 Simran Left NULL NULL 100003
    100007 Raman Right NULL NULL 100003
    100008 Vijay Left NULL NULL 100004
    It is a binary table structure.. Every user has to add two per id under him, one is left_leg and second is right_leg... Parent_id is under which user current user is added.. Hope you will be understand..
    I have to write sql query for counting pairs under id "100001". i know there will be important role of parent_id for counting pairs. * what is pair( suppose if any user contains  both left_leg and right_leg id, then it is called pair.)
    I know there are three pairs under id "100001" :-
    1.  100002 and 100003
    2.  100004 and 100005
    3.  100006 and 100007
        100008 will not be counted as pair because it does not have right leg..
     But i dont know how to write sql query for this... Any help will be appreciated... This is my college project... And tommorow is the last date of submission.... Hope anyone will help me...
    Suppose i have to count pair for id '100002'. Then there is only one pair under id '100002'. i.e 100004 and 100005

    Sounds like this to me
    DECLARE @ID int
    SET @ID = 100001--your passed value
    SELECT left_leg,right_leg
    FROM table
    WHERE (user_id = @ID
    OR parent_id = @ID)
    AND left_leg IS NOT NULL
    AND right_leg IS NOT NULL
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Unable to create Spotlight query for expression

    I don't want to assume that the following Console Log entry is a Spotlight indexing issue since the PID is from MAIL however the following entry appears repeatedly every minute to five minutes:
    "12/1/10 6:33:01 PM Mail[2698] Unable to create Spotlight query for expression ([email protected]) && (kMDItemContentType == 'com.apple.mail.emlx' || kMDItemWhereFroms == 'message:*'w)"
    Why would Mail try to create a Spotlight query like this, why so often, and where should I look to correct or remove the offending source?
    BTW, the noted email address has been changed for privacy. Otherwise the syntax is exact.
    Thanks

    I, too, have been seeing this same error ever since I started syncing my mail via .mac or whatever they call it these days. The whole experience has been so problematic that I've discontinued using it, but it's taken me weeks to clean up the disaster it's made of my multiple computers.
    This issue seems to be one of the last remnants of the whole debacle, and I'd love to hear any suggestions on how to clean it up without having to do complete wipe/reinstall of everything, which is pretty much all that's left to try.

  • I want sql query for this output

    hi guys
    could u tell how can i write sql query for this out put
    i have one table like this
    ID ACCOUTID TAX
    1 1 A
    2 1 B
    3 2 C
    4 2 D
    5 3 E
    7 NULL F
    8 NULL G
    MY OUT PUT MUST BE LIKE THIS
    ID AID TAX
    2 1 A
    4 2 D
    7 NULL F
    8 NULL G
    HERE IN THIS OUTPUT I SHOULD HAVE
    MAXIMAM ID VALUE FOR A REPEATED AID VALUES
    AND
    THE ROWS AID VALUES IS NULL ALSO MUST PAPULATED IN THE OUTPUT.
    I KNOW ONE SOLUTION LIKE THIS
    SELECT MAX(ID),AID,TAX
    FROM TABLE T
    GROUP BY AID,TAX
    UNION ALL
    SELECT ID, AIC,TAX
    FROM TABLE T
    WHERE AID IS NULL;
    BUT I WANT SAME RESULT WITH OUT USING LOGICAL OPERATORS.
    COULD U PLZ TELL A SOL.

    Will this help:
    SQL> with t as
      2    (
      3      select 1 ID, 1 ACCOUTID, 'A' TAX from dual union all
      4      select 2, 1, 'B' from dual union all
      5      select 3, 2, 'C' from dual union all
      6      select 4, 2, 'D' from dual union all
      7      select 5, 3, 'E' from dual union all
      8      select 7, NULL, 'F' from dual union all
      9      select 8, NULL, 'G' from dual
    10    )
    11  --
    12  select id, ACCOUTID AID, Tax
    13  from
    14  (
    15    select t.*
    16          ,count(1)       over (partition by t.ACCOUTID) cn
    17          ,row_number()   over (partition by t.ACCOUTID order by id desc) rn
    18    from t
    19  )
    20  where cn > 1
    21  and (rn = 1 or ACCOUTID is null)
    22  /
            ID        AID T
             2          1 B
             4          2 D
             8            G
             7            F
    -- If I leave out the OR condition then you'll get this:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2    (
      3      select 1 ID, 1 ACCOUTID, 'A' TAX from dual union all
      4      select 2, 1, 'B' from dual union all
      5      select 3, 2, 'C' from dual union all
      6      select 4, 2, 'D' from dual union all
      7      select 5, 3, 'E' from dual union all
      8      select 7, NULL, 'F' from dual union all
      9      select 8, NULL, 'G' from dual
    10    )
    11  --
    12  select id, ACCOUTID AID, Tax
    13  from
    14  (
    15    select t.*
    16          ,count(1)       over (partition by t.ACCOUTID) cn
    17          ,row_number()   over (partition by t.ACCOUTID order by id desc) rn
    18    from t
    19  )
    20  where cn > 1
    21* and rn = 1
    SQL> /
            ID        AID T
             2          1 B
             4          2 D
             8            G
    --which follows the description you've given, but not the output

  • Problem writing a sql query for a select list based on a static LOV

    Hi,
    I have the following table...
    VALIDATIONS
    ID          Number     (PK)
    APP_ID          Number     
    REQUESTED     Date          
    APPROVED     Date          
    VALID_TIL     Date
    DEPT_ID          Number     (FK)
    I have a search form with the following field item variables...
    P11_DEPT_ID (select list based on dynamic LOV from depts table)
    P11_VALID (select list based on static Yes/No LOV)
    A report on the columns of the Validations table is shown based on the values in the search form. So far, my sql query for the report is...
    SELECT v.APP_ID,
    v.REQUESTED,
    v.APPROVED,
    v.VALID_TIL,
    d.DEPT
    FROM DEPTS d, VALIDATIONS v
    WHERE d.DEPT_ID = v.DEPT_ID(+)
    AND (d.DEPT_ID = :P11_DEPT_ID OR :P11_DEPT_ID = -1)
    This query works so far. My problem is that I don't know how to do a search based on the P11_VALID item - if 'yes' is selected, then the VALID_TIL date is still valid. If 'no' is selected then the VALID_TIL date has passed.
    Can anyone help me to extend my query to include this situation?
    Thanks.

    Hello !
    Let's have a look at my example:create table test
    id        number
    ,valid_til date
    insert into test values( 1, sysdate-3 );
    insert into test values( 2, sysdate-2 );
    insert into test values( 3, sysdate-1 );
    insert into test values( 4, sysdate );
    insert into test values( 5, sysdate+1 );
    insert into test values( 6, sysdate+2 );
    commit;
    select * from test;
    def til=yes
    select *
      from test
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);
    def til=no
    select *                                                                               
      from test                                                                            
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);  
    drop table test;  It's working fine, I've tested it.
    The above changes to my first idea I did because of time portion of the DATE datatype in Oracle and therefore the wrong result for today.
    For understandings:
    1.) TRUNC removes the time part of DATE
    2.) The difference of to date-values is the number of days between.
    3.) SIGN is the mathematical function and gives -1,0 or +1 according to an negative, zero or positiv argument.
    4.) DECODE is like an IF.
    Inspect your LOV for the returning values. According to my example they shoul be 'yes' and 'no'. If your values are different, you may have to modify the DECODE.
    Good luck,
    Heinz

  • Extracting the Logical sql query for the specified report  in OBIEE 11g

    Hi ,
    I want to extract the logical SQL Query for the Particular report in OBIEE 11.1.1.5.
    Any pointers related to this will be very helpful.
    Thanks,
    Sonali

    for a try please add Logical sql view to ur report it will dispaly the Logical sql for that Report..
    Hope it will helps you.

  • Oracle SQL query for getting specific special characters from a table

    Hi all,
    This is my table
    Table Name- Table1
    S.no    Name
    1          aaaaaaaa
    2          a1234sgjghb
    3          a@3$%jkhkjn
    4          abcd-dfghjik
    5          bbvxzckvbzxcv&^%#
    6          ashgweqfg/gfjwgefj////
    7          sdsaf$([]:'
    8          <-fdsjgbdfsg
    9           dfgfdgfd"uodf
    10         aaaa  bbbbz#$
    11         cccc dddd-/mnm
    The output has to be
    S.no    Name
    3          a@3$%jkhkjn
    5          bbvxzckvbzxcv&^%#
    7          sdsaf$([]:'
    8          <-fdsjgbdfsg
    10         aaaa  bbbbz#$
    It has to return "Name" column which is having special characters,whereas some special chars like -, / ," and space are acceptable.
    The Oracle query has to print columns having special characters excluding -,/," and space
    Can anyone help me to get a SQL query for the above.
    Thanks in advance.

    You can achieve it in multiple ways. Here are few.
    SQL> with t
      2  as
      3  (
      4  select 1 id, 'aaaaaaaa' name from dual union all
      5  select 2 id, 'a1234sgjghb' name from dual union all
      6  select 3 id, 'a@3$%jkhkjn' name from dual union all
      7  select 4 id, 'abcd-dfghjik' name from dual union all
      8  select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
      9  select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
    10  select 7 id, 'sdsaf$([]:''' name from dual union all
    11  select 8 id, '<-fdsjgbdfsg' name from dual union all
    12  select 9 id, 'dfgfdgfd"uodf' name from dual union all
    13  select 10 id, 'aaaa  bbbbz#$' name from dual union all
    14  select 11 id, 'cccc dddd-/mnm' name from dual
    15  )
    16  select *
    17    from t
    18   where regexp_like(translate(name,'a-/" ','a'), '[^[:alnum:]]');
            ID NAME
             3 a@3$%jkhkjn
             5 bbvxzckvbzxcv&^%#
             7 sdsaf$([]:'
             8 <-fdsjgbdfsg
            10 aaaa  bbbbz#$
    SQL> with t
      2  as
      3  (
      4  select 1 id, 'aaaaaaaa' name from dual union all
      5  select 2 id, 'a1234sgjghb' name from dual union all
      6  select 3 id, 'a@3$%jkhkjn' name from dual union all
      7  select 4 id, 'abcd-dfghjik' name from dual union all
      8  select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
      9  select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
    10  select 7 id, 'sdsaf$([]:''' name from dual union all
    11  select 8 id, '<-fdsjgbdfsg' name from dual union all
    12  select 9 id, 'dfgfdgfd"uodf' name from dual union all
    13  select 10 id, 'aaaa  bbbbz#$' name from dual union all
    14  select 11 id, 'cccc dddd-/mnm' name from dual
    15  )
    16  select *
    17    from t
    18   where translate
    19         (
    20            lower(translate(name,'a-/" ','a'))
    21          , '.0123456789abcdefghijklmnopqrstuvwxyz'
    22          , '.'
    23         ) is not null;
            ID NAME
             3 a@3$%jkhkjn
             5 bbvxzckvbzxcv&^%#
             7 sdsaf$([]:'
             8 <-fdsjgbdfsg
            10 aaaa  bbbbz#$
    SQL>

  • Crystal Reports for Eclipse - Builds wrong query for Ingres

    An Ingres user tries to use Crystal Reports for Eclipse with Ingres database. I am attaching here-with the related Ingres forum posting (  http://community.ingres.com/forum/database-drivers-apis/2567-jdbc-crystal-reports-eclipse.html ). Based on further research it appears that the crystal reports engine generates a wrong SQL query for Ingres when the table fields are dragged and dropped from the Field Explorer view to a newly created crystal report. Examining the contents of the table from the Data Explorer view seems to work just fine. Any thoughts/pointers on this issue is greatly appreciated.
    Regards,
    Usha

    Please re-post if this is still an issue to the Java Development - Crystal Reports Forum or purchase a case and have a dedicated support engineer work with you directly

  • Multiple choose for one parameter

    Hi, does Oracle Report support the multiple choose for one parameter? i used a IN statement inside my WHERE conditions as following
    Select ....
    where ....
    content.style IN (:p_style)
    (content.style is a column in table "content", and "p_style" is a bind variable)
    i want user can have multiple choises on p_style value. but in the parameter form i only can make one choise. Does any one know how to do the multi choise from parameter form? if you do, please help me. Thank you very much.
    Li

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by whl:
    Hi, does Oracle Report support the multiple choose for one parameter? i used a IN statement inside my WHERE conditions as following
    Select ....
    where ....
    content.style IN (:p_style)
    (content.style is a column in table "content", and "p_style" is a bind variable)
    i want user can have multiple choises on p_style value. but in the parameter form i only can make one choise. Does any one know how to do the multi choise from parameter form? if you do, please help me. Thank you very much.
    Li<HR></BLOCKQUOTE>
    you can do that by flowing the stap
    at first you will write a select statement
    select ...
    From ...
    where Style (colomn name) = &style1
    then you create a user parameter soupose wich name is P_style and which valus is x, y, and z you should enter another value soupose that name is 'All' (All means x + y + Z)
    then you write in after parameter form trigger...
    IF :P_style = 'All' then
    :style1 := null;
    Else :style1 := 'and style (style means your column name) = :P_style;
    end if;
    null

Maybe you are looking for