Replace joins with normal query

hi experts ,
can u help me out splving in this issue.
i want to convert this query in to normal query I.e  with out usin gany joins .pls help me out.
select a~ebeln
        b~ebelp
        b~loekz
        a~bukrs
        a~wkurs
        a~lifnr
        a~ekorg
        a~ekgrp
        a~waers
        a~bedat
        b~txz01
        b~menge
        b~meins
        b~netpr
        b~elikz
        b~erekz
        b~wepos
        b~weunb
        b~repos
        b~webre
        b~matkl
        c~eindt
   from ekko as a
   inner join ekpo as b
   on aebeln eq bebeln
inner join eket as c
on  bebeln eq cebeln
and bebelp eq cebelp
into corresponding fields of table t_ekko_ekpo
where a~bukrs in s_bukrs
  and lifnr   in s_lifnr
  and ekorg   in s_ekorg
  and ekgrp   in s_ekgrp
  and a~bedat in s_bedat.
  and c~eindt in s_eindt.
Thanks in advance ,

Hi all,
Can someone tell me if it is possible to replace a
call like
<jbo:ShowValue datasource="dsNews"
dataitem="NisStory" /> with
String s = jbo.ShowValue(dsNews,NisStory)? Or if there
is another way to get the output of the tag into a
String?One way to do it would be to wrap the execution of <jbo:ShowValue/> with a body tag that captures its body and writes it to a variable in the pageContext. The usage would be something like:
<mytaglib:capture var="aString">
<jbo:ShowValue/>
</mytaglib:capture>
the capture tag handler would take the body content in the doAfterBody callback and expose it as "aString" in the pageContext attributes.
>
Thanks in advance.
Regards BasBr - J

