View previous topic :: View next topic |
Author |
Message |
Arun Beginner
Joined: 24 Mar 2003 Posts: 13 Topics: 7 Location: Philadelphia, US.
|
Posted: Wed May 28, 2003 5:02 pm Post subject: Is this the way this SQL is required? |
|
|
Hi,
One of our production maintenance job has a sysin that has both the queries below. I'm just confused. 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.
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 ?? |
|
Back to top |
|
|
Bithead Advanced
Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Thu May 29, 2003 8:46 am Post subject: |
|
|
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 |
|
|
Arun Beginner
Joined: 24 Mar 2003 Posts: 13 Topics: 7 Location: Philadelphia, US.
|
Posted: Thu May 29, 2003 3:46 pm Post subject: |
|
|
Thank You Bithead, for you kind reply . |
|
Back to top |
|
|
Mukunda Beginner
Joined: 11 Dec 2002 Posts: 46 Topics: 15
|
|
Back to top |
|
|
|
|