Joe wrote
Quote:
Hi Ron,
I just want to search by "k" and only retrieve data3 as you said. I
have seen the reference for DB_DBT_PARTIAL.
It is to do the partial retrieval or storage of an item. I am not sure
whether it's what I want. I think that data3 is an item, not the
combination of data1, data2 and data3. When I store them into database,
I use the form as put(k, data1), (k, data2), (k, data3). |
Glad you explained that since I thought you were referring to a single
record.
If all 3 records have the same key, I'm not sure how you know which one
you want so I am assuming you just know which one.
In this case, you would use DBcursor->c_get() three times. The first
time would be using the DB_SET flag and the next 2 times would be
simply using the DB_NEXT flag.
http://www.sleepycat.com/docs/api_c/dbc_get.html
If the data records are very large and you know in advance which record
you want (with the same key) you could use the optimization technique I
mentioned in my first reply. That is, use DB_DBT_PARTIAL and dlen=0
as flags on your dbt. For further information:
http://www.sleepycat.com/docs/api_c/dbt_class.html
Ron