This discussion is archived
3 Replies Latest reply: Jun 7, 2013 2:46 PM by user8997135 RSS

putOverwrite?

user8997135 Newbie
Currently Being Moderated
I want to do this:
1,if the key exists, overwrite
2,if the key doesn't exist, no op, return operationstatus.keyexist

My lame understanding of transaction did not give me a definite answer. And the existance of putNoOverwrite made me wonder if there is something subtle going on.
  • 1. Re: putOverwrite?
    Bogdan Coman Journeyer
    Currently Being Moderated
    It's not clear to me what question is, as you talked about overwriting existing records and transactions... and I don't see the connection. Do you want to do 'putOverwrite' using a single database operation? Or do you ask about enclosing the two operations (locating the key and inserting if it's there) in the same transaction?
  • 2. Re: putOverwrite?
    greybird Expert
    Currently Being Moderated
    I think he's asking how to do an update or "putNoInsert", and the answer if that you have to use a cursor:
    1. Cursor.getSearchKey -- if NOTFOUND, stop.
    2. Cursor.putCurrent.
    --mark                                                                                                                                                                                                                                                                                                                                                                               
  • 3. Re: putOverwrite?
    user8997135 Newbie
    Currently Being Moderated
    Yes,that's what I want.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points