View previous topic :: View next topic
|
Author |
Message |
mahi
New User
Joined: 04 Apr 2006 Posts: 86 Location: Hyderabad
|
|
|
|
I am inserting a row in to the DB2 table in one para and next My requirement is to UPDATE that same row I have inserted.
Is this possible? Because with out completing the JOb only we are trying to update that row.
Please suggest. |
|
Back to top |
|
|
vch
New User
Joined: 01 Feb 2008 Posts: 22 Location: chennai
|
|
|
|
Hi Mahi,
I think it is possible. First insert record in table and store all data that is needed for fetching that inserted record in working storage. In next para using Working storage values write a select querry WITH UR option and update that row.
WITH UR ---> With Uncommited Read
A query defined with uncommitted read will read every matching row, including those that
have not yet been committed. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Mahi,
I am old and slow (thickheaded) and as such see this as a simple expansion of your program/Stored Procedure.
1st: why not insert the correct row to begin with?
2nd: UPDATEing a row that you have INSERTed is no different than UPDATEing any row.- you build the WHERE clause (host variable values) to insure you only update the row in question
- you populate the appropriate host variables with NEW data with which you want to modifiy the row, in your SET clause.
|
|
Back to top |
|
|
hikaps14
Active User
Joined: 02 Sep 2005 Posts: 189 Location: Noida
|
|
|
|
Well, I haven't tried this but still I think its possible.
What I would suggest is try using explicit 'Commit' command after you insert the row. Then try accessing the newly inserted row. May be this helps.
One thing is for sure that you won't be able to access the newly inserted row unless you commit it in the table.
Let me know if this works or if anyone has some comments on my view. I could be wrong as I haven't tried it. I have just put a logical view on the problem.
Thanks,
-Kapil. |
|
Back to top |
|
|
vch
New User
Joined: 01 Feb 2008 Posts: 22 Location: chennai
|
|
|
|
Hi Hikaps14,
What if i use WITH UR instead of commit.. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
What I would suggest is try using explicit 'Commit' command after you insert the row |
explicit commits should never, repeat never be used unless a proper
checkpoint/restart/recovery architecture has been defined |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you can UPDATE a row just INSERTed
without COMMIT
without using WITH UR.
It is in your logical unit of work (LUW).
even though the OP should just modify his logic
so that he INSERTs the row with proper data,
he can immediately UPDATE the row, without WITH UR.
no need to COMMIT anything.
please, try testing before suggesting. |
|
Back to top |
|
|
r2k1984
New User
Joined: 21 Jun 2005 Posts: 69 Location: chennai
|
|
|
|
You can do it if you give a commit command explicitly after insert.
So that you will be able to execute it. |
|
Back to top |
|
|
mahi
New User
Joined: 04 Apr 2006 Posts: 86 Location: Hyderabad
|
|
|
|
Thanks Every One... I have tested without giving COMMIT & WITH UR and it seems not working..I will check it once with correct data and let you know .... |
|
Back to top |
|
|
mahi
New User
Joined: 04 Apr 2006 Posts: 86 Location: Hyderabad
|
|
|
|
Thank you Dick ...it is working fine without using COMMIT , WITH UR... |
|
Back to top |
|
|
|