How can you split a table in to exactly half?

Answer Posted / reddy kanupuru

Hi,

Here i am giving the procedure , how to make the table into
half..... using program... I dont know whether any direct
SQL command is there or not. This is just for ur idea what
i know.

1) Find the total number of rows in a table using count(*)

2) Declare two variable in working storage section.
eg: 02 A pic 9(4) .
02 B pic 9(2).

store the count no into one variable .assume u stored that
in A.

then divide that by 2. so u will get half of the rows in a
table. strore that value in B.

3) Take another variable name C .

eg: 02 c pic 9(4) value 0.

perform para1 until B =C

para1:

Retrive the row from the table.

move to corresponding host variables ( use table to store
muliple rows ).

insert into table(u can insert multiple rows at a time ...)

do the same for storing the other half into the another
table.

means here 1 st half rows were stored in one temp
table .... the other in the one table.

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

List out the buffer pools in db2

634


Is ibm db2 open source?

590


Mention some fields that are a part of sqlca.

604


What is the use of with ur in db2?

623


What is declare cursor?

617






How can we retrieve the total number of records in RPG & CLLE?

203


How can the firstname and the lastname from the emp table be concatenated to generate complete names?

750


What is sqlca?

625


What is the use of reorg in db2?

612


What is the physical storage length of the data types: date, time, timestamp in the db2 database?

656


Why select is not preferred in embedded sql programs?

715


What is the purpose of using commit?

622


What is collection in db2 bind?

579


What is db2 purescale?

553


What is db2 bind?

644