Page 1 of 1

Help on understanding unload

PostPosted: Tue Jul 21, 2009 12:18 pm
by curios13579
Hello, first of all I am new with DB2 and databases so please be patient if the questions seems to be stupid :(

Let's say I have to do this unload , if I did it once and RC was 0 so finished well, what happens if I do the step again?
will it unload it again cancel and write the file again or it will write over it?
In small words: will it duplicate the RECORDS WRITTEN in file ? because with the DISP=(,CATLG,DELETE), it shoul delete it only if abends right?

//*-------------------------------------------
//* UNLOAD TABEL
//*-------------------------------------------
//12345678 EXEC DB2HPU
//SYSPRINT DD SYSOUT=*
//UNLDDN1 DD DSN=xxx.xxx.xxxx.xxxxxxxx.xxxx,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(300,150),RLSE),
// DSORG=PS,LRECL=1300,RECFM=FB
//LOADNDN1 DD DUMMY
//$ORTPARM DD *
OPTION FILSZ=U30000000
/*
//SYSIN DD *
UNLOAD TABLESPACE 12345678.1234567
DB2 NO LOCK NO
SELECT * FROM 1234.98765432 WHERE CIST = 33
OUTDDN (UNLDDN1)
FORMAT DSNTIAUL


thanks in advance

Re: Help on understanding unload

PostPosted: Tue Jul 21, 2009 4:06 pm
by nayanpatra
The job will abend if you are using a simple sequential file. But if you are using a GDG version then a new version will be created. In order to reuse the PS you can use DISP = SHR

Re: Help on understanding unload

PostPosted: Wed Jul 22, 2009 1:36 am
by dick scherrer
Hello,

This is more of a jcl question than a db2 question. . .

Suggest you review how the DISP paramater of the DD statement works.

This situation would exist if this was a sort, an iebgener, a user program, etc.

If the file is to be re-created at each execution, suggest you incorporate a "housekeeping" step to make sure the dataset does not exist before the (new,catlg,delete) is processed.

I suggest you NOT use disp=shr because shr has a completely different meaning and purpose.