How can you split a table in to exactly half?
Answer Posted / 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 |
Post New Answer View All Answers
How to retrieve rows from a db2 table in embedded sql?
Is db2 a database?
What is dclgen in db2?
How do I import data from excel to db2?
What is the maximum number of columns in a db2 table?
What is the use of value function?
What is consistency token in db2?
What is a db2 table?
What is isolation level in db2?
Mention the way of highlighting as well as putting a cursor to use in a cobol program.
When a COBOL-DB2 program in PRODUCTION is updating main tables and gone for long run, what have to do?
What is a db2 cursor?
What is a db2 tablespace?
What is database manager in db2?
If the cursor is kept open followed the issuing of commit, what is the procedure to leave the cursor that way?