Incorrect Where Clause being set in Master Block

I got a strange error the other day. I have 2 database blocks in a form and the blocks are based on views. So, lets say Block1 is based on View1 and Block2 is based on View2. Block1 and Block2 are also in a Master Detail relationship. So, Block B1 is the Master and Block B2 is the Child.
So, our error routine captures the last query that was run by doing a :SYSTEM.LAST_QUERY. What was interesting was that a user got Error FRM-40505 which basically means "ORACLE error: unable to perform query".
Looking at the Last Query, it basically tried to get the WHERE Clause from the View2 instead of the View1 in which case there was a problem Querying that block and thus getting Error 40505.
The where clause that is being created is actually coming from the where clause of View2 which has been set up in the Property Sheet value.
Am not putting any code here for now but if that helps, I can put some code in there.
Any help is appreciated.

If you are executing a query from one of your own buttons or some other programmatic manner be sure focus is in the master block. Remember that if you are clicking on a button, focus is moved to the button. In this case, your first line of code in the button should be something like GO_BLOCK('MY_MASTER_BLOCK')
If that doesn't help, I would recommend creating a new form. Use the Data-block and Layout Wizards to create the master block then the detail block. Allow the Wizard to create all the code needed for the relationship. Once this relationship has been created, manually create a new block. Be sure that the new block is positioned below your first two blocks. In other words:
+ Data Blocks
...+ master_block
...+ detail_block
...+ my_block
Add one text item to this new block. Set the max number of characters to 32767 and set Multiline to YES. Now create a form level, POST-QUERY trigger doing something similar to what you mentioned already doing:
:text_item1 := :system.last_query

