IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

inserting a row in to the DB2 table in one para and nex


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Hyderabad

PostPosted: Mon Nov 10, 2008 4:14 pm
Reply with quote

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
View user's profile Send private message
vch

New User


Joined: 01 Feb 2008
Posts: 22
Location: chennai

PostPosted: Mon Nov 10, 2008 5:11 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Nov 10, 2008 5:16 pm
Reply with quote

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
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Mon Nov 10, 2008 5:16 pm
Reply with quote

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
View user's profile Send private message
vch

New User


Joined: 01 Feb 2008
Posts: 22
Location: chennai

PostPosted: Mon Nov 10, 2008 5:35 pm
Reply with quote

Hi Hikaps14,

What if i use WITH UR instead of commit..
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Nov 10, 2008 5:42 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Nov 10, 2008 7:44 pm
Reply with quote

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
View user's profile Send private message
r2k1984

New User


Joined: 21 Jun 2005
Posts: 69
Location: chennai

PostPosted: Tue Nov 11, 2008 11:23 am
Reply with quote

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
View user's profile Send private message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Hyderabad

PostPosted: Tue Nov 11, 2008 12:59 pm
Reply with quote

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
View user's profile Send private message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Hyderabad

PostPosted: Tue Nov 11, 2008 6:13 pm
Reply with quote

Thank you Dick ...it is working fine without using COMMIT , WITH UR...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top