Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Pune

PostPosted: Mon Nov 10, 2008 4:14 pm    Post subject: inserting a row in to the DB2 table in one para and nex
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    Post subject:
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    Post subject:
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    Post subject: Reply to: inserting a row in to the DB2 table in one para an
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10232
Location: italy

PostPosted: Mon Nov 10, 2008 5:42 pm    Post subject: Reply to: inserting a row in to the DB2 table in one para an
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    Post subject:
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    Post subject: Reply to: inserting a row in to the DB2 table in one para an
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: Pune

PostPosted: Tue Nov 11, 2008 12:59 pm    Post subject:
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: Pune

PostPosted: Tue Nov 11, 2008 6:13 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Data replication from multiple Db2 ta... kishpra DB2 5 Mon Mar 27, 2017 9:58 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us