Similar Messages

  • How to set custmer master block for posting & how to set the status .....

    < MODERATOR:  Message locked.  Please read the [Rules of Engagement|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement] before posting next time. Use an appropriate subject in your message thread. >
    Hi ...
    How to set custmer master blocked for posting & how to set the status has deleted. please provide the steps for the above two actions.
    thanks

    Hi,
    U can use T-code FD05 for Blocking the customer and
    T-code FD06 in order to set for deletion,
    Assign Points if useful,
    Regards,

  • Function in where clause being executed in subquery

    Oracle version 9.2.0.8
    I have a query of the form
    select cola
          ,colb
          ,expensive_function(colb) as colc
      from t
    where cola between 1 and 100This query returns 100 rows very fast.
    When I try to specify a where clause that uses the result of the expensive function the query takes 60 times longer (60 secs). Table t has a million rows.
    Long Query:
    select *
      from (
        select cola
              ,colb
              ,expensive_function(colb) as colc
          from t
         where cola between 1 and 100) t
    where colc = 'XXX'Could it be that Oracle is executing the function for each row in table t? I only want the function executed on the resultset but I can't seem to get it to work.
    Have tried many different hints and forms of the query without success, e.g.
    select *
      from (
        select cola
              ,colb
          from t
         where cola between 1 and 100) t
    where expensive_function(colb) = 'XXX'
    select /*+ NO_PUSH_PRED(t) */ *
      from (
        select cola
              ,colb
          from t
         where cola between 1 and 100) t
    where expensive_function(colb) = 'XXX'Message was edited by:
    SamB

    <s></s>Compare planing of two SQL, and post what is difference?
    @?/rdbms/admin/utlxplan
    explain plan for
    select cola
          ,colb
          ,expensive_function(colb) as colc
      from t
    where cola between 1 and 100
    @?/rdbms/admin/utlxpls
    explain plan for
    select *
       from (
        select cola
              ,colb
              ,expensive_function(colb) as colc
          from t
         where cola between 1 and 100) t
    where colc = 'XXX'
    @?/rdbms/admin/utlxpls
    explain plan for
    select cola
          ,colb
      from t
    where cola between 1 and 100
        and expensive_function(colb)='XXX'
    @?/rdbms/admin/utlxpls                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • VO returning rows though where clause is set to 1=2

    Hi,
    I have a method in AMImpl class with following code
    public void reset()
    testVO vobj = gettestVO1();
    vobj.setwhereclause("1=2");
    vobj.executeQuery() ;
    System.out.println("Query ="+vobj.getQuery().toString());
    System.out.println("Fetched Row Count = "+vobj.getFetchedRowCount());
    System.out.println("Row Count = "+vobj.getRowCount());
    And I'm calling this method from Process Form request method on click of a submit button. When I run the page and click on the button the sop messages shows fetched row count = 2 and row count = 2. But if I execute the query that i got from the sop in sql developer it doesn't returns any rows.
    I'm trying to make the vobj return no rows.
    Can anyone please tell me what is going wrong.
    Thanks
    Sunny

    Hi Gyan,
    I'm getting the same query before and after executing. And here is it.
    SELECT XXCEDPmtRqstLineEO.SUNDRY_LISTING_NUMBER, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_NUMBER, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_PAYEE, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_DESC, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_ADDR, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_CITY, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_STATE, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_ZIP, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_PROJECT, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_TASK, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_EXP_TYPE, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_AMOUNT, XXCEDPmtRqstLineEO.SUNDRY_REQUEST_LINE_ORG, XXCEDPmtRqstLineEO.TIN, XXCEDPmtRqstLineEO.CREATED_BY, XXCEDPmtRqstLineEO.CREATION_DATE, XXCEDPmtRqstLineEO.LAST_UPDATE_DATE, XXCEDPmtRqstLineEO.LAST_UPDATED_BY, XXCEDPmtRqstLineEO.LAST_UPDATE_LOGIN FROM XXCED_AP_SUNDRY_PMT_RQST_LINE XXCEDPmtRqstLineEO WHERE (1=2)
    the row count still shows as 2.
    Thanks
    Sunny

  • Where Clause in Table Lookups for Data Load

    Hello,
    In Shared Components I created in Data Load Table. In this Data Load Table I added a Table Lookup. On the page to edit the Table Lookup, there is a field called Where Clause. I tried to add a Where Clause to my Table Lookup in this field but it seems that it has no effect on the Data Load process.
    Does someone know how to use this Where Clause field?
    Thanks,
    Seb

    Hi,
    I'm having the same problem with the where clause being ignored in the table lookup, is this a bug and if so is there a work around?
    Thanks in advance

  • Using a Dimension/ Measure in a Where clause of Another Dimension/ Measure in IDT

    Hi All
    I am building a Universe using Information Design Tool. In the Business Layer, I need to use a created Business Layer Dimension (not Tables) in a Where clause of another dimension as follow:
    Dimension: "Current Week No"
         SELECT
              budgets.dbo.Calenderweeks.WeekNo
         WHERE
              budgets.dbo.Calenderweeks.EndDate = convert(SMALLDATETIME, fn CURDATE()})  
    Dimension: "Last Week No"
         SELECT
              budgets.dbo.Calenderweeks.WeekNo
         WHERE
              budget.dbo.Calenderweeks  .WeekNo = @Select(Dimension\Current Week No) - 1
    The first dimension is working well. However, the "Last Week No" shows NOTHING (I do not get any value)
    Anyone can explain why I am not get any value from the second dimension, and how I can use a Dimension/ Measure in a Where clause of another Dimension/ Measure ?
    Thanks

    Short answer:
    Beware of object WHERE clauses. They are rarely (I'd almost say never) the solution to the problem you're trying to solve.
    Long answer:
    It doesn't work because you are inadvertently filtering the same value twice in two incompatible ways in the same SQL statement.  Both objects SELECT the same column in the database.  The first object uses a WHERE clause to set it to the current week.  The second object attempts to use a WHERE clause to set it to the previous week, but does so by selecting the first object, so you end up with both objects in your data provider.
    Remember that BO is going to place all the objects in your data provider in the same SQL (except of course where your context definition has ensured otherwise.), so you have two WHERE clauses in your generated SQL which attempt to find a line equal both the current week and the previous week... and returns, naturally, no results.
    Rewrite it with a derived table (as explained in the response above) and you'll get what you want.

  • PreparedStatement.setDate(int, Date) problem in WHERE clause

    Hello all,
    First and foremost, thanks for the help. It is really appreciated.
    I am having the toughest time tracking down a problem with how I am handling date setting with my PreparedStatement. The kicker is that I am only having problems with the where clause date sets.
    The date is pulled out of the database, put into a string, modified, put back into a date, and then used to query via SQL.
    Data selected this way:
    "SELECT * FROM table_name"
    Data updated this way:
    "UPDATE table_name SET name = ? WHERE pk_id = ? AND pk_date = ?"
    The java.sql.Date object I use to PreparedStatement.setDate(int, Date) is exact to seconds. It works great if it is not in the where clause (eg Inserts work, Updates work without where clause) which leads me to believe there is truncation of data somewhere between setDate(int, Date) and the native SQL in Oracle 9i.
    Is that a correct assumption? How do I solve this?
    Thanks,
    John

    My assumption was correct. If a java.sql.DATE is pulled from a Oracle 9i database it may have more data in it than is allowed for in java.sql.Date. java.sql.Timestamp, on the other hand, does retain all data in the field.
    The correct code looks something like this
    prepStmt.setTimestamp(Timestamp.valueOf(timeString));
    cheers,
    John

  • Dynamically changing the WHERE clause in detail VO in Master Detail

    Hi, I want to develop a search functionality, results will be in a table, which will have an inline table displaying the details per row found.
    I have a MD defined trough viewlink. I do change the master VO at runtime (set the entire SQL), based on the criteria entered by the user.
    Is there a way to change the VO at the detail end of the link at runtime - that is what I haven't been able to do.
    I have read that the ADF framework creates internal VO for each master row, whenever accessed trough accessor (which is not I am trying to do). I haven't been able to find a way to get a hold of the REAL VO at the detail end and have its WHERE clause changed.
    Changes to the "VO instance in AM" (same one used as a definition in the detail end in the ViewLink def) does not seem to reflect the detail VO.
    I have a MasterView, DetailView, MasterDetailLink (MasterView->DetailView).
    MasterDetailLink is used to create a table with inline detail table. At runtime:
    1.get MasterView (from AM), change query trough setQuesry() - works.
    2.get DetailView (from AM), change query trough addWhereClause() - does not work (no exceptions) - the results I am getting DO NOT reflect the conditions of the where clause, I mean the clause have not been addedd.
    I 've looked at the logs (debug enabled) and it seems to me that there no "activities" related to the detail VO, even after the where clause of the VO from step 2 is changed.
    Looks like there is a separate VO which I would like to get a hold of :)
    Thanks, and sorry for the long explanation

    After you have added a new where clause on the detail VO, try re-executing VO's query by DetailVO.executeQuery()
    If it doesn't work try re-executing the MasterVO's query after you have added the where clause on the detail

  • How to set the where clause of a value set on the basis of a form field

    I am using a DFF(Descriptive FlexField), which needs to display the value of a certain column(say columnA) on the basis of the value of another column(say columnB).
    So i have created a value set which points to the table which has both these columns, and the DFF uses this value set. However, the problem is that I have not put any where clause in the value set, because of which i cannot handle the exact fetch returns more than one rows error.
    The query has to be as follows:
    select ColumnA from tbl where ColumnB = [ a form value ];
    What I want to know is how can i get the value of a certain field of a certain block of the form in the above query.
    Edited by: 981615 on Jan 14, 2013 12:48 AM
    Edited by: 981615 on Jan 14, 2013 12:48 AM

    Just have a look over these two statements if it solves your problem
    one time where clause
    Set_Block_Property('BLOCK_NAME',ONETIME_WHERE,your form item);
    dynamic where clause
    set_block_property('BLOCK_NAME'default_where, your form itme)
    you can where clause at run time from any procedure or some triggers

  • Null global variable in block's WHERE clause - no records?

    I'm setting a :GLOBAL.emp_id in certain spots in my form. The EMPLOYEE block's WHERE clause says emp_id = :GLOBAL.emp_id. In the POST-QUERY, it sets that variable back to NULL so the next time they want to run a blind query, it will show all records.
    Well when the :GLOBAL.emp_id is NULL, nothing comes up in a blind query. I even changed the WHERE clause to say emp_id = NVL(:GLOBAL.emp_id,'') but that didn't do anything either.
    How can I get the WHERE clause to (basically) do nothing when that global variable is null? Or should I be messing with DEFAULT_WHERE instead of these global variables
    I'm in 6i

    I'm sorry - I stumbled on something soon after I posted and changed it to:
    emp_id = NVL(:GLOBAL.emp_id,emp_id)
    and it worked - duh

  • Where Clause in the block not executed

    I have this in the where clause in my block, I want to exclude managers. I have added a flag column IS_MGR to prs_employee_profile and I added this line to query(where IS_MGR <> 2) “ value 2 for true” and but it doesn’t work. prs_amp_profile is the emp table and this block is based on atn_emp_week , emp_id is a foreign key. all the conditions are working except for the one i added and it is still bring the records for the managers. Any body can tell me why the condition is not being forced.
    Original Where Clause
    1=1 AND (emp_id in (select id from prs_employee_profile where
    dpt_id in (select dept_id from prs_user_dept_priv where user_id = :global.usr)
    and emp_id = decode(:global.emp_user_flag, 1, id, :global.emp_id)
    and emp_sts_id in (select id from prs_employment_status where active_flag <> 0))
    OR :GLOBAL.GRP='ATN_ADM')
    After adding
    1=1 AND (emp_id in (select id from prs_employee_profile where IS_MGR <>2
    And dpt_id in (select dept_id from prs_user_dept_priv where user_id = :global.usr)
    and emp_id = decode(:global.emp_user_flag, 1, id, :global.emp_id)
    and emp_sts_id in (select id from prs_employment_status where active_flag <> 0))
    OR :GLOBAL.GRP='ATN_ADM')

         1=1
    AND (    emp_id in (select id
                          from prs_employee_profile
                         where IS_MGR!=2
                           And dpt_id in (select dept_id
                                            from prs_user_dept_priv
                                           where user_id = :global.usr
                           and emp_id = decode(:global.emp_user_flag, 1, id, :global.emp_id)
                           and emp_sts_id in (select id
                                                from prs_employment_status
                                               where active_flag!=0)
          OR :GLOBAL.GRP='ATN_ADM'
        )I don't know your table-structures, one possibility would be that :GLOBAL.GRP is ATN_ADM at testing for this overwrites the other conditions.
    I would try to check the condition in sql*plus, apply it to the block when its working.

  • Where clause in Master-Detial (BC4J+uiXML)

    Hi All,
    I have used uiXML + BC4J. I have problems again.
    I create two ViewObjects PlannerVO and ObjectiveVO,its have ViewLink Planner-0..1 to Objective - * ,which like master-detial pattern ,and join by EN Attribute (its have common fileds both).
    I create uiXML for BC4J by wizard. First i can render it and can click next or browse. Now I would like to pass parameter for filter it by where clause on master (PlannerVO). like this
    http://10.50.0.152:8988/Workspace4-TestBG-context-root/Planner2Objtive_View.uix?en=002182
    in Planner2Objtive.uix on the last line code I write more my tag , this is
         <event name="*">
              <bc4j:findRootAppModule name="Planner2ObjtiveAppModule">
                   <bc4j:findViewObject name="PlannerVO">
                        <method class="mypackage.ViewFilter" method="filterByEn"/>
                   </bc4j:findViewObject>
              </bc4j:findRootAppModule>
         </event>and in ViewFilter.java
    public class ViewFilter  {
      static public EventResult filterByEn(
        BajaContext   context,
        Page          page,
        PageEvent     event) throws Throwable
        EventResult result = new EventResult(page);
        // Check for event parameters that we care about
        if (event != null)
         String en = event.getParameter("en");
         ViewObject view = ServletBindingUtils.getViewObject(context);
         view.setWhereClause("Planner.EN = "+en);
         view.executeQuery();
          // Shove the value on the EventResult so we
          // can reference it from our UIX page
          result.setProperty("en", en);
        return result;
    }I get EN from URL and then pass it to uiXML and to Java for query BC4j Object,it not return any thing. In debug windows ,its have to query first for PlannerVO and second for ObjectiveVO ,on second query ObjectiveVO I see it pass null to second query (becuase of its must pass EN attribute from master PlannerVO to join it). What this its mean, first query has not success? or in this method can not filter by where clause.

    I am not sure I understand your problem.
    What I do see is that there is no event on your url:
    Planner2Objtive_View.uix?en=002182
    so your check:
    if (event != null)
    will always be false.
    If you port the uiXML fragment that you use to create the url, I can tell you how to set an event on it.

  • Where clause one query not being pushed down

    I am having a problem where I cannot get a certain "optional" parameter to be pushed down to a query. The parameter gets applied in memory after the result set is returned but not pushed down to the DB. The function is as follows:
    declare function getFoo($key as xs:string, $optinalInput as xs:string*) as element(b:bar)*
    for $foo in f:getFoo()
    where $key = $foo/key
    where not(exists($optinalInput)) or $foo/optional = $optinalInput<- does not get pushed down to the query
    return $foo
    If I make optinalInput an xs:string instead of xs:string * and the optional parameter will get pushed to the query. The problem is for this optional parameter I could get anywhere from 0-50 in the sequence. Seems like when the parameter is a sequence it doesn't get applied to the query. Is there any way around this?

    Mike,
    I understand the difference between * and ? and I was one of the people working on the "string-length not getting pushed" problem so I am very familiar with it. I tried you solution that you mentioned below and it still did not push the where clause to the query. I know I could achieve this with an ad-hoc query but I wanted to do a pure xquery implementation of this component because of the benefits it could have when interacting with other components in our ODSI project...such as SQL joining and potentially pushing additional where clause down from components that call this component. The only way I did get this to kind of work is to do this:
    return
    for $o in $optinalInput
    for $foo in f:getFoo()
    where $key = $foo/key
    where $o = $foo/optional
    return
    $foo
    for $count in 1
    where not(exists($optinalInput))
    for $foo in f:getFoo()
    where $key = $foo/key
    return
    $foo
    By putting the optional parameter into a FOR statement above the table call it guarantees that at least one will exists and that's why the optional parameter gets pushed properly to the DB with a parameterized query. The problem with this is that even though a parameterized query gets pushed it will call the SQL statement multiple times!...not good.
    Another solution that was suggested to me would be to create the number of sequences for each item in the sequence and treat each item as it's own. For example if you know that the schema limits the sequence from 0..50 then you could make 50 items and 50 where clauses....probably not an optimal solution either but it would achieve properly pushing the where clause tot he DB.
    For now I am satisfied with this optional parameter not being pushed to the DB because the performance was still good but it would be nice if there was a maintainable pure xquery solution to this problem.
    Thanks for the help it's always appreciated!
    Mike

  • Change block where clause !!

    hello !!
    i wanna change the where clause of the data block in the runtime !!
    i know that it can by Set_block_property
    but it don't work with me !!!
    can u give me an example for that !!
    and what is the differance between default_where and onetime_where ,,, a two attributes in the set_block_property !!

    and what is the differance between default_where and onetime_where ,,, a two attributes in the set_block_property !!Default_where remains with the block for every query until you change it using pl/sql. The onetime_where is set null automatically immediately after a single query is executed.
    Look up the on-line help for Set_Block_Property on default_where and onetime_where, then click the onetime_where link, and read that.

  • JSP, DataWebBean: How to dynamically set the where clause of query and display record

    Hi,
    I am reposting this question as per suggestions made by Mr. Dwight.
    I have used ViewCurrentRecord web bean to display records from EMP table. I have to use the Dept_Id_FK from the current
    record of the EMP table to display corresponding records of Dept table. I have a view object called DeptView in my Business
    Components which selects all the records from the Dept table.
    How do I get the value of Dept_Id_FK and use it to display the required records of the Dept table?
    I tried to declare a variable and get the value of Dept_Id_FK but it did not work. My code is as follows:
    <%! String m_DeptId = null; %>
    <jsp:useBean id="RowViewer" class="oracle.jbo.html.databeans.ViewCurrentRecord" scope="request">
    <%
    RowViewer.initialize(pageContext, "EMPApp_EMP_EMPAppModule.EMPView1");
    RowViewer.setReleaseApplicationResources(false);
    RowViewer.getRowSet().next();
    m_DeptId = (String)RowViewer.getRowSet().getCurrentRow().getAttribute("DeptIdFk");
    %>
    </jsp:useBean>
    Thanks.
    null

    First of all, Thank you very much for making use of the new topic format. It is very much appreciated.
    As for your question, I think there are several different ways to accomplish what I think you want to do.
    1. Create a view object that includes both Emp and Dept entities and join them there. In this case, your query would look something like this:
    Select e.empno,e.name,...,d.dname,d.loc from emp e, dept d
    where e.deptno = d.deptno
    You should be able to create a JSP off of this view object that contains both the employee and department information. In this case, BC4J takes care of the foreign key to primary key coordination.
    2. In order to set a dynamic where clause for a view, you need to do the following in your usebean tag:
    rsn.initialize(application,session, request,response,out,"DeptView");
    rsn.getRowSet().getViewObject().setWhereClause("deptno=" &#0124; &#0124; m_DeptId);
    rsn.getRowSet().getViewObject().executeQuery();
    rsn.getRowSet().first();
    You will need to do this in a separate usebean tag from the EmpView, since the usebean can only initialize one view object.
    In other words, you would have your ViewCurrentRecord bean tag for the EmpView, then a separate one for the DeptView where you use the above code to set the where clause to display just the information for the department you want.
    Another option, but one I'm not sure would work as well, is to create a master-detail JSP to do this for you. Usually a master-detail is a one-to-many (one department to many employees). Your request appears to be the reverse, but might still be doable using the same mechanism.
    You set up relationships between views in your BC4J project using View Links. If you used the BC4J project wizard and created default views, some of these links may have been created for you. They are created when BC4J detects a foreign key to primary key relationship in the database.
    You can create your own View Links using the View Link wizard. Select your BC4J project node and choose Create View Link... from the context menu. You will be asked to select a source view (Emp), and a target view (Dept), then select the attribute in each view that related the two of them (deptno).
    Next, you need to reflect this new relationship setting in your application module. Select your app module and choose Edit from the context menu. On the data model page, select the EmpView node in the Selected list. Now select the DeptView node in the available list and shuttle it over. You should see DeptView1 via yourlink appear indented under the EmpView node. Save and rebuild your BC4J project to reflect the changes.
    In your JSP project, you can now have the wizard create a master-detail form for you based on DeptView1.
    Let me know if the above answers your question, or if I have misunderstood what it is you wanted to do.
    null

Maybe you are looking for