Query with negated collection.contains

Hi,
I'm trying to create a query which should find objects which do NOT belong
to a certain collection.
I've tried something like
(!_user._groups.contains(login) && (login._name == "GROUP_LOGIN"))
, but this returns the same result as with the negation:
(_user._groups.contains(login) && (login._name == "GROUP_LOGIN"))
I've compared the SQL statements of both queries (see below), they are
equal, too.
Does JDO support queries like this? If not, is there any workaround?
Here's the SQL statement of kodo:
executing statement <4958626>: (SELECT DISTINCT t0.JDOIDX, t0.JDOCLASSX,
t0.JDOLOCKX, t0.ACCOUNT, t0.CONTENT_ROLE, t0.FIRST_NAME,
t0.FRAMEWORKUSERX, t0.LAST_NAME, t0.PASSWORD, t0.RETAILER,
t0.WRONG_PWD_COUNTER, t0.ACCOUNT FROM JDOABSTRUSR t1, JDOABSTRUSR t3,
JDOUSERGROUP__USERSX t2, UUser t0 WHERE ((t3.NAME = ? AND t0.JDOCLASSX =
?) AND t0.FRAMEWORKUSERX = t1.JDOIDX AND t1.JDOIDX = t2.USERSX AND
t2.JDOIDX = t3.JDOIDX) ORDER BY t0.ACCOUNT DESC):
[reused=1;params={(String)GROUP_LOGIN,(String)de.d2vodafone.webe.fho.domain.user.User}]
Regards,
Andreas

