Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How can you split a table in to exactly half?

Answers were Sorted based on User's Feedback



How can you split a table in to exactly half?..

Answer / nirmal khatri

Hi

We can do it by SQL also, below is SQL which is working on
iSeries(AS/400)

insert into nk11581/temp1 (select * from nk11581/temp1
where rrn(temp1) in(
SELECT distinct dec((rrn(temp1)/2)) FROM nk11581/temp1
))

Is This Answer Correct ?    3 Yes 1 No

How can you split a table in to exactly half?..

Answer / 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

How can you split a table in to exactly half?..

Answer / pavani

i forgot to mention the c value increment in the above
mail.increment the c value after each row retrieved.

Is This Answer Correct ?    2 Yes 1 No

How can you split a table in to exactly half?..

Answer / sachin

ADDING TO ans1
no need to write perform

direct use below query

select * from table fech first :b rows only.

Is This Answer Correct ?    1 Yes 1 No

How can you split a table in to exactly half?..

Answer / arpita

We can achieve this by using STRSQL and CPYF commands as
follows -

Type STRSQL, Press Shift + F1, option1 Change session
attributes.Type 3 for SELECT option, specify the output
file name and library (must be created in QTEMP, for a
temporary file). Press ENTER twice.

Then, type the following query -
select * from SAHAA/EMPDATA1
where rrn(EMPDATA1) in(
SELECT distinct dec((rrn(EMPDATA1)/2)) FROM SAHAA/EMPDATA1
) --> use your file and library name

Press Enter, the message File TEMP in QTEMP was created.
Restore the previous session attributes as follows -

Press Shift + F1, option1 Change session attributes.Type 1
for SELECT option. Press ENTER thrice.

Now, we would have half no. of records of EMPDATA1 in file
TEMP (say)

Now, simply use the CPYF command to copy TEMP file data
into EMPDATA1 as follows -

CPYF FROMFILE(QTEMP/TEMP) TOFILE(SAHAA/EMPDATA1) MBROPT
(*REPLACE)

Note:- TEMP is the file temporarily created in QTEMP, so
that it is no longer present in the system when the session
expires.

Is This Answer Correct ?    0 Yes 1 No

How can you split a table in to exactly half?..

Answer / kumar

ohh.. just manage the ws-count variable..

Is This Answer Correct ?    0 Yes 2 No

How can you split a table in to exactly half?..

Answer / kumar

Hi ............
try this one ....might be a logical one ... but have to
give customers what they want.....

Select count(*) into :ws-count from emp with ur;

Declare CURSOR cursor1 for
Select *(if possible better code all fields)
from emp where count(*) < :ws-count;
Open cursor
Fetch cursor.

Declare CURSOR cursor2 for
Select *(if possible better code all fields)
from emp where

count(*) >= :ws-
count;
Open cursor
Fetch cursor.

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More DB2 Interview Questions

Explain the contents that are a part of dclgen.

0 Answers  


Mention the various locks that are available in db2.

0 Answers  


what is the maximum number of tables that can be joined ?

8 Answers   IBM, TCS,


How can you classify the locks in db2?

0 Answers  


What are the isolation levels possible ?

3 Answers  


What is a bind in db2?

0 Answers  


How to create backup table in db2?

0 Answers  


I have 3 cursors declared. Cursor1 retieves some data. Based on this curso2 will also fetches some data. In cursor3 (using for some updation) I'm using the data retrieved by the above 2 cursor. My question is, while working with cursor3, periodically if I give commit, will all the three crsors will be closed or only cursor3 will be closed?

4 Answers  


1. what if null values retrived from database and no null indicator mentioned in query. What is sql code.

1 Answers   Cap Gemini,


Can you search give an array in the WHERE clause of a db2 query?

1 Answers  


Can i insert bulk records into a db2 table using qmf of spufi only............!!!

2 Answers  


Why do chiropractors use drop table?

0 Answers  


Categories