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 

Is this the way this SQL is required?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
Arun
Beginner


Joined: 24 Mar 2003
Posts: 13
Topics: 7
Location: Philadelphia, US.

PostPosted: Wed May 28, 2003 5:02 pm    Post subject: Is this the way this SQL is required? Reply with quote

Hi,
One of our production maintenance job has a sysin that has both the queries below. I'm just confused. Rolling Eyes Why should they have both of the queries in a single sysin ? I don't see any point in having the first query, as the final outcome of the job with/without the first query is the same.
In that case, why they need to select all the records once, they do a commit and then again select one by one and delete it. Thay can very well have only the second query. Exclamation Question

SELECT *
FROM BILLG_ACCT_DTD A
WHERE A.TM_PD_TYP_INST_NBR = 551
AND A.DT_TYPE_CD = 'DISCONNECT'
AND A.DT_STATUS_CD = 'AC'
AND EXISTS
( SELECT *
FROM LGCY_BILLG_ACCT B
WHERE B.BILLG_ACCT_ID = A.BILLG_ACCT_ID
AND B.LGCY_BLACT_END_DT = '9999-12-31')
;

COMMIT ;

DELETE
FROM BILLG_ACCT_DTD A
WHERE A.TM_PD_TYP_INST_NBR = 551
AND A.DT_TYPE_CD = 'DISCONNECT'
AND A.DT_STATUS_CD = 'AC'
AND EXISTS
( SELECT *
FROM LGCY_BILLG_ACCT B
WHERE B.BILLG_ACCT_ID = A.BILLG_ACCT_ID
AND B.LGCY_BLACT_END_DT = '9999-12-31')
;

COMMIT ;



am i missing out something ?? Do u feel any importance/difference it makes by the way they are written Rolling Eyes ??
Back to top
View user's profile Send private message Send e-mail
Bithead
Advanced


Joined: 03 Jan 2003
Posts: 550
Topics: 23
Location: Michigan, USA

PostPosted: Thu May 29, 2003 8:46 am    Post subject: Reply with quote

It looks to me like you are creating a backup, or at least a report, of the data (step 1) before you delete it (step 2). It is always a good idea to commit after the select to release any locks.
Back to top
View user's profile Send private message
Arun
Beginner


Joined: 24 Mar 2003
Posts: 13
Topics: 7
Location: Philadelphia, US.

PostPosted: Thu May 29, 2003 3:46 pm    Post subject: Reply with quote

Thank You Bithead, for you kind reply . Laughing
Back to top
View user's profile Send private message Send e-mail
Mukunda
Beginner


Joined: 11 Dec 2002
Posts: 46
Topics: 15

PostPosted: Sat Jun 21, 2003 9:12 pm    Post subject: Reply with quote

Arun
You might also be interested in Pranav Sampath's article (DB2 Magazine)
http://www.db2mag.com/db_area/archives/2002/q4/sampat.shtml 8)
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
Page 1 of 1

 
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