MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Replace DB2 LOAD in Batch
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
pvrajs
Beginner


Joined: 07 Jan 2005
Posts: 41
Topics: 12

PostPosted: Fri Dec 29, 2006 1:24 pm    Post subject: Replace DB2 LOAD in Batch Reply with quote

Hi,

I have a DB2 table that is loaded with the help of LOAD utility. I understand till Ver 8.1 the tablespace is exclusively locked for the table to be loaded. In the current scenerio, the table is being accessed by other distributed applications at the time the table is loaded. So, either the distributed applications are not able to retrieve data or the batch job fails. So, we thought of replacing the LOAD utlity with INSERT statements. Please note that amount of data being loaded is NOT huge.

The LOAD utility step is also the TERM Utility. I would like to know if it is necessary to use the term utility if we are using the COBOL-DB2 program with INSERT statements in place of LOAD utility. If so, how? Also please let me know if there is any other alternatives.

Please clarify.

Thanks,
Vijay
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Dec 29, 2006 4:07 pm    Post subject: Reply with quote

Quote:

So, we thought of replacing the LOAD utlity with INSERT statements. Please note that amount of data being loaded is NOT huge.

pvrajs,

A programatical INSERTS will also lock the table at a page level and depending on your Commit frequency you will still have deadlocks. So I suggest generating sql statements.

http://www.mvsforums.com/helpboards/viewtopic.php?t=2787&highlight=sqlcards

http://www.mvsforums.com/helpboards/viewtopic.php?t=3369&highlight=sqlcards


Quote:

The LOAD utility step is also the TERM Utility. I would like to know if it is necessary to use the term utility if we are using the COBOL-DB2 program with INSERT statements in place of LOAD utility. If so, how? Also please let me know if there is any other alternatives.


The TERM utility has got nothing to do with your load. The TERM utility is used to terminate the load utilid in case of an abend.

Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pvrajs
Beginner


Joined: 07 Jan 2005
Posts: 41
Topics: 12

PostPosted: Tue Jan 02, 2007 12:23 pm    Post subject: Reply with quote

Hi Kolusu,

Thanks for the reply. Could you please provide me the link to understand the theoritical back ground. That would help me to understand things better before i work on the proposed solution. My requirement slightly varies with the other postings (i think).

1. Insert if a new record is not available in the table.
2. Update if the record is availble in the table.
3. Delete the record from the table if the record is not present in the file.

Thanks,
Vijay
Back to top
View user's profile Send private message
pvrajs
Beginner


Joined: 07 Jan 2005
Posts: 41
Topics: 12

PostPosted: Wed Jan 03, 2007 4:59 pm    Post subject: Reply with quote

Hi,

After going thru the details provided, I understand that the below mentioned steps are to be performed to get out of the problem I am facing -

1. Generate the Delete control cards for the i/p file
2. Execute the DSNTIAUL utility to UNLOAD the data from the table
3. Generate the Insert control card for the i/p file
4. Run the updates

Please correct me if I am wrong.

This leaves me with some queries -

a. How can I ensure that all the data in the table has been Unloaded by DSNTIAUL? There may be a case that some of the key values present in the table are not present in the i/p file. And so are not deleted. Can I write a DELETE control card to delete everything from the table, by putting Delete * ... Currently we are flushing out the data and reloading it every day with LOAD
b.
Quote:
either the distributed applications are not able to retrieve data or the batch job fails

Does the proposed process handle the condition specified in quote i.e. I would like to know which lock is applied on the table.
c. Currently as part of the LOAD process the job is using DSNUTILB to check the consistency between indexes and the data that is supported. Should the proposed solution need to perform this? If not, how is it taken care.

Please let me know and correct me, if I am wrong at any stage.

Thanks,
Vijay
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jan 04, 2007 9:39 am    Post subject: Reply with quote

pvrajs,

Since you want to update/delete/insert I suggest you this procedure.

1. Unload the entire data from the table using DSNTIAUL. The utility unloads all the records from the table if your select statement is as follows
Code:

Select * from table;


Also note that unload means a copy of the table is only taken. The data still exists in the table. i.e a snapshot of the table data is taken at the time.

2. Now compare this unload file with your input file using easytrieve, sort, cobol program and within this program itself generate 3 files

a. Delete statement file.
b. Update statement file.
c. Insert statement file.

3. Now run the update/delete/insert using the inputs from step2.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pvrajs
Beginner


Joined: 07 Jan 2005
Posts: 41
Topics: 12

PostPosted: Thu Jan 04, 2007 9:56 am    Post subject: Reply with quote

Thanks kolusu.

Can you please address my questions 'b' and 'c' in my earlier thread on locking and consistency?

Thanks,
Vijay
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jan 05, 2007 9:42 am    Post subject: Reply with quote

