Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to Avoid repeating of query(rewrite query)

743620Apr 24 2012 — edited Apr 25 2012
Have the follwoing select statement in cursor. How can i avoid repeating the same select statement but with different columns n the where clause conditions.

for cur1 in (SELECT d.ID,
name
type,
code
FROM tableA ,c
tableB d
WHERE c.id = d.id
AND d.vin_id IN
-- select statement
(SELECT b.id
FROM tableA a,
TableB b
WHERE a.id = b.id
GROUP BY b.id,
b.code
HAVING COUNT(1) = 1
)
AND d.code IN
--same select stmt used before with diff col
(SELECT b.id
FROM tableA a,
TableB b
WHERE a.id = b.id
GROUP BY b.id,
b.code
HAVING COUNT(1) = 1
))
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 23 2012
Added on Apr 24 2012
11 comments
321 views