Similar Messages

  • Outer Join with the query

    I have written the below query, our requirement is, Some employees have "Transport Allowance" but not "Project Allowance". For this, I tried to use OUTER JOIN with this query. But this query takes long time and failed. The following query works fine if the employee has both "Transport Allowance" and "Project Allowance" (without outer join) Now, I also need to retrieve the employees who have "Transport Allowance" but not "Project Allowance". How can I retrieve it?
    SELECT DISTINCT papf.employee_number
    , peev.screen_entry_value Transport_Allowance
    ,peev1.screen_entry_value Project_Allowance
    FROM apps.per_all_people_f papf
    ,apps.per_all_assignments_f paaf
    ,apps.pay_element_types_x petf
    ,apps.pay_element_types_x petf1
    ,apps.pay_element_types_x petf2
    ,apps.pay_element_entries_f peef
    ,apps.pay_element_entries_f peef1
    ,apps.pay_element_entries_f peef2
    ,apps.pay_element_entry_values_x peev
    ,apps.pay_element_entry_values_x peev1
    ,apps.pay_element_entry_values_x peev2
    ,apps.pay_input_values_x pivf
    ,apps.pay_input_values_x pivf1
    ,apps.pay_input_values_x pivf2
    WHERE
    papf.person_id = paaf.person_id
    AND paaf.assignment_id = peef.assignment_id
    AND paaf.assignment_id = peef1.assignment_id
    AND paaf.business_group_id = papf.business_group_id
    --Transport Allowance
    AND peef.element_entry_id = peev.element_entry_id
    AND petf.element_Name = 'Transport Allowance'
    AND pivf.element_type_id =petf.element_type_id
    AND pivf.name = 'Allowance'
    AND peev.input_value_id= pivf.input_value_id
    --Project Allowance
    AND peef1.element_entry_id = peev1.element_entry_id
    AND petf1.element_Name = "Project Allowance'
    AND pivf1.element_type_id = petf1.element_type_id
    AND pivf1.name = 'Allowance'
    AND peev1.input_value_id = pivf1.input_value_id
    AND (SYSDATE BETWEEN peev.effective_start_date AND peev.effective_end_date)
    AND (SYSDATE BETWEEN peev1.effective_start_date AND peev1.effective_end_date)
    AND (SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date)
    ORDER BY papf.employee_number
    Thanks in advance.

    I am using sames tables with alias to retrieve the columns values from the same table.
    Here is my query.
    SELECT DISTINCT papf.employee_number
    , peev.screen_entry_value Transport_Allowance
    ,peev1.screen_entry_value Project_Allowance
    FROM apps.per_all_people_f papf
    ,apps.per_all_assignments_f paaf
    ,apps.pay_element_types_x petf
    ,apps.pay_element_types_x petf1
    ,apps.pay_element_entries_f peef
    ,apps.pay_element_entries_f peef1
    ,apps.pay_element_entry_values_x peev
    ,apps.pay_element_entry_values_x peev1
    ,apps.pay_input_values_x pivf
    ,apps.pay_input_values_x pivf1
    WHERE
    papf.person_id = paaf.person_id
    AND paaf.assignment_id = peef.assignment_id
    AND paaf.assignment_id = peef1.assignment_id
    AND paaf.business_group_id = papf.business_group_id
    --Transport Allowance
    AND peef.element_entry_id = peev.element_entry_id
    AND petf.element_Name = 'Transport Allowance'
    AND pivf.element_type_id =petf.element_type_id
    AND pivf.name = 'Allowance'
    AND peev.input_value_id= pivf.input_value_id
    --Project Allowance
    AND peef1.element_entry_id = peev1.element_entry_id
    AND petf1.element_Name = "Project Allowance'
    AND pivf1.element_type_id = petf1.element_type_id
    AND pivf1.name = 'Allowance'
    AND peev1.input_value_id = pivf1.input_value_id
    AND (SYSDATE BETWEEN peev.effective_start_date AND peev.effective_end_date)
    AND (SYSDATE BETWEEN peev1.effective_start_date AND peev1.effective_end_date)
    AND (SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date)
    ORDER BY papf.employee_number
    Thanks in advance.

  • Joining with sub query not working

    Hi
    I am new with these complex queries. I am trying to join a sub query to a query as below;
    SELECT Events1.InvoiceBatch AS BatchNo, Events1.InvoiceBatchDate AS BatchDate, tblClients.Company, tblClients.ID AS ClientID, COUNT(Events1.ID) AS Invoices,
    COUNT(*) - COUNT(Events1.InvoicePrintDate) AS E, Events1.InvoiceBatchFromDate AS BatchFrom, Events1.InvoiceBatchToDate AS BatchTo, (SELECT EventID, SUM(Total) FROM tblStaffBookings AS StaffBookings WHERE StaffBookings.EventID = Events1.ID GROUP BY EventID) AS Total
    FROM tblEvents AS Events1 LEFT OUTER JOIN
    tblClients ON Events1.ClientID = tblClients.ID
    WHERE (Events1.FactoringExportDate IS NULL) OR (Events1.AccountsExportDate IS NULL) OR (Events1.InvoiceSentDate IS NULL)
    GROUP BY Events1.InvoiceBatch, Events1.InvoiceBatchDate, tblClients.Company, tblClients.ID, Events1.InvoiceBatchFromDate, Events1.InvoiceBatchToDate
    HAVING (Events1.InvoiceBatch = 5212)
    ORDER BY tblClients.Company
    I am getting these two errors;
    Msg 8120, Level 16, State 1, Line 2
    Column 'tblEvents.ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
    Msg 116, Level 16, State 1, Line 2
    Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
    What am I missing?
    Thanks
    Regards

    SELECT Events1.InvoiceBatch AS BatchNo, Events1.InvoiceBatchDate AS BatchDate, tblClients.Company, tblClients.ID AS ClientID, COUNT(Events1.ID) AS Invoices,
    COUNT(*) - COUNT(Events1.InvoicePrintDate) AS E, Events1.InvoiceBatchFromDate AS BatchFrom, Events1.InvoiceBatchToDate AS BatchTo,Total
    FROM tblEvents AS Events1 LEFT OUTER JOIN
    tblClients ON Events1.ClientID = tblClients.ID
    LEFT OUTER JOIN (SELECT EventID, SUM(Total) AS Total FROM tblStaffBookings AS StaffBookings WHERE StaffBookings.EventID = Events1.ID GROUP BY EventID) sb
    ON sb.EventID = Events1.ID
    WHERE (Events1.FactoringExportDate IS NULL) OR (Events1.AccountsExportDate IS NULL) OR (Events1.InvoiceSentDate IS NULL)
    GROUP BY Events1.InvoiceBatch, Events1.InvoiceBatchDate, tblClients.Company, tblClients.ID, Events1.InvoiceBatchFromDate, Events1.InvoiceBatchToDate,Total
    HAVING (Events1.InvoiceBatch = 5212)
    ORDER BY tblClients.Company
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page
    Says;
    Msg 4104, Level 16, State 1, Line 5
    The multi-part identifier "Events1.ID" could not be bound.
    on
    LEFT OUTER JOIN (SELECT EventID, SUM(Total) AS Total FROM tblStaffBookings AS StaffBookings WHERE StaffBookings.EventID = Events1.ID GROUP BY EventID) sb
    Regards

  • Replace taglib with normal call

    Hi all,
    Can someone tell me if it is possible to replace a call like
    <jbo:ShowValue datasource="dsNews" dataitem="NisStory" /> with
    String s = jbo.ShowValue(dsNews,NisStory)? Or if there is another way to get the output of the tag into a String?
    Thanks in advance.
    Regards Bas

    Hi all,
    Can someone tell me if it is possible to replace a
    call like
    <jbo:ShowValue datasource="dsNews"
    dataitem="NisStory" /> with
    String s = jbo.ShowValue(dsNews,NisStory)? Or if there
    is another way to get the output of the tag into a
    String?One way to do it would be to wrap the execution of <jbo:ShowValue/> with a body tag that captures its body and writes it to a variable in the pageContext. The usage would be something like:
    <mytaglib:capture var="aString">
    <jbo:ShowValue/>
    </mytaglib:capture>
    the capture tag handler would take the body content in the doAfterBody callback and expose it as "aString" in the pageContext attributes.
    >
    Thanks in advance.
    Regards BasBr - J

  • Replacing a inner join with for all entries

    Hi Team,
       In a already developed program I am replacing a inner join with select query follow up with for-all-entris and passing the data to final internal table but in both the case the result should be same then only my replacement will be correct. But my no records in both cases differs. This happening because when i am selecting data from first data base table is 32 lines. then I am doing fo-all-entries moving all the duplicate entries then the no records are four. but in final internal table i am looping the first internal table. So in final internal table the no of records are 32. But in inner join query the records are 16.So please let me know how resolve this issue?
    Thanks and REgards
    Deepa

    Hi Thomas,
      Thanks for ur suggestion.
    The solved that in below.
    In select query I did not change anything The way I had written the code was correct.
    I think many of us know how to write that how to make the performance better in that way.
    I made the change when I transfered the to final internal table.
    The original Inner join code:
    select a~field1 a~field2 a~field3 b~field2 b~field3 b~field4
               from dbtab1 as a  inner join dbtab2 as b
              on a~field1 = b~field1 into it_final where
              a~field1 in s_field1. [Field1  in both the table are key field]
    Before code:
    Sort itab1 by key-fields.
    sort itab2 by keyfields.
    loop at itab1 into wa1.
    move: wa1-field1 to wa_final-field1,
               wa1-field2 to wa_final-field2,
               wa1-field3 to wa_final-field3.
    read table itab2 into wa2 witk key field1 = wa1-field1 binary search.
      if sy-subrc = 0.
      move : wa2-field2 to wa_final-field4,
                 wa2-field3 to wa_final-field5,
                 wa2-field4 to wa_final-field6.
    append wa_final to it_final.
    endif.
    Clear : wa1, wa2, wa_final.
    endloop.
    In this case if the one key fieild value is not present there in second internal table but its there in first internal table still it will read that row with 2nd internal values having zeroes. Normally what does not happen in inner join case if the key field value will same in both the case ,then that will fetch only those rows.
    Changed Code
    loop at itab1 into wa1.
    read table itab2 into wa2 witk key field1 = wa1-field1 binary search.
      if sy-subrc = 0.
    move: wa1-field1 to wa_final-field1,
               wa1-field2 to wa_final-field2,
               wa1-field3 to wa_final-field3.
      move : wa2-field2 to wa_final-field4,
                 wa2-field3 to wa_final-field5,
                 wa2-field4 to wa_final-field6.
    append wa_final to it_final.
    endif.
    Clear : wa1, wa2, wa_final.
    endloop.
    In this case the values will read to final internal table if both key field matches.
    With Regards
    Deepa

  • Hi! Everyone, I have some problems with JOIN and Sub-query; Could you help me, Please?

    Dear Sir/Madam
    I'm a student who is interested in Oracle Database and
    I have some problems with JOIN and Sub-query.
    I hope so many of you could help me.
    if i use JOIN without sub-query, may it be faster or not?
    SELECT field1, field2 FROM tableA INNER JOIN tableB
    if i use JOIN with sub-query, may it be faster or not?
    SELECT field1,field2,field3 FROM tableA INNER JOIN (SELECT field1,field2 FROM tableB)
    Thanks in advance!

    Hi,
    fac30d8e-74d3-42aa-b643-e30a3780e00f wrote:
    Dear Sir/Madam
    I'm a student who is interested in Oracle Database and
    I have some problems with JOIN and Sub-query.
    I hope so many of you could help me.
    if i use JOIN without sub-query, may it be faster or not?
    SELECT field1, field2 FROM tableA INNER JOIN tableB
    if i use JOIN with sub-query, may it be faster or not?
    SELECT field1,field2,field3 FROM tableA INNER JOIN (SELECT field1,field2 FROM tableB)
    Thanks in advance!
    As the others have said, the execution plan will give you a better idea about which is faster.
    If you're trying to see how using (or not using) a sub-query affects performance, make the rest of the queries as similar as possible.  For example, include field3 in both queries, or ignore field3 in both queries.
    In this particular case, I guess the optimizer would do the same thing either way, but that's just a guess.  I can't see your execution plans.
    In general, simpler code is faster, and better in other ways, too.  In this case
    tableB
    is simpler than
    (SELECT field1, field2  FROM tableB)
    Why do you want a sub-query in this example?

  • Maximum number of tables that can be outer joined with one table in a query

    Hi All,
    Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
    Thanks,
    Srini

    srinu2 wrote:
    Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
    There is no limit to the number of tables you can outer join as long as you join them correctly.
    SQL> with a as
      2      (
      3      select 1 id, 2 b_key, 3 c_key from dual union all
      4      select 2 id, 1 b_key, 4 c_key from dual union all
      5      select 3 id, 3 b_key, 1 c_key from dual union all
      6      select 4 id, 4 b_key, 2 c_key from dual
      7      ),
      8      b as
      9      (
    10      select 1 id, 1 c_key2 from dual union all
    11      select 2 id, 5 c_key2 from dual union all
    12      select 3 id, 3 c_key2 from dual union all
    13      select 4 id, 2 c_key2 from dual
    14      ),
    15      c as
    16      (
    17      select 1 key1, 1 key2, '1-1' dta from dual union all
    18      select 1 key1, 2 key2, '1-2' dta from dual union all
    19      select 1 key1, 3 key2, '1-3' dta from dual union all
    20      select 1 key1, 4 key2, '1-4' dta from dual union all
    21      select 2 key1, 1 key2, '2-1' dta from dual union all
    22      select 2 key1, 2 key2, '2-2' dta from dual union all
    23      select 2 key1, 3 key2, '2-3' dta from dual union all
    24      select 2 key1, 4 key2, '2-4' dta from dual union all
    25      select 3 key1, 1 key2, '3-1' dta from dual union all
    26      select 3 key1, 2 key2, '3-2' dta from dual union all
    27      select 3 key1, 3 key2, '3-3' dta from dual union all
    28      select 3 key1, 4 key2, '3-4' dta from dual union all
    29      select 4 key1, 1 key2, '4-1' dta from dual union all
    30      select 4 key1, 2 key2, '4-2' dta from dual union all
    31      select 4 key1, 3 key2, '4-3' dta from dual union all
    32      select 4 key1, 4 key2, '4-4' dta from dual
    33      )
    34  select d.a_id, d.b_id, c.key1 as c_key1, c.key2 as c_key3, c.dta
    35  from
    36      c,
    37      (
    38      select
    39          a.id as a_id, b.id as b_id, a.c_key, b.c_key2
    40      from a, b
    41      where a.b_key = b.id
    42      ) d
    43  where d.c_key = c.key1 (+)
    44  and   d.c_key2 = c.key2 (+);
          A_ID       B_ID     C_KEY1     C_KEY3 DTA
             3          3          1          3 1-3
             4          4          2          2 2-2
             2          1          4          1 4-1
             1          2
    SQL>

  • Outer join with effective date in peoplesoft query

    Hi,
    I'm trying to join two tables using outer join. Both tables are effective dated:
    Dept_Tbl: dept_id, status, effdt
    Tips_Tbl: dept_id, tips_id, effdt
    Not all records in Dept_Tbl are in Tips_Tbl. I need to get all active depts and their most recent tips_id if they have one.
    select a.dept_id, b.tips_id
    from dept_tbl a, tips_tbl b
    where a.status = 'Active'
    and a.effdt =
    (select max(a_ed.effdt) from dept_tbl a_ed
    where a.dept_id = a_ed.dept_id
    and a_ed.effdt <= SYSDATE)
    and b.dept_id(+) = a.dept_id
    and b.effdt =
    (select max(b_ed.effdt) from tips_tbl b_ed
    where b.dept_id = b_ed.dept_id
    and b.tips_id = b_ed.tips_id
    and b_ed.effdt <= SYSDATE)
    The query only returns records that are in both tables.
    Is there a way for outer join to work with effective dates?
    Thanks in advance,
    Reg

    Here is an example of one solution. Note the use of NVL on both sides of the equal sign since both sides could be NULL in the case of the outer join
    with dept_tbl as (select 1 dept_id, SYSDATE effdt FROM DUAL),
         tips_tbl as (select 1 dept_id, NULL effdt FROM DUAL)
    select a.effdt
      from dept_tbl a,
           tips_tbl b
    where b.dept_id(+) = a.dept_id
       and NVL(b.effdt, SYSDATE) = NVL((select max(b_ed.effdt)
                                          from tips_tbl b_ed
                                         where b.dept_id = b_ed.dept_id
                                           and b_ed.effdt <= SYSDATE), SYSDATE);
    EFFDT
    5/7/2007 3:25:00 PM

  • How do I...Mimic Replacement Path with Query using Customer Variable Exits?

    Hello SDN:
    We are on BW 3.5 SP16.
    We are currently using a replacement path Query(RP) with variables
    to populate a variable in another Query(T).
    The problem we are having is with performance.
    The entry of variables in replacement path Query(RP) is optional (This is necessary there cannot be required values)
    When results from Replacement Path Query are small performance is fine. (e.g. 10 seconds)
    When results from Replacement path query are large performance suffers. (e.g. 1+ minutes)
    Users are free to leave the replacement path variables empty resulting in a large set of data to be replaced. This is the worst performance case.
    We would like to discover a way to conditionally execute the replacement path query. That is if users do not enter values for the replacement Query(RP) variables do not execute the replacement path query(RP).
    Does anyone know if this is possible within reason and in customer exit space?
    We have reviewed the situation from all angles and the requirement for the replacement path FUNCTIONALITY and the freedom for the user to leave variable values blank remains.
    I've been searching and reading SDN and SAP notes for about a week and do not find threads which address this situation.
    We are also exploring Customer variable exits to mimic replacement path functionality
    (different topic subject="How do I...Mimic Replacement Path with Query using Customer Variable Exits?")
    Any help will be appreciated
    Many thanks
    David Schuh

    My appologies-I posted this message with the wrong subject. I will repost it with appropriate subject.
    dave schuh

  • Can we perform Join operation using SQLCall with Datatabae Query

    Hi,
    I am working on Toplink SQLCall query. I am performing join operation but, it is giving error.
    so please, any can tell me . we can perform join operation using SQLCall with Database Query
    Thanking You.

    You can use joining with SQLCall queries in TopLink, provided your SQL returns all of the required fields.
    What is the query you are executing and what error are you getting?

  • Can anyone give me examples of replacement path with query?

    hi all,
    Can anyone give me examples of replacment path with query. if u have any docs pls send it across to my email id [email protected]
    thanxs
    hari

    Here is an example:
    Lets assume you have a characteristic( Say Project)  with about 30 attributes. now your requirement is to display all 30 attributes and about 10 keyfigures and another characteristic and it's attributes...
    If Project has about 25K projects in a Year,you will find its very difficult to diasply all the inofmation with one Query.(you may get disconnected from server after executing the query)..
    So firstly,create a Query1 only with Project and keyfigures.
    then create another Query2 only with Project and its attributes...here create a variable on Projeect with replacementpath and select the Query1.So you will have the Projects only from Query1.
    Create Query3 with Project and other chars.create one more variable on Project with replacementpath select Query1 result. So this Query also gets Projects from Query1...
    Now Query2 and Query3 get Projects from Query1 always...so you will have same Projects in your all 3 Queries..
    Now crate a workbook and insert 3 Queries.make sure you insert Query1 lastly.Since last inserted query will be executed first...
    You may use VBA or excel functionality if you want to see whole data in one sheet.
    Hope this helps.

  • I have a window asking: do you want to replace the existing Normal.dotm? what should i do? I'm on OSX 10.7.5 with Office 365 14.3.2 for mac 2011.

    I have a window asking: do you want to replace the existing Normal.dotm? what should i do? I'm on OSX 10.7.5 with Office 365 14.3.2 for mac 2011.

    That is not what I said.
    Normal.dotm is a template, not a .doc file. It is the template that every new document is based upon, IF you changed any of the template settings (font size or other attributes) then you will be prompted to save the changes.
    Did you? (or is this an old Windows Template)

  • SQL Server Multiple JOINS with Table Value Function - query never ends

    I have a query with 4 joins using a table value function to get the data and when I execute it the query never ends.
    Issue Details 
    - Table value function 
        CREATE FUNCTION [dbo].[GetIndicator] 
          @indicator varchar(50),
          @refDate datetime
    RETURNS 
    TABLE
    AS
    RETURN
    SELECT
    T1.Id ,T1.ColINT_1, T1.ColNVARCHAR_1 collate DATABASE_DEFAULT as ColNVARCHAR_1 ,T1.ColNVARCHAR_2 ,T1.ColSMALLDATETIME_1, T1.ColDECIMAL_1, T1.ColDECIMAL_1
    FROM TABLE2 T2
    JOIN TABLE3 T3
    ON T2.COLFKT3 = T3.Id
    AND T3.ReferenceDate = @RefDate
    AND T3.State != 'Deleted'
    JOIN TABLE4 T4
    ON T2.COLFKT4 = T4.Id AND T4.Name=@indicator
    JOIN TABLE1 T1
    ON T2.COLFKT1=T1.Id
    - Query
        DECLARE @RefDate datetime
    SET @RefDate = '30 April 2014 23:59:59'
    SELECT DISTINCT OTHERTABLE.Id As Id
    FROM 
    GetIndicator('ID#1_0#INDICATOR_X',@RefDate) AS OTHERTABLE
    JOIN GetIndicator('ID#1_0#INDICATOR_Y',@RefDate) AS YTABLE  
    ON OTHERTABLE.SomeId=YTABLE.SomeId
    AND OTHERTABLE.DateOfEntry=YTABLE.DateOfEntry
    JOIN GetIndicator('ID#1_0#INDICATOR_Z',@RefDate) AS ZTABLE
    ON OTHERTABLE.SomeId=ZTABLE.SomeId
    AND OTHERTABLE.DateOfEntry=ZTABLE.DateOfEntry
    JOIN GetIndicator('ID#1_0#INDICATOR_W',@RefDate) AS WTABLE 
    ON OTHERTABLE.SomeId=WTABLE.SomeId
    AND OTHERTABLE.DateOfEntry=WTABLE.DateOfEntry
    JOIN GetIndicator('ID#1_0#INDICATOR_A',@RefDate) AS ATABLE  
    ON OTHERTABLE.SomeId=ATABLE.SomeId
    AND OTHERTABLE.DateOfEntry=ATABLE.DateOfEntry
    Other details:
    - SQL server version: 2008 R2
    - If I execute the table function code outside the query, with the same args, the execution time is less the 1s.
    - Each table function call return between 250 and 500 rows.

    Hi,
    Calling function in general is a costly query. And definitely joining with a function 5 times in not an efficient one.
    1. You can populate the results for all parameters in a CTE or table variable or temporary table and join (instead of funtion) for different parameters
    2. Looks like you want fetch the IDs falling to different indicators for the same @Refdate. You can try something like this
    WITH CTE
    AS
    SELECT
    T1.Id ,T1.ColINT_1, T1.ColNVARCHAR_1 collate DATABASE_DEFAULT as ColNVARCHAR_1 ,T1.ColNVARCHAR_2 ,T1.ColSMALLDATETIME_1, T1.ColDECIMAL_1, T1.ColDECIMAL_1, T4.Name
    FROM TABLE2 T2
    JOIN TABLE3 T3
    ON T2.COLFKT3 = T3.Id
    AND T3.ReferenceDate = @RefDate
    AND T3.State != 'Deleted'
    JOIN TABLE4 T4
    ON T2.COLFKT4 = T4.Id AND T4.Name=@indicator
    JOIN TABLE1 T1
    ON T2.COLFKT1=T1.Id
    SELECT * FROM CTE WHERE Name = 'ID#1_0#INDICATOR_X' AND Name = 'ID#1_0#INDICATOR_Y' AND Name = 'ID#1_0#INDICATOR_Z' AND Name = 'ID#1_0#INDICATOR_W' AND Name = 'ID#1_0#INDICATOR_A' AND ReferenceDate = @RefDate.
    Or you can even simplify more depends on your requirement.
    Regards,
    Brindha.

  • Join with another table in pre-query

    Hi,
    We have a large data block and we need to order some columns based on street name for example, not id. The base table of db block contains an id_street column, and 'streets' table contains id and name.
    Ok, in pre-query trigger of that block, we have a complex logic and we dynamically build the where clause. At the end, we set the order_By clause of the block, to order the rows, for example we need to order by the 'my_date' column asc (it's a date type column), and street desc; but street NAME, not id. We don't want to use a from clause query, because the dynamically where clause logic it's complex.
    How can we join the db block table with 'streets' table in pre-query, so when constructing the order by clause to specify something like
    set_block_property('ADRESE_NEZONATE', order_by, 'my_date, name desc');where 'name' is the name of the street, from the 'streets' table.
    Is it possible in pre-query, somehow? Or, in my case where can I join with that table and use that column in pre-query at setting order by?
    Thanks!
    Edited by: Roger25 on 26.04.2013 12:31

    I understand what you say but partially.. please explain in more detail how to do that;
    How should look the adrese_nezonate block, then? I have to add a 'name' column and set copy value from item property to 'STREETS.NAME', and database_property No?
    Then the post-query trigger how should look like (the order by clause)? The post-query sends the entire query (with where/order by clauses) to the server, but in that "select... where... order by" (built dynamically) there are only columns from that block (adrese_nezonate). I need to join with streets, INSIDE that query.
    Thanks.

  • Query the new inserted but not committed row join with db

    Hi,
    I have one vo based on two EOs, one is for update and another is for reference. When inserting a new row, is there any way I can retrieve the data from the reference EM based on the join condition for the new inserted row from the reference EO. If the inserted row is committed, it is not an issue. Before the commit, the join is between the memory and db. I tried to set the VO query mode to
    ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS|ViewObject.QUERY_MODE_SCAN_UNPOSTED_ENTITY_ROW, it does not get the column values from the reference EO.
    If I use sql, I insert row in one table, then join query this table and another table, within the same transaction, I can get the new row joining with other table rows before committing the trans.
    Thx
    Hu

    I think you don't need to change the query execution mode
    check [url http://blogs.oracle.com/shay/entry/whenvalidateitem_trigger_in_ad]When-Validate-Item trigger in ADF with PPR 

Maybe you are looking for