Page 1 of 1

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

PostPosted: Thu Dec 13, 2012 4:48 pm
by raulravi
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?

Re: CICS-DB2

PostPosted: Thu Dec 13, 2012 5:06 pm
by Robert Sample
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)?

Re: CICS-DB2

PostPosted: Thu Dec 13, 2012 8:38 pm
by dick scherrer
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.

Re: CICS-DB2

PostPosted: Mon Dec 17, 2012 3:52 pm
by GuyC
you could use multi-row fetch, multi-row insert.

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

PostPosted: Mon Dec 17, 2012 8:10 pm
by dick scherrer
Hi Guy,

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

d

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

PostPosted: Tue Dec 18, 2012 2:59 pm
by GuyC
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

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

PostPosted: Tue Dec 18, 2012 4:45 pm
by Akatsukami
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?".