Duplicate records for Dynamic Query in WLS 7

I am getting duplicate records back when I run a dynamic query. If I run the same
query via a finder method, I get the correct results.
Here's the query:
SELECT DISTINCT OBJECT(a) FROM Company AS a, b IN a.userRole WHERE b.userId = ?1
AND a.deptId IN ('1', '2', '3')
Company EJB maps to LU_Company (look up table for company)
Company to UserRole is a one-to-many relationship.
The number of duplicates is equal to the number of records I have for the same company_id
in User_Role table.
The ids for the object I should get back are 1, 2, 3.
Instead I get back 1, 1, 2, 2, 2, 2, 2, 3, 3, 3
In the database, company_id 1 occurs twice in user_role table; company_id 2 occurs
five times.
Any ideas of why the dynamic query has this problem whereas the same query for a
finder method works fine?
Thanks for your help.

Thanks Greg, that worked!
"Greg Nyberg" <greg.nyberg.at.objectpartners.com> wrote:
You can supply properties on the query request, perhaps there is a
SQL_SELECT_DISTINCT property:
Properties p = new Properties();
p.setProperty("GROUP_NAME", "fieldgroup");
p.setProperty("INCLUDE_UPDATES", "true");
p.setProperty("SQL_SELECT_DISTINCT", "true");
Collection people = myQuery.find(
"SELECT OBJECT(o) FROM PersonCMPEJB o WHERE o.lastName = 'Smith'", p);
-Greg
Check out my WebLogic 6.1 Workbook for O'Reilly EJB Third Edition
www.amazon.com/exec/obidos/ASIN/1931822468 or www.titan-books.com
"Mike" <[email protected]> wrote in message
news:[email protected]...
Matt,
<sql-select-distinct> needs to be set in <weblogic-query> element. I amgenerating
a dynamic query from within a local client. So I don't have a finderdefined for
this method. (I don't want to define a finder for this method). How doyou suggest
I can use this? Thanks again for your help.
Matthew Shinn <[email protected]> wrote:
Hi Mike,
I just filed a bug report for this (CR079471). As a work around, you
can
use the
setSQLSelectDistinct flag so the database will weed out the duplicates.
The only thing to
look out for when using this flag is that Oracle will not allow the use
of 'SELECT DISTINCT'
in conjunction with a 'FOR UPDATE' clause, thus,<sql-select-distinct>True
CANNOT be used if
any Bean in the calling chain has a method with <transaction-isolation>
set to
<isolation-level>TRANSACTION_READ_COMMITTED_FOR_UPDATE. Sorry for theinconvenience.
- Matt
Mike wrote:
I am getting duplicate records back when I run a dynamic query. If
I
run
the same
query via a finder method, I get the correct results.
Here's the query:
SELECT DISTINCT OBJECT(a) FROM Company AS a, b IN a.userRole WHERE
b.userId
= ?1
AND a.deptId IN ('1', '2', '3')
Company EJB maps to LU_Company (look up table for company)
Company to UserRole is a one-to-many relationship.
The number of duplicates is equal to the number of records I have forthe same company_id
in User_Role table.
The ids for the object I should get back are 1, 2, 3.
Instead I get back 1, 1, 2, 2, 2, 2, 2, 3, 3, 3
In the database, company_id 1 occurs twice in user_role table;
company_id
2 occurs
five times.
Any ideas of why the dynamic query has this problem whereas the same
query
for a
finder method works fine?
Thanks for your help.

Similar Messages

  • Need to include duplicate records in sub query

    Hi All,
             I am using the following query and i am getting error message that your sub query return dupliate records and throwing error. Actually i need these duplicate records for my report. I want to get records for
    whole year like
       JAN FEB MARCH ..   ...    ...
    and idea how i can achieve this task and my query is as follows
     select pmnum
     ,SITEID,
     (select description from locations where pm.location = locations.location and pm.siteid=locations.siteid) as site,
     (select description from commodities where commodities.commodity=  pm.commoditygroup) as workcategory,
     description, (select wonum from workorder where workorder.pmnum = pm.pmnum
     and  targstartdate < '2013-02-01') as jan,
     (select wonum from workorder where workorder.pmnum = pm.pmnum and
     workorder.status<>'CAN' and targstartdate >= '2013-02-01' and
     targstartdate < '2013-03-01') as feb,
     (select wonum from workorder where workorder.pmnum = pm.pmnum and
     workorder.status<>'CAN' and targstartdate >= '2013-03-01' and
     targstartdate < '2013-04-01') as mar
    (select name from companies where companies.company = pm.vendor) as contractor 
           from pm  where ((PM.siteid = 'AAA'))

    Subqueries in the SELECT column list must return a scalar value (single row, single column).  If you need multiple rows returned, use a join instead.  But you need to consider what will happen when more than one row is returned by more than one
    of the joins because these are correlated with the pm table row but not each other.  For example, let's say you have a single row returned from "pm" matching 5 sites and 3 workcategories.  This will result in 15 rows being returned for the single
    pm row.
    Below is an untested example.
    SELECT
    pmnum
    ,SITEID
    ,locations.description as site
    ,commodities.description as workcategory
    ,pm.description
    ,workorder_jan.wonum AS jan
    ,workorder_feb.wonum AS feb
    ,workorder_mar.wonum AS mar
    ,companies.name AS contractor
    FROM dbo.pm
    LEFT JOIN dbo.locations ON pm.location = locations.location
    AND pm.siteid=locations.siteid
    LEFT JOIN dbo.commodities ON commodities.commodity = pm.commoditygroup
    LEFT JOIN dbo.workorder AS workorder_jan ON workorder_jan.pmnum = pm.pmnum
    AND workorder_jan.targstartdate < '2013-02-01'
    LEFT JOIN dbo.workorder AS workorder_feb ON workorder_feb.pmnum = pm.pmnum
    AND workorder_feb.status <> 'CAN'
    AND workorder_feb.targstartdate >= '2013-02-01'
    AND workorder_feb.targstartdate < '2013-03-01'
    LEFT JOIN dbo.workorder AS workorder_mar ON workorder_mar.pmnum = pm.pmnum
    AND workorder_mar.status <> 'CAN'
    AND workorder_mar.targstartdate >= '2013-03-01'
    AND workorder_mar.targstartdate < '2013-04-01'
    LEFT JOIN dbo.companies ON companies.company = pm.vendor
    WHERE pm.siteid = 'AAA';
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • Duplicate Records in ABAP Query

    I have prepared ABAP query with tables KNA1, KNB1, BSID. I have mapped only BUKRS and KUNNR from BSID . as I don't have any condition to map the fields. I want only one record for considering  KUNNR and BUKRS in report . But in report It is displaying all entries from BSID considering BUKRS and KUNNR means for documents all line items.Kindly suggest as soon. How to avoid such duplicate records

    Hi,
    Duplicate Records in ABAP Query
    Regarding on your problem,
    Use these link, It will helps to your post
    ABAP Querry Duplicate entries
    Regards,
    Sekhar

  • How to create custom BOL object for dynamic query in CRM 7.0

    Hi,
    Could anyone please explain me with steps that how to create the custom BOL object for dynamic query in CRM 7.0, I did it in previous version but its throwing exception when i try to create the object of my dynamic query class. I just defined the entry of my in crmv_obj_btil to create the dynamic query BOL object. do i need to do any other thing also to make it work?
    Regards,
    Kamesh Bathla
    Edited by: Kamesh Bathla on Jul 6, 2009 5:12 PM

    Hi Justin,
    First of thanks for your reply, and coming to my requirement, I need to report the list of items which are there in the dynamic select statement what am getting from the DB. The select statement number of columns may vary in my example for different countries the select item columns count is different. For US its '15', for UK it may be 10 ...like so, and some of the column value might be a combination or calculation part of other table columns (The select query contains more than one table in the from clause).
    In order to execute the dynamic select statement and return the result i choose to write a function which will parse the cursor for dynamic query and then iterate the values and construct a Type Object and append it to the pipe row.
    Am relatively very new for these sort of things, welcome in case of any suggestions to make it simple (Instead of the function what i thought to work with) also a sample narrating the new procedure will be appreciated.
    Thanks in Advance,
    mallikj2.

  • Re: relationship caching for dynamic query finder

    "Carlos Muchiutti" <[email protected]> wrote:
    I have the same scenario ... is there an answer for this?
    "Haoguang" <[email protected]> wrote in message
    news:3e2e64af$[email protected]..
    Is there any way to using the relationship caching defined in thedeployment descriptor
    for the dynamic query?
    I suppose it should be one of the properties passed to the query findmethod (Query.query.find(String,
    Properties)).
    I was unable to locate any documentation or examples for the question.
    What is the key set the Properties? I know the "GROUP_NAME" is one,which
    I found
    via Google. Bravo to the documentation of bea!
    ps, We are using Weblogic 7 with sp1.
    Your help or comments will be appreciated.
    Try the stuff described in:
    http://e-docs.bea.com/wls/docs70/ejb/EJB_environment.html#1151177

    There is no information related to dynamic query finder with relationship caching.

  • Ignore duplicate records for master data attributes

    dear  experts ,
                   how & where can i  enable "ignore duplicate records" when i am running my DTP to load data
                     to master data attributes.

    Hi Raj
    Suppose you are loading master data to InfoObject and in PSA you have more than one records for Key.
    Let's assume you are loading some attributes of Document NUmber ( 0DOC_NUMBER) and in PSA you have multiple records for same document number. In PSA this is not a problem, as Key for PSA table is technical key and which is different for every record in PSA. But this is a problem for InfoObject attribute table as more than  one records for primary key ( here 0DOC_NUMBER) will create Primary Key consraints in database.
    This issue can be easily avoided by selecting "Handle Duplicate Records" in DTP . You will find this option under *update" tab of DTP.
    Regards
    Anindya

  • Parameter in form for dynamic query in report

    Hello,
    I want to send parameters to report for replacing a dynamic query. I don't know how to make it...
    1.I want my select statement like
    select * from emp
    &p_where_clause
    2.I want to transfer parameters to report to replace the &p_where_clause.
    3.I know I should create a parameter list first, and then use add_parameter built-in to add the parameter, but what I don't know is the correct format of the add_parameter statement.
    4.I know the common format is add_parameter(paramlist,'TEXT_PARAMETER',value) , is it the same format if I want to transfer a select statement to report such as "where deptno in ('25','28','30')" for replacing &p_where_clause in report?
    Thanks in advance
    Joseph

    I appreciate your reply, but I am still a little confused...
    Actually, I want to pass the where clause to report by different condition. Such as when the user choose the deptment 1, then I can transfer the "where dept_no = '1' and empno > 500", or user choose the deptment 2, I can transfer "where dept_no = '2' and company = '0001'". What I want is to pass different where clause to report according to different condition.
    So is it right the statement should be like
    DECLARE
    vWhere1 varchar2 := 'where dept_no = "1" and empno > 500';
    vWhere2 varchar2 := 'where dept_no = "2" and company = "0001"';
    BEGIN
    IF choose = 1 THEN
    ADD_PARAMETER(&P_WHERE_CLAUSE, TEXT_PARAMETER, vWhere1);
    ELSIF choose = 2 THEN
    ADD_PARAMETER(&P_WHERE_CLAUSE, TEXT_PARAMETER, vWhere2);
    END IF;
    END;
    THANKS AGAIN!!
    Joseph

  • Duplicate records in SQ00 query

    HI,
    I am trying to make a query joining 3 tables. All tables have atleast 1 key field in common. In the output I have all fields from the main table, 3 fields from table "B" with a left outer join and 1 field from table "C" with an inner join. I am recieving duplicate records in the output. Is this issue a result of incorrect join conditions or is something else needed. Below is an illustration of join conditions.
    I look forward to your responses
    Regards,
    Curt

    Curt - is this related to BI?
    SQ00 is an ECC transaction and you may have better luck posting in one of the ERP spaces

  • Returning all records for a query

    Hi,
    still working on this library. I have the majority of it working (not pretty but it works). One problem I have run into is that when I query an authors name I would like all records for that author to be shown. However, it is only showing the final record.
                   public void Search_a()throws Exception{
              String S_author1 = JOptionPane.showInputDialog(null,"Please enter the authors name");
                   String query = ("select * from library where Author=('"+S_author1+"')");
                   ResultSet rs = db_statement.executeQuery(query);
                   while (rs.next()) {
                  String s = rs.getString("Author");
                  output.setText(rs.getString("ISBN")+"\t"+rs.getString("Title")+"\t"+ s +"\t"+ rs.getString("Publisher")+"\t"+rs.getString("Genre")+"\t"+rs.getString("Details")+"\n");
              }//end while
         }// end search_aI cannot see where the error is. I think maybe I am overwriting the previous records but thought that the inclusion of +"\n" would force each result to a new line.
    Any ideas?

    Thanks for that. Not really sure how I would implement that (new to programming) but I have managed to solve it using               output.setText(output.getText()+rs.getString("ISBN")+"\t"+rs.getString("Title")+"\t"+ s +"\t"+ rs.getString("Publisher")+"\t"+rs.getString("Genre")+"\t"+rs.getString("Details")+"\n");Thanks for the reply though.

  • Duplicate records for the same computer

    I have recently deployed SCCM 2007 SP1 with R2 for a customer.  We are currently in the process of deploying imaging and are having an issue with duplicate computers showing up.  The duplicates appear to be for the same computer.  I have read everything I can on duplicate computers showing up, but none of it has helped.  Basically, we have our base image, which is just a basic install of XP SP2 with all updates.  We lay down the image on a clean computer using an OSD task sequence, and when the machine shows up in the all systems collection, there are two records for it.  The current one is called SCCMTEST01.
    The first record shows the following:
    Name: SCCMTEST01
    Resource Type: System
    Domain: OURDOMAIN
    Site: 001
    Client: Yes
    Approved: Approved
    Assigned: Yes
    Blocked: No
    Client Type: Advanced
    Obsolete: No
    Active: Yes
    Properties:
    Agent Name[0]: MP_ClientRegistration
    Agent Name[1]: Heartbeat Discovery
    The second record shows the following:
    Name: SCCMTEST01
    Resource Type: System
    Domain: OURDOMAIN
    Site: 001
    Client: No
    Approved: N/A
    Assigned: Yes
    Blocked: No
    Client Type:
    Obsolete:
    Active:
    Properties:
    Agent Name[0]: SMS_AD_SYSTEM_DISCOVERY_AGENT
    Agent Name[1]: SMS_AD_SYSTEM_GROUP_DISCOVERY_AGENT
    The first one appears to be the active one, since it includes more information and the client is listed as installed.  Does anyone have any suggestions on what might be misconfigured?
    thanks,
    Justin

    I'm experiencing the same behaviour as described above. Not using any other OS distribution methods than scripted installation from RIS, will obviously make explanations based on OS Deployment behaviour not applicable in my case.
    The thing is that an object being discovered by Heartbeat, MP_Registration, SMS_AD_SYSTEM and SMS_AD_SYSTEN_GROUP... until suddenly, SMS_AD_SYSTEM_GROUP discovery agent starts generating a new object and updates that object from the moment on. Heartbeat from the client still updates the original object. This is done for about five object a day (among 2600 alltogether), and it's not the same computers that do this (apart from some, troublesome clients...).
    When finding this duplicate object, I have kept the one generated by SMS_AD_SYSTEM... and then reinitiated a Heartbeat Discovery on that object. Doing this will make Heartbeat to update the new object (now the original is gone), and everything seem to work for a while, although I have to manually approve that object again.
    I cannot work out what makes SMS_AD_SYSTEM... generate a new object.
    Does anyone have an idea?
    /Jakob

  • Duplicate records for Sale Order Cycle Report(excluding item level detail)

    I have posted this issue in number of forums but till today no one is able to answer it correctly.Here it is:
    I need to create a report which I think most of the sd consultants have also done it.It basically covers sales order cycle without item lvel detail such as:
    Sale Order No -- Sales Order Date-- Delivery No-- Delivery Date
    Now as we all know ,sales orders and deliveries are connected through item table which means in the output I will get duplicate rows for the report above.For Example, if a sales order share 3 items with the delivery then we will get 3 exact duplicate rows in the report.
    What can be the best solution?connecting through VBFA has alos same result as it also has item level details.
    I need a good solution.This a common report and there must be some solution

    Hiiii,
    It is standard SAP rule that system will catch the document flow (document link history) at item level.
    Now your problem that you dont want to show the line item based report because of duplicacy.
    Try this.
    Brows table VBFA -
    In screen selection select the following......
    1. Subsiquent document category
    2. Preceding item
    select "J" in Subsiquent document category
    and "000010" in Preceding item  then execute the table.
    Now system will not show multple line item based delivery report. so No duplicacy will be there
    Regards
    Shambhu Sarkar

  • How to change the name of the column for dynamic query

    I would like to change the name of the column name to bidderone, biddertwo and bidderthree. the only problem is the vendors name unknown when I run the query and sometimes the query returns two vendors. the maximum vendor is three. here is the query and please let me know how this can be done. thank you so much. I am using oracle 10i
    FOR lv_rec IN   ( SELECT vendor, calcbtot
      FROM (SELECT t.*, ROW_NUMBER () OVER (ORDER BY t.calcbtot Asc) rn
              FROM (  SELECT DISTINCT
                             s.vendor,
                             TO_CHAR (s.calcbtot, '999,999,999.00') calcbtot
                        FROM bidtabs b, bidders s
                       WHERE     b.CALL = s.CALL
                             AND b.letting = s.letting
                             AND b.vendor = s.vendor
                             AND b.letting = v_letting
                             AND b.CALL = v_call
                    ORDER BY 2) t)
    WHERE rn <= 3 )                 
       LOOP
          lv_sql :=
                lv_sql  || ', TO_CHAR(MAX(DECODE(TRIM(S.VENDOR),'''|| TRIM (lv_rec.vendor) || ''', S.BIDPRICE)),  ''$999,999,999.00'') AS "'|| TRIM (lv_rec.vendor) ||'" ';
       END LOOP;

    thank you so so much for your help on this. I am sorry i did not post the entire code. my intention is to use bidderone, biddertwo,bidderthree as a column name insead of the name of the vendors and also calcuate the average of the three vendors. the maximum vendor will be three but the minumum could be one or two. hope this is enought information to help me out further . thank you
    CREATE OR REPLACE PROCEDURE biddersquoteforbridge (
       p_spnumber   IN       VARCHAR2,
       p_result     OUT      sys_refcursor
    IS
       v_letting   VARCHAR2 (40);
       v_call      VARCHAR2 (40);
       lv_sql      VARCHAR2 (32767) := NULL;
    BEGIN
       SELECT DISTINCT L.LETTING, CALL
                  INTO v_letting, v_call
                  FROM LETPROP L, PROPOSAL P
                 WHERE L.LCONTID = P.CONTID AND CPROJNUM= p_spnumber;
       lv_sql :=
          'SELECT   O.PRPITEM "Item Number",
                    INITCAP(FUNC_GET_ITEM_DESCRIPTION(O.PRPITEM)) "Description",
                    O.CONTID "Contract Id",O.SECTION "Section" , P.CPROJNUM "SP Number", P.CFACSSUP "District",
                    FUNCT_GET_SECTION_IDENTIFIER(O.SECTION, O.CONTID) "Section Title",  ''Q''||(TO_CHAR(D.DATELET, ''Q-YYYY'')) "Quarter",
                    O.IPLINENO "Line Number", O.QTY "Quantity" ';
      FOR lv_rec IN   ( SELECT vendor, calcbtot
      FROM (SELECT t.*, ROW_NUMBER () OVER (ORDER BY t.calcbtot Asc) rn
              FROM (  SELECT DISTINCT
                             s.vendor,
                             TO_CHAR (s.calcbtot, '999,999,999.00') calcbtot
                        FROM bidtabs b, bidders s
                       WHERE     b.CALL = s.CALL
                             AND b.letting = s.letting
                             AND b.vendor = s.vendor
                             AND b.letting = v_letting
                             AND b.CALL = v_call
                    ORDER BY 2) t)
    WHERE rn <= 3 )                 
       LOOP
          lv_sql :=
                lv_sql  || ', TO_CHAR(MAX(DECODE(TRIM(S.VENDOR),'''|| TRIM (lv_rec.vendor) || ''', S.BIDPRICE)),  ''$999,999,999.00'') AS "'|| TRIM (lv_rec.vendor) ||'" ';
       END LOOP;
       lv_sql :=
             lv_sql
          || '
            FROM   PROPITEM O  ,                   
                   PROPOSAL P  ,
                   LETPROP  L  ,
                   BIDDERS  B  ,
                   BIDTABS  S  ,
                   BIDLET   D
             WHERE O.CONTID = P.CONTID
                    AND P.CONTID = L.LCONTID
                    AND L.CALL = B.CALL
                    AND L.LETTING = B.LETTING
                    AND B.CALL = S.CALL             
                    AND B.LETTING = S.LETTING
                    AND B.VENDOR = S.VENDOR 
                    AND S.IPLINENO = O.IPLINENO
                    AND L.LETTING = D.LETTING             
                    AND O.LINEFLAG =''L''    
                    AND L.LETTING = :B1
                    AND L.CALL = :B2
             GROUP BY
                   O.CONTID,
                   O.SECTION,
                   O.IPLINENO,
                   O.PRPITEM,
                   O.QTY,
                   P.CPROJNUM,
                   P.CFACSSUP,
                   O.PRICE ,
                   D.DATELET             
             ORDER BY O.IPLINENO ';
      -- DBMS_OUTPUT.put_line (lv_sql);
       OPEN p_result FOR lv_sql USING v_letting, v_call;
    END;

  • Duplicate records for address

    Hi
    When an emp updates his address from the ESS , 2 records are getting created in the back end( idealy ony one records should get created). both the records have same information. Not sure why this is happening.
    Please help me
    Regards
    Minal

    Minal,
    You get 2 new records? With the same data? (strange because of Time Constraints).
    Did you configure the right rule in TCODE PTARQ for this infotype?
    TCODE PTARQ ->  Employee Self-Service -> Service-Specific Settings -> Own Data -> Define Active Subtypes and Application Case:
    For IT0006 with the respective subtype I want to see in ESS I select the use case A1.
    Hope this help.
    Sónia

  • Duplicate rows in SAP Query

    Now here is the issue.
    FIrst of all I am using sap query for generating a report.There are such reports where we require to know deliveries corresponding to sales orders.So in the infoset we have to join the tables *vbak-vbap-lips-likp". Now in the report output we will find duplicate records for a single order(400000001)  delivery relation(9000000002) such as:
    Sale Order      Delivery
    400000001     9000000002
    400000001     9000000002
    400000001     9000000002
    This is due to three items in between them.Now how can we handle this situation as we know there is not duplicate records in the infoset but there duplicate records in the output.I hope you get my point.Please reply urgently

    Hello,
    in the join of the tables VBAK VBAP LIKP LIPS and you look for item detailes, are you considering the item number POSNR as key also?
    Try to consider also the folliwing tables:
    1. VBAK (get the order list)
    2. VBAP (get the item details of the order) and keep truck of the POSNR
    3. check the subsequent documents in VBFA (you enter with result of VBAP [VBELV & POSNV] and you end/take the follow-on document and item number = VBELN & POSNN)
    4. LIKP (get the information of the delivery header = you enter with the result at point 3 VBELN)
    5. LIPS (get the information of the item of the delivery = you enter with VBELN & POSNN got at point 3)
    Do not forget to query and have POSNR as key since the beginning.
    Regards,

  • DB_GET_BOTH_RANGE fails when there is only one record for a key

    Using the DB_GET_BOTH_RANGE flag doesn't seem to work when there is a
    single record for a key.
    Here's a sample Python program that illustrates the problem. If you
    don't know Python, then consider this to be pseudo code. :)
    from bsddb3 import db
    import os
    env = db.DBEnv()
    os.mkdir('t')
    env.open('t',
    db.DB_INIT_LOCK | db.DB_INIT_LOG | db.DB_INIT_MPOOL |
    db.DB_INIT_TXN | db.DB_RECOVER | db.DB_THREAD |
    db.DB_CREATE | db.DB_AUTO_COMMIT)
    data = db.DB(env)
    data.set_flags(db.DB_DUPSORT)
    data.open('data', dbtype=db.DB_HASH,
    flags=(db.DB_CREATE | db.DB_THREAD | db.DB_AUTO_COMMIT |
    db.DB_MULTIVERSION),
    txn = env.txn_begin()
    #data.put('0', '6ob 0 rev 6', txn)
    data.put('0', '7ob 0 rev 7', txn)
    #data.put('0', '8ob 0 rev 8', txn)
    data.put('1', '9ob 1 rev 9', txn)
    txn.commit()
    cursor = data.cursor()
    print cursor.get('0', '7', flags=db.DB_GET_BOTH_RANGE)
    cursor.close()
    data.close()
    env.close()
    This prints None, indicating that the record who's key is '0' and
    who's data begins with '7' couldn't be found. If I uncomment wither of
    the commented out puts, so that there is more than one record for the
    key, then the get with DB_GET_BOTH_RANGE works.
    Is this expected behavior? or a bug?

    You can use the DB_SET flag which will look for an exact key match. If
    you use it with the DB_MULTIPLE_KEY flag, it will return multiple keys
    after the point it gets a match. If you can post here how all your
    LIKE QUERIES look, I may be able to provide you with the suited
    combination of the flags you can use for them.I'm not doing like queries. I'm using BDB as a back end for an object
    database. In the object database, I keep multiple versions of object
    records tagged by timestamp. The most common query is to get the
    current (most recent version) for an object, but sometimes I want the
    version for a specific timestamp or the latest version before some
    timestamp.
    I'm leveraging duplicate keys to implement a nested mapping:
    {oid -> {timestamp -> data}}
    I'm using a hash access method for mapping object ids to a collection
    of time stamps and data. The mapping of timestamps to data is
    implemented as duplicate records for the oid key, where each record is
    an 8-byte inverse timestamp concatenated with the data. The inverse
    timestamps are constructed in such a way that they sort
    lexicographically in inverse chronological order. So there are
    basically 3 kinds of query:
    A. Get the most recent data for an object id.
    B. Get the data for an object id and timestamp.
    C. Get the most recent data for an object id who's timestamp is before
    a given timestamp.
    For query A, I can use DB->get.
    For query B, I want to do a prefix match on the values. This can be
    thought of as a like query: "like <inverse-time-stamp>%", but it can
    also be modelled as a range search: "get the smallest record that is >=
    a given inverse time stamp". Of course, after such a range search,
    I'd have to check whether the inverse time stamp matches.
    For query C, I really want to do a range search on the inverse time
    stamp prefixes. This cannot be modelled as a like query.
    I could model this instead as {oid+timestamp -> data}, but then I'd
    have to use the btree access method, and I don't expect that to scale
    as I'll have hundreds of millions of objects.
    We tried using BDB as a back end for our database (ZODB) several years
    ago and it didn't scale well. I think there were 2 reasons for
    this. First, we used the btree access method for all of our
    databases. Second, we used too many tables. This time, I'm hoping that
    the hash access method and a leaner design will provide better
    scalability. We'll see. :)
    If you want to start
    on a key partial match you should use the DB_SET_RANGE flag instead of
    the DB_SET flag.I don't want to do a key partial match.
    Indeed, with DB_GET_BOTH_RANGE you can do partial
    matches in the duplicate data set and this should be used only if you
    look for duplicate data sets.I can't know ahead of time whether there will be duplicates for an
    object. So, that means I have to potentially do the query 2 ways,
    which is quite inconvenient.
    As you saw, the flags you can use with cursor.get are described in
    detailed here.But it wasn't at all clear from the documentation that
    DB_GET_BOTH_RANGE wouldn't work unless there were duplicates. As I
    mentioned earlier, I think if this was documented more clearly and
    especially of there was an example of how one would work around the
    behavior, someone would figure out that behavior wasn't very useful.
    What you should know is that the usual piece of
    information after which the flags are accessing the records, is the
    key. What I advice you is to look over Secondary indexes and Foreign
    key indexes, as you may need them in implementing your queries.I don't see how secondary indexes help in this situation.
    BDB is
    used as the storage engine underneath RDBMS. In fact, BDB was the
    first "generic data storage library" implemented underneath MySQL. As
    such, BDB has API calls and access methods that can support any RDBMS
    query. However, since BDB is just a storage engine, your application
    has to provide the code that accesses the data store with an
    appropriate sequence of steps that will implement the behavior that
    you want.Yup.
    Sometimes you may find it unsatisfying, but it may be more
    efficient than you think.Sure, I just think the notion that DB_GET_BOTH_RANGE should fail if
    the number of records for a key is 1 is rather silly. It's hard for me
    to imagine that it would be less efficient to handle the non duplicate
    case. It is certainly less efficient to handle this at the application
    level, as I'm likely to have to implement this with multiple database
    queries. Hopefully, BDB's cache will mitigate this.
    Thanks again for digging into this.
    Jim

Maybe you are looking for

  • Lenovo w510 will not boot after BIOS update

    Hi,  This morning I used the windows bios update utility to update my Lenovo w510 type 4318. Everything appeared to have been successful until the machine rebooted. It froze on the lenovo splash screen with text saying to press the blue think vantage

  • Best practice in dreamweaver based web design

    Hi DW Gurus I have been learning dreamweaver at work and at home for a while now and I am very interested in getting some details about best practices. I am aware that my designs are still quite simple and don't expand dreamweaver anyway near its abi

  • Trying to install presets but can't find presets folder

    I just upgraded to Lion AND purchased Lightroom 4. I'm trying to install a set of presets by going to lightroom preferences, presets and clicking on the "show lightroom presets folder" but when I click the button nothing happens at all. In fact, I ca

  • Sb live 24 with logitech z5300e no 5.1 please h

    I Have sb li've 24 bit card (new) and Logitech z5300e (new) an am getting only front right and left speakers on the test. The sub switch is set to 5. the sb is set to 5. and when I play music or a dvd there is sound coming out of the rears but it doe

  • Dynamic code [i]replacement[/i]

    Hi all, I have seen dynamic code replacement used in Tomcat, Eclipse, jEdit, ... but whenever I go to research how to incorporate it into my applications, I just get a bunch of stuff about Erlang, python, and Java ClassLoaders, which if a class is al