I can't see any unbound variables in this query - the variable l is used
in contains() and it is used on the right-hand-side of contains(). Or did
I misunderstand the meaning of unbound variables?!
Regards,
Andreas
Stephen Kim wrote:
As I recall, Kodo 2.4.x doesn't handle unbound variables very well. I
would see if the query is resolved in our 2.5.2 beta (the URL is listed
in our solarmetric.kodo.beta newsgroup)
Andreas Thiel wrote:
Outcome of further experimentation:
If I use the (not negated) filter
((_user._groups.contains(l) && (l._name == "GROUP_LOGIN")))
, I get the correct, expected result with all users which are member of
the special login group with name "GROUP_LOGIN". But if I use the
(negated) filter
(!(_user._groups.contains(l) && (l._name == "GROUP_LOGIN")))
, I get a result containing all users NOT belonging to the login group
(that's ok), but in addition the result contains the users from the the
first query, too, i.e. all users belonging to the login group (that's
wrong).
My parameters: <none>
My variables:
de.d2vodafone.webe.common.security.authorization.jdo.JDOUserGroup l
My arguments: <none>
Any hints?
Cheers,
Andreas
Andreas Thiel wrote:
Hi,
I'm trying to create a query which should find objects which do NOT belong
to a certain collection.
I've tried something like
(!_user._groups.contains(login) && (login._name == "GROUP_LOGIN"))
, but this returns the same result as with the negation:
(_user._groups.contains(login) && (login._name == "GROUP_LOGIN"))
I've compared the SQL statements of both queries (see below), they are
equal, too.
Does JDO support queries like this? If not, is there any workaround?
Here's the SQL statement of kodo:
executing statement <4958626>: (SELECT DISTINCT t0.JDOIDX, t0.JDOCLASSX,
t0.JDOLOCKX, t0.ACCOUNT, t0.CONTENT_ROLE, t0.FIRST_NAME,
t0.FRAMEWORKUSERX, t0.LAST_NAME, t0.PASSWORD, t0.RETAILER,
t0.WRONG_PWD_COUNTER, t0.ACCOUNT FROM JDOABSTRUSR t1, JDOABSTRUSR t3,
JDOUSERGROUP__USERSX t2, UUser t0 WHERE ((t3.NAME = ? AND t0.JDOCLASSX =
?) AND t0.FRAMEWORKUSERX = t1.JDOIDX AND t1.JDOIDX = t2.USERSX AND
t2.JDOIDX = t3.JDOIDX) ORDER BY t0.ACCOUNT DESC):
[reused=1;params=]
Regards,
Andreas
Stephen Kim
[email protected]
SolarMetric, Inc.
http://www.solarmetric.com

Similar Messages

  • Tuning SQL query with SDO and Contains?

    I'trying to optimize a query
    with a sdo_filter and an intermedia_contains
    on a 3.000.000 records table,
    the query look like this
    SELECT COUNT(*) FROM professionnel WHERE mdsys.sdo_filter(professionnel.coor_cart,mdsys.sdo_geometry(2003, null, null,mdsys.sdo_elem_info_array(1,1003,4),mdsys.sdo_ordinate_array(809990,2087279,778784,2087279,794387,2102882)),'querytype=window') = 'TRUE' AND professionnel.code_rubr ='12 3 30' AND CONTAINS(professionnel.Ctx,'PLOMBERIE within Nom and ( RUE within Adresse1 )',1)>0
    and it takes 15s on a bi 750 pentium III with
    1.5Go of memory running under 8.1.6 linux.
    What can i do to improve this query time?
    null

    Hi Vincent,
    We have patches for Oracle 8.1.6 Spatial
    on NT and Solaris.
    These patches include bug fixes and
    performance enhancements.
    We are in the process of making these patches
    avaialble in a permanent place, but until then, I will temporarily put the patches on:
    ftp://oracle-ftp.oracle.com/
    Log in as anonymous and use your email for
    password.
    The patches are in /tmp/outgoing in:
    NT816-000706.zip - NT patch
    libordsdo.tar - Solaris patch
    I recommend doing some analysis on
    individual pieces of the query.
    i.e. time the following:
    1)
    SELECT COUNT(*)
    FROM professionnel
    WHERE mdsys.sdo_filter(
    professionnel.coor_cart,
    mdsys.sdo_geometry(
    2003, null, null,
    mdsys.sdo_elem_info_array(1,1003,4),
    mdsys.sdo_ordinate_array(
    809990,2087279,
    778784,2087279,
    794387,2102882)),
    'querytype=window') = 'TRUE';
    2)
    SELECT COUNT(*)
    FROM professionnel
    WHERE CONTAINS(professionnel.Ctx,
    'PLOMBERIE within Nom and ( RUE within Adresse1)',1) >0;
    You might want to try reorganizing the entire
    query as follows (no promises).
    If you contact me directly, I can try to
    help to further tune the SQL.
    Hope this helps. Thanks.
    Dan
    select count(*)
    FROM
    (SELECT /*+ no_merge */ rowid
    FROM professionnel
    WHERE mdsys.sdo_filter(
    professionnel.coor_cart,
    mdsys.sdo_geometry(
    2003, null, null,
    mdsys.sdo_elem_info_array(1,1003,4),
    mdsys.sdo_ordinate_array(809990,2087279,
    778784,2087279,
    794387,2102882)),
    'querytype=window') = 'TRUE'
    ) a,
    (SELECT /*+ no_merge */ rowid
    FROM professionnel
    WHERE CONTAINS(professionnel.Ctx,
    'PLOMBERIE within Nom and
    ( RUE within Adresse1)',1) >0
    ) b
    where a.rowid = b.rowid
    and professionnel.code_rubr ='12 3 30';
    **NOTE** Try this with no index on code_rubr
    null

  • How to write multi row sub query with the row containing range of values?

    Hi all,
    I have to include a column which contains weight ranges and it should come fom table called "report_range_parameters"
    The following query will reutrn those weight ranges.
    select report_parameter_min_value || ' -> ' || report_parameter_max_value
              from report_range_parameters
             WHERE report_range_parameters.report_parameter_id = 2359
               and report_range_parameters.report_parameter_group = 'GVW_GROUP'
               and report_range_parameters.report_parameter_name  = 'GVW_NAME'
                        The below query should return the values group by those weight ranges.
    How could I write that sub query?
    select   SUM(NVL("Class 0", 0)) "Class 0"  ,
                SUM(NVL("Class 1", 0)) "Class 1"  ,
                SUM(NVL("Class 2", 0)) "Class 2"  ,
                SUM(NVL(" ", 0)) "Total"
         FROM (
                 SELECT report_data.bin_start_date_time start_date_time,
                        SUM(DECODE(report_data.gvw, 0, report_data.gvw_count, 0)) "Class 0" ,
                        SUM(DECODE(report_data.gvw, 1, report_data.gvw_count, 0)) "Class 1" ,
                        SUM(DECODE(report_data.gvw, 2, report_data.gvw_count, 0)) "Class 2" ,
                        SUM(NVL(report_data.gvw_count, 0)) " "
                  FROM report_data
                 GROUP BY report_data.bin_start_date_time
              ) results
       RIGHT OUTER JOIN tmp_bin_periods
                     ON results.start_date_time >= tmp_bin_periods.bin_start_date_time
                    AND results.start_date_time <  tmp_bin_periods.bin_end_date_time
               GROUP BY tmp_bin_periods.bin_start_date_time,
                        tmp_bin_periods.bin_end_date_time Thanks.
    Edited by: user10641405 on Jun 15, 2009 3:14 PM
    Edited by: user10641405 on Jun 15, 2009 3:17 PM

    Hi,
    Assuming the following 4 things:
    (1) report_range_parameters contains data like this, from your [previous thread|http://forums.oracle.com/forums/message.jspa?messageID=3541079#3541079]
    id  group      name         min_value      max_value
    1   gvw_group  gvw_name      0              5
    2   gvw_group  gvw_name      5              10
    3   gvw_group  gvw_name     10              15(2) max_value is actually outside the range (that is, a value of exactly 5.000 is counted in the '5->10' range, not the '0->5' range)
    (3) the range has to match some column x that is in one of the tables in your main query
    (4) You want to add that column x to the GROUP BY clause
    then you shopuld do somehting like this:
    select   SUM(NVL("Class 0", 0)) "Class 0"  ,
                SUM(NVL("Class 1", 0)) "Class 1"  ,
                SUM(NVL("Class 2", 0)) "Class 2"  ,
                SUM(NVL(" ", 0)) "Total"
    ,         report_parameter_min_value || ' -> ' || report_parameter_max_value     AS weight_range          -- New
         FROM (
                 SELECT report_data.bin_start_date_time start_date_time,
                        SUM(DECODE(report_data.gvw, 0, report_data.gvw_count, 0)) "Class 0" ,
                        SUM(DECODE(report_data.gvw, 1, report_data.gvw_count, 0)) "Class 1" ,
                        SUM(DECODE(report_data.gvw, 2, report_data.gvw_count, 0)) "Class 2" ,
                        SUM(NVL(report_data.gvw_count, 0)) " "
                  FROM report_data
                 GROUP BY report_data.bin_start_date_time
              ) results
       RIGHT OUTER JOIN tmp_bin_periods
                     ON results.start_date_time >= tmp_bin_periods.bin_start_date_time
                    AND results.start_date_time <  tmp_bin_periods.bin_end_date_time
       LEFT OUTER JOIN  report_range_parameters                                        -- New
                    ON  x >= report_parameter_min_value                                    -- New
              AND x <  report_parameter_max_value                                   -- New
                    AND report_range_parameters.report_parameter_id = 2359                         -- New
                    and report_range_parameters.report_parameter_group = 'GVW_GROUP'               -- New
                    and report_range_parameters.report_parameter_name  = 'GVW_NAME'                    -- New
               GROUP BY tmp_bin_periods.bin_start_date_time,
                        tmp_bin_periods.bin_end_date_time
                  , x                                                       -- New

  • Query with aggregates over collection of trans. instances throws an error

    Hi, I'm executing a query with aggregates an it throws an exception with the following message "Queries with aggregates or projections using variables currently cannot be executed in-memory. Either set the javax.jdo.option.IgnoreCache property to true, set IgnoreCache to true for this query,
    set the kodo.FlushBeforeQueries property to true, or execute the query before changing any instances in the transaction.
    The offending query was on type "class Pago" with filter "productosServicios.contains(item)".
    The class Pago has the field productosServicios which is a List of Pago$ItemMonto, the relevant code is :
    KodoQuery query = (KodoQuery)pm.newQuery(Pago.class,
    pagos);
    where pagos is a list of transient instances of type Pago.
    query.declareVariables("Pago$ItemMonto item");
    query.setFilter("productosServicios.contains(item)");
    query.setGrouping("item.id");
    query.setResult("item.id as idProductoServicio,
    sum(montoTotal) as montoTotal");
    query.setResultClass(PagoAgrupado.class);
    where the class PagoAgrupado has the corresponding fields idProductoServicio and montoTotal.
    In other words, I want to aggregate the id field of class ItemMonto over the instances contained in the productosServicios field of class Pago.
    I have set to true the ignoreCache and kodo.FlushBeforeQueries flags in the kodo.properties file and in the instances of the pm and the query but it has not worked, what can be wrong?.
    I'm using Kodo 3.2.4, MySQL 5.0
    Thanks,
    Jaime.
    Message was edited by:
    jdelajaraf

    Thanks, you nailed it! I tried comparing the two files myself, but Bridge told me that the 72.009 dpi document was 72 dpi.
    I have no idea why the resolution mess things up, but as long as I know how to avoid the bug, things are grand!

  • Rest query with filter sub-string (contains, not eq)

    Hi,
    how can I do a REST-query with a filter for a string-column which is only a sub-string? I only found EQ, for example $filter=(name EQ 'tom') which compares the whole string.
    But I would like to query records, where a string-column CONTAINS a specific sub-string.
    Thx, Tom

    Hi Tom,
    Do you use it on azure Data Market place? Did you try to add "*" on your query string, like this
    post.
    Also, you could try this tool from this
    thread. Also, for this issue, I suggest you could post it on
    SQL forum for better support.
    If I misunderstood, please let me know.
    Regards,
    Will
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Executing query with arguments- issue when  parameter value contains '&'

    My application inserts 'First name', last name' and last upd date to the table. it inserts all the data properly. Next level I access the information along with other tables using same arguments. But it is not fetching any data. I noticed it happens whenever the '&' is included in the parameter (first name). eg:
    'Margaret & John'. From the logs I noticed that first name it is not taking what I passed. It just stripping the first name from '&' onwards and taking only 'Margaret'. Here is the example from the log. You could notice only 'Margaret' instead of 'Margaret & John' in place of first argument.
    <2007-03-29 11:35:51,425> <DEBUG> <default.collaxa.cube.ws> <Database Adapter::Outbound> <oracle.tip.adapter.db.DBInteraction executeOutboundRead> Executing query with arguments [Margaret , Cohen, 2007-03-29T11:35:51-06:00]
    Appreciate your help if you could give me a hint how to resolve this issue
    Thanks
    Reddy

    Hi Reddy,
    from the log it looks like the DbAdapter received the value as 'Margaret '. Because parameter binding is used by default, the database shouldn't try to interpret the & as it is inside a bind variable.
    Could it be that the & is getting dropped somewhere else? Marc was suggesting you put that value inside a CDATA section or escape it. He probably showed that but when he hit Post Message it displayed the escaped & as &. I think we should find out where that & got dropped though. Normally BPEL will preserve it.
    Thanks
    Steve

  • SQL Report query with condition (multiple parameters) in apex item?

    Hello all,
    I have a little problem and can't find a solution.
    I need to create reports based on a SQL query or I.R. Nothing hard there.
    Then I need to add the WHERE clause dynamically with javascript from an Apex item.
    Again not very hard. I defined an Apex item, set my query like this "SELECT * FROM MYTAB WHERE COL1 = :P1_SEARCH" and then I call the page setting the P1_SEARCH value. For instance COL1 is rowid. It works fine.
    But here is my problem. Let's consider that P1_SEARCH will contain several rowids and that I don't know the number of those values,
    (no I won't create a lot of items and build a query with so many OR!), I would like sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (:P1_SEARCH) with something like : ROWID1,ROWID2 in P1_SEARCH.
    I also tried : 'ROWID1,ROWID2' and 'ROWID1','ROWID2'
    but I can't get anything else than filter error. It works with IN with one value but as soon as there are two values or more, it seems than Apex can't read the string.
    How could I do that, please?
    Thanks for your help.
    Max

    mnoscars wrote:
    But here is my problem. Let's consider that P1_SEARCH will contain several rowids and that I don't know the number of those values,
    (no I won't create a lot of items and build a query with so many OR!), I would like sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (:P1_SEARCH) with something like : ROWID1,ROWID2 in P1_SEARCH.
    I also tried : 'ROWID1,ROWID2' and 'ROWID1','ROWID2'
    but I can't get anything else than filter error. It works with IN with one value but as soon as there are two values or more, it seems than Apex can't read the string.For a standard report, see +{message:id=9609120}+
    For an IR&mdash;and improved security avoiding the risk of SQL Injection&mdash;use a <a href="http://download.oracle.com/docs/cd/E17556_01/doc/apirefs.40/e15519/apex_collection.htm#CACFAICJ">collection</a> containing the values in a column instead of a CSV list:
    {code}
    SELECT * FROM MYTAB WHERE ROWID IN (SELECT c001 FROM apex_collections WHERE collection_name = 'P1_SEARCH')
    {code}
    (Please close duplicate threads spawned by your original question.)

  • SQL query with Bind variable with slower execution plan

    I have a 'normal' sql select-insert statement (not using bind variable) and it yields the following execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=7 Card=1 Bytes=148)
    1 0 HASH JOIN (Cost=7 Card=1 Bytes=148)
    2 1 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=4 Card=1 Bytes=100)
    3 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=3 Card=1)
    4 1 INDEX (FAST FULL SCAN) OF 'TABLEB_IDX_003' (NON-UNIQUE)
    (Cost=2 Card=135 Bytes=6480)
    Statistics
    0 recursive calls
    18 db block gets
    15558 consistent gets
    47 physical reads
    9896 redo size
    423 bytes sent via SQL*Net to client
    1095 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    I have the same query but instead running using bind variable (I test it with both oracle form and SQL*plus), it takes considerably longer with a different execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=407 Card=1 Bytes=148)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=3 Card=1 Bytes=100)
    2 1 NESTED LOOPS (Cost=407 Card=1 Bytes=148)
    3 2 INDEX (FAST FULL SCAN) OF TABLEB_IDX_003' (NON-UNIQUE) (Cost=2 Card=135 Bytes=6480)
    4 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=2 Card=1)
    Statistics
    0 recursive calls
    12 db block gets
    3003199 consistent gets
    54 physical reads
    9448 redo size
    423 bytes sent via SQL*Net to client
    1258 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    TABLEA has around 3million record while TABLEB has 300 records. Is there anyway I can improve the speed of the sql query with bind variable? I have DBA Access to the database
    Regards
    Ivan

    Many thanks for your reply.
    I have run the statistic already for the both tableA and tableB as well all the indexes associated with both table (using dbms_stats, I am on 9i db ) but not the indexed columns.
    for table I use:-
    begin
    dbms_stats.gather_table_stats(ownname=> 'IVAN', tabname=> 'TABLEA', partname=> NULL);
    end;
    for index I use:-
    begin
    dbms_stats.gather_index_stats(ownname=> 'IVAN', indname=> 'TABLEB_IDX_003', partname=> NULL);
    end;
    Is it possible to show me a sample of how to collect statisc for INDEX columns stats?
    regards
    Ivan

  • SQL query with parallel hint  running very slow

    I have a SQL query which joins three huge tables. (given below)
         insert /*+ append */ into final_table (oid, rmeth, id, expdt, crddt, coupon, bitfields, processed_count)
         select /*+ full(t2) parallel(t2,31) full(t3) parallel(t3,31)*/
         seq_final_table.nextval, '200', t2.id, t3.end_date, '1/jul/2009',123,t2.bitfield, 0
         from table1 t1, table2 t2, table3 t3 where
         t1.id=t2.id and
         t2.pid=t3.pid and
         t2.vid=t3.vid and
         t3.end_date is not null and
         (trunc(t1.expiry_date) != trunc(t3.end_date) or trim(t1.expiry_date) is null);
         Below are some statistics of the three tables.
         Table_Name          RowCount    Size(MB)
         table1 36469938 532
         table2 242172205     39184
         table3 231756758     29814
         The above query ran for 30+ hours, and returned with no rows inserted into final_table. I didn't get any error message also.
         But when I ran the query with table1 containing just 10000 records, the query completed succesfully within 20 minutes.
         Can any one please optimize the above query?
    Edited by: jaysara on Aug 18, 2009 11:51 PM

    As a side note: You probably don't want to insert a string into a date field, won't you?
    Under the assumption that crddt is of datatype date:
    crddt='1/jul/2009' needs to be changed into
    crddt= to_date('01/07/2009','dd/mm/yyyy') This is data type correct and nls independent.

  • SQL query with JSP and WML-parameters

    Hey,
    Could you help me?
    I'm trying to do the following. WML deck card 1 send parameter to same WML deck's card help. I try to read the parameter with JSP in card help by putting the parameter to SQL query, but it doesn't work. I can read the parameter with WML in card help. I can also print the value of the parameter with JSP if I generate WML with JSP.
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi' value='$(valittukurssi)'/>");
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    /'parameter read with JSP by generating WML with JSP*/
    out.println("<p>$valittukurssi</p>");
    /* SQL query with JSP */
    ResultSet uudettulokset = uusilause.executeQuery("select * from kurssi where lyhenne='$valittukurssi'");
    Thanks,
    Rampe

    You're problem is easy to fix. You're confusing WML variables with JSP variables. See below:
    >
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi'
    value='$(valittukurssi)'/>");
    Above you set a var that will work on the phone, not in JSP.
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    Yes the above does display the parameter, because it is a client side WML var, but you cannot use this variable in the JSP code (that's why your SWL fails).
    /'parameter read with JSP by generating WML with
    JSP*/
    out.println("<p>$valittukurssi</p>");Here's you're problem, the above line is EXACTLY the same as the one before it. When the container parses through this JSP code it translates the above line to:
    <p>$valittukurssi</p> on the WML page and the CLIENT uses it's local variable to display it.
    What you need and want is to have a variable that can be used in JSP code and output to your WML page. Here's how it's done:
    out.println("<go href='#helpcard'>");
    String some_name = "valittukurssi";
    out.println("<setvar name='"+some_name+"'
    value='$("+some_name+")'/>");
    //note that you may have to escape the ( and ) with a \
    //so we displayed the variable above into the WML page, now we can use it in the SQL query:
    /* SQL query with JSP */
    ResultSet uudettulokset =
    uusilause.executeQuery("select * from kurssi where
    lyhenne='"+some_name+"'");//the end of the command is: " ' " ) ;
    Frank Krul
    Got Node?

  • How can I create a query with web service data control?

    I need to create a query with web service data control, in WSDL, it's query operation, there is a parameter message with the possible query criteria and a return message contains the results. I googled, but cannot find anything on the query with web service. I cannot find a "Named Criteria" in web service data control like normal data control. In Shay's blog, I saw the topics on update with web service data control. How can I create a query with web service data control? Thanks.

    Hi,
    This might help
    *054.     Search form using ADF WS Data Control and Complex input types*
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html

  • Can I query with a select statement in the from statement

    I'm working with an application that creates a MASTERTABLE that keeps track of DATATABLEs as it creates them. These data tables are only allowed to be so big, so the data tables are time stamped. What I need to do is to be able to query the MASTERTABLE to find out what the latest datatable is and then query the specific datatable.
    I've tried
    select count(*) from (select max(timestamp) from mastertable)
    and it always comes back with a count of 1.
    Is this possible, or is there a better way?

    Well, I'm trying to understand... and if I understand, then you need something dynamic. I did create the following example, of course not exactly as yours (I don't have your data). Each employee has a table with his name, containing the sal history, and I want to query that table starting from actual sal :
    SCOTT@db102 SQL> select ename from emp where sal= 3000;
    ENAME
    SCOTT
    FORD
    SCOTT@db102 SQL> select * from scott;
    SAL_DATE         SAL
    01-JAN-85       2500
    01-JAN-95       2750
    01-JAN-05       3000
    SCOTT@db102 SQL> set serveroutput on
    SCOTT@db102 SQL> declare
      2     v_rc    sys_refcursor;
      3     tname   varchar2(30);
      4     v_date  date;
      5     v_sal   number;
      6  begin
      7     select max(ename) into tname
      8     from emp
      9     where sal = 3000;
    10     open v_rc for 'select * from '||tname;
    11     loop
    12             fetch v_rc into v_date,v_sal;
    13             exit when v_rc%notfound;
    14             dbms_output.put_line(v_date||' '||v_sal);
    15     end loop;
    16* end;
    SCOTT@db102 SQL> /
    01-JAN-85 2500
    01-JAN-95 2750
    01-JAN-05 3000
    PL/SQL procedure successfully completed.
    SCOTT@db102 SQL>                                                                          

  • "Cannot draw document with negative rows to credit note"

    Hi Experts,
    A General query :
    I create an AR invoice with two items one with qty 1 and the other with qty (-ve 1)  on posting this invoice the second item / row with negative qty gets closed automatically. Now, I require to post a AR Credit note to this invoice i get the following status error message "cannot draw document with negative rows to AR credit note" when copying to a AR Credit note and it is the same the other way when copying from
    How is it possible to create a  AR credit note to the above scenario. Any sugestions
    V.  2007A SP01 PL05
    Regards,
    Rakesh N

    Hi Rakesh N,
    version 8.8 supports fully the scenario you outline & I would recommend you upgrade to benefit from the new functionalities introduced in that version. Please have a look at the [8.8 landing page|https://service.sap.com/~sapidb/011000358700000199032009].
    Using stand-alone documents & internally reconciling in the lower versions works beautifully on the accounting side yet impacts also the stock side, where corrections in stock value & item cost must be carried out manually.
    All the best,
    Kerstin

  • Input query with dynamic actual & forecast values by month per year

    Hello,
    I am working on a Input ready query for a forecasting application which shows both actuals and forecast numbers and the user will revise the forecast numbers by month
    Requirement: I want to build a Input query for monthly forecasting for the current year. It will be dynamic rolling of months with actuals & forecast data.
    E.g. My report has 12 months for the current year
    and if run the report in May, the months before May has to show the actuals and the months after May has to show the old forecast data so that the user will revise the numbers again in each month and save the data to the real time cube.
    Jan.Feb.Mar.Apr.May.Jun.Jul.Aug.Sept.Nov.Dec
    Act Act  Act Act Act  Old frcst for the remaining months
      user will revise forecast for these months
    So, i am able to create Input query with all restricted key figures( plan kf has change mode set to change, actual kf are not set change) and calculate key figures and all the logic is done on dynamically moving/rolling the data based on the input month of the year.
    But the problem is that i am using cal kf to dynamically roll months, i was not able to set the change option for the cal kf.
    So, how can i make sure that the dynamically changed plan months will open for entering forecast and the actuals months not to change?
    Do you guys have any better solutions in implementing it?
    I really appreciate it your input....:)
    Thanks,
    Srini

    Hi,
    Please look at the following DOC which may be useful to you and if so please grant me point.
    Regards,
    SUbha'
    Input-Ready Query
    Use
    You use input-ready queries to create applications for manual planning. These can range from simple data entry scenarios to complex planning applications.
    Integration
    You define a query that you want to use for manual planning in the BEx Query Designer (see Defining New Queries).
    In the Web Application Designer or the BEx Analyzer, you can combine the input-ready queries with other queries and planning functions to create complex planning applications.
    Prerequisites
    You can define an input-ready query on any of the following InfoProviders:
    &#9679;     Aggregation levels (see Aggregation Levels)
    &#9679;     MultiProviders that include at least one simple aggregation level
    The aggregation levels are created in the planning modeler; MultiProviders are defined in the modeling functional area of the Data Warehousing Workbench.
    Features
    Definition of an Input-Ready Query
    Once you have defined a query on an InfoProvider, you see the Planning tab page under the Properties of structural components (for example, in key figures or restricted key figures). The options provided there allow you to determine which structural components of an input-ready query are to be input ready at runtime and which are not. With structural components that are not input ready, you can also determine whether these components are viewed as reference data or are just protected against manual entry.
    For the structural components, you also have the following options:
    Input readiness of structural components of a query
    Option
    Description
    Not input ready (reference data)
    If they are being used as reference data, the structural components are not protected by data locks to ensure exclusive access for one user because this data serves as a reference for many users.
    This is the default setting.
    Not input ready (no reference data)
    If you want to protect structural components against manual entries but allow changes by planning functions, you can use locks to protect this data for one particular user. In this way you can ensure that the planning function works with the displayed data only and not with data that has been changed by other users.
    Input ready
    You can also determine whether an input ready query is to be started in change mode or in display mode. You find this property in the Query Properties on the Planning tab page. If there is at least one input-ready query component, the query (as long as it has not been determined otherwise) is started in display mode.
    In BI applications that use input ready queries as data providers, you can enter data manually at runtime. For more information, see Performing Manual Planning and Creation of Planning Applications.
    Example
    You want to create an input-ready query for manual planning for a plan-actual comparison of revenues for a set of products. You want the plan data in a real-time-enabled InfoCube and the actual data in a standard InfoCube.
           1.      Create a MultiProvider that includes the InfoCubes for the plan and actual data.
           2.      Define an aggregation level on the MultiProvider which contains the characteristic Product and the key figure Revenue.
           3.      On the aggregation level, create two restricted key figures Plan Revenue and Actual Revenue. For restriction, choose the characteristic 0INFOPROV and restrict it to the plan or actual InfoCube.
           4.      Add the restricted key figures to the key figure structure. Insert Product into the rows. For Plan Revenue, choose Input Ready for the input-readiness option. For Actual Revenue, choose the option Not Input Ready (Reference Data).
           5.      In the query properties, set the indicator that determines whether the queries are started in display or change mode as required.
    Example of an input-ready query
    Product
    Plan Revenue
    Actual Revenue
    P01
    20
    P02
    30
    If you want to keep actual and plan data in a real-time enabled InfoCube, you do not require a MultiProvider for the task described above. Create an aggregation level on the InfoCube and define the input-ready query for the aggregation level. In the example above, a version characteristic acts as the InfoProvider. Create restricted key figures with the plan or actual version and proceed as in the previous example.

  • The option 'Display Credit Balance with negative sign" was not activated.

    I've encountered with a huge problem after load opening balance.
    I forgot to tick the  option 'Display Credit Balance with negative sign"
    It makes my client's Chart of Account  uncommon such as credit balance in Cash Account, AR .....
    However, I've search the sap  note to solve it  as follow:
      Description of the bug::     
    When creating the company in the system the option 'Display Credit Balance with negative sign' was not activated.
    Once transactions were created in the system the functionality can not be changed.
    Limits of the query:     
    After running the update query, please restart SBO first and then   run the restore 'GL account and bp balances';
    otherwise, the cashed value of SBO will not be updated and restore function may not take effect.
    1. Meaning of  restart SBO => restart SBO Service Manager right?
    2. Please help me please to find "The restore G/L account and bp balances" form.  Where is it?;
    Thank you

    Hi,
    I would think that you are following the PEQ instructions for note 970813, correct?
    If this is the case and you are using 2007 then you will find the restorev in the top menu; Help -> Support Desk -> Restore. You will find the functions here. Please note that this should only be used on direct instruction from support or a note like in this case. A backup should also be taken before running restore.
    Regards,
    Jesper

Maybe you are looking for

  • DVI to Video adapter TV

    My dvi to video adapter worked fine at first, when I connected to my CRT TVs. Now it is in black and white and the vertical hold keeps flipping. Tried it on two TVs same results. Tried rebooting same thing after the logon page. Help please

  • Use of project view to group project records in multi-project report

    I have a summary level multi-project report to report summary level information for active projects.  We are using project view to organize our projects between departments and divisions (hierarchical structure) - represented by folders in project vi

  • Problem running Office 2004 applications

    When I try to run any office 2004 for mac application I get the error: Microsoft Word: launch failed with error code -2855 (cfragStdFolderErr) for application /Applications/Microsoft Office 2004/Microsoft Word\n It only happens with office 2004. All

  • How to draw nice lines in faces-config.xml page flow?

    hi, I would like to be able to split the line connecting the pages in any point with a view to "beautifying" the diagram, and perhaps rearranging the flow so it looks more professional. Is that possible and how? thanks,

  • FCP5 crashes with Canopus

    If I use my ADVC 300 for more than 5 minutes, just viewing the canvas, then FCP5 crashes. Every time, consistently. Oddly, it works perfectly for monitoring the same video with Pro Tools or Logic Pro, all day long..... Anyone experienced this before?