First rows in Table A- process and write it to table



IBM's flagship relational database management system

First rows in Table A- process and write it to table

Postby raulravi » Thu Dec 13, 2012 4:48 pm

Hi,
I have to read 5 first rows in Table A- process and write it to table B. And gain read next five rows (from 6-10 ) again process and write them to table B.

Can any one help me out here?
raulravi
 
Posts: 3
Joined: Thu Dec 13, 2012 4:39 pm
Has thanked: 0 time
Been thanked: 0 time

Re: CICS-DB2

Postby Robert Sample » Thu Dec 13, 2012 5:06 pm

Since this is a HELP forum and not a WRITE-THE-CODE-FOR-YOU forum, what have you done so far and what is your problem?

And what does "first five rows" mean to you since DB2 does not guarantee you will get the rows in any particular order (unless you use ORDER BY in your SELECT)?
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: CICS-DB2

Postby dick scherrer » Thu Dec 13, 2012 8:38 pm

Hello and welcome to the forum,

I have to read 5 first rows in Table A- process and write it to table B. And gain read next five rows (from 6-10 ) again process and write them to table B.
Why does someone believe this should be done? What business requirement does it meet?

Hopefully, you are aware that in database there is no concept of first/last n rows. Even with an ORDER BY, the result can change due to inserts/deletes.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: CICS-DB2

Postby GuyC » Mon Dec 17, 2012 3:52 pm

you could use multi-row fetch, multi-row insert.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times

Re: First rows in Table A- process and write it to table

Postby dick scherrer » Mon Dec 17, 2012 8:10 pm

Hi Guy,

Yup, surely could - but i'm still curious Why . . . ?

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: First rows in Table A- process and write it to table

Postby GuyC » Tue Dec 18, 2012 2:59 pm

80% of programs read/fetch from some input (table) , process, and write/insert some output (table).
That's almost the definition of "a program".
Why it should be in batches of 5 I have no idea. maybe he needs to print them side by side, package 5 items in a box, commit every 5, ...
He could just fetch 5 times, but multi-row is faster
I can explain it to you, but i can not understand it for you.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times

Re: First rows in Table A- process and write it to table

Postby Akatsukami » Tue Dec 18, 2012 4:45 pm

I think that the intent of the question may have been, "But how does this help in ensuring that the first five rows are gotten, and then the next five rows?".
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post