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
I HAVE 500 ROW TO UPDATE I WOULD LIKE TO USE ROLLBACK ALONG WITH COMMIT.WHAT IS THE SYNTAX TO CODE COMMIT AND ROLLBACK FOR EVERY 100 ROWS.AND HOW THE CURSOR ROLLBACK TO THE LAST COMMITTING POINT.
What are union and union all?
What is a db2 collection?
What is package in db2 mainframe?
What are the two types of logging in the db2 database? Explain them.
When the like statement is used?
How do I copy a table in db2?
How to find the number of rows in a db2 table?
What is dbrm? When it will be created?
How do you find the maximum value in a column in db2?
Define predicate?
What is the use of with ur in db2?
What is collection in db2 bind?
What is the maximum No of rows per page?
Can we update view in db2?