Quote:

either the distributed applications are not able to retrieve data or the batch job fails
Does the proposed process handle the condition specified in quote i.e. I would like to know which lock is applied on the table.


Pvrajs,

If you are using the approach of generating the sql statements with a commit after every statement , there is very less chance of getting deadlocks with other applications. The locks are applied at a page level but your immediate commit stmt will release the lock immediately.

Quote:

c. Currently as part of the LOAD process the job is using DSNUTILB to check the consistency between indexes and the data that is supported. Should the proposed solution need to perform this


You don't have to check the index consistency. Just make sure that your input file data is sorted in the order of the primary keys of the table.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pvrajs
Beginner


Joined: 07 Jan 2005
Posts: 41
Topics: 12

PostPosted: Fri Jan 05, 2007 11:00 am    Post subject: Reply with quote

Thanks for the clarifications Kolusu.

Hopefully a last query. I have some COMP-3 data in one of the datasets that is being loaded to the database into smallint type of column. As per my knowledge, the LOAD utility implicitly takes care of the data conversions.

How can the conversion of COMP-3 to smallint / any other datatype be achieved when using INSERT/UPDATE statements?

Thanks,
Vijay
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jan 05, 2007 1:15 pm    Post subject: Reply with quote

pvrajs,

Quote:

I have some COMP-3 data in one of the datasets that is being loaded to the database into smallint type of column. As per my knowledge, the LOAD utility implicitly takes care of the data conversions.


Are you sure you are loading the right values? Your input file must confirm the DCLGEN of the table. The load utility does NOT convert the comp-3 to smallint unless you have a editproc on that column.

When you are using insert/update statement in batch , just give the numbers in regular readable format.

for ex a column named salary is defined as DECIMAL(9, 2) in the table. In your update statement you can specify

Code:

UPDATE TABLE
   SET SALARY = 5000


The utility automatically takes cares of the conversion.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pvrajs
Beginner


Joined: 07 Jan 2005
Posts: 41
Topics: 12

PostPosted: Fri Jan 05, 2007 3:00 pm    Post subject: Reply with quote

Yes, I am sure. Please find the details below -

DCLGEN
Code:

EXEC SQL DECLARE <table_name> TABLE                                   
          ( C1       CHAR(1) NOT NULL,         
            C2      CHAR(8 ) NOT NULL,         
            C3      CHAR(4) NOT NULL,         
            C4      CHAR(4) NOT NULL,         
            C5      SMALLINT NOT NULL         
          ) ;                                                       

Values from input file
[code:1:b98f746c4a]
VAA2859 02000000.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jan 05, 2007 3:07 pm    Post subject: Reply with quote

what makes you think the input file has COMP-3 values? Run the following job and show us the contents in hex format.

Code:

//STEP0100 EXEC PGM=SORT 
//SYSOUT    DD SYSOUT=* 
//SORTIN    DD DSN=your input load file,
//             DISP=SHR
//SORTOUT   DD SYSOUT=*
//SYSIN     DD *
 SORT FIELDS=COPY,STOPAFT=50
 OUTREC FIELDS=(18,2,HEX)
/*                       


Quote:

Whne we are preparing the SQLCARDS from the input file, how can we provide the regular read format values in the INSERT/UPDATE statement, without any conversion?


How are you planning to create the sqlcards? pgm ? utitlity?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pvrajs
Beginner


Joined: 07 Jan 2005
Posts: 41
Topics: 12

PostPosted: Fri Jan 05, 2007 3:17 pm    Post subject: Reply with quote

Cond from the prev thread ..

Please find the table definition below

CREATE TABLE <table_name>
(C1 CHAR ( 0001 ) NOT NULL ,
C2 CHAR ( 0008 ) NOT NULL ,
C3 CHAR ( 0004 ) NOT NULL ,
C4 CHAR ( 0004 ) NOT NULL ,
C5 SMALLINT NOT NULL )
IN <table_space>
AUDIT NONE DATA CAPTURE NONE ;
_________________
Thanks for help
Back to top
View user's profile Send private message
pvrajs
Beginner


Joined: 07 Jan 2005
Posts: 41
Topics: 12

PostPosted: Fri Jan 05, 2007 3:24 pm    Post subject: Reply with quote

Please find the values below -

00CF
003C
0000
0000
0000
0000

I am thinking to use the code you have suggested in threads of your first reply to create the SQLCARDS
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jan 05, 2007 4:55 pm    Post subject: Reply with quote

pvrajs,

From the above data I don't think the input is comp-3.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pvrajs
Beginner


Joined: 07 Jan 2005
Posts: 41
Topics: 12

PostPosted: Mon Jan 08, 2007 2:23 pm    Post subject: Reply with quote

What values could it be then?

Thanks,
Vijay
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group