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!

Reuse Query result

SmidrebJun 25 2016 — edited Jun 25 2016

Hi All,

I have sub queries in a package that are frequent. How can I avoid copying and pasting the same  sub queries in multiple places? How can I reuse the result set.

The queries are very slow, I am trying to see if I can use some mechanism where I can store the result set from one query to be used in other proc or statements..

The queries are much more complicated than what I have given in the example below

proc1 as

Select

WITH a as

(select t1.code from t1, t2

where....),

col

FROM t

where a.gk= t.gk;

...

...

Insert into Auth_Customer  from above query ;

...

...

...

ENd proc1;

proc2 as

Select

WITH a as

(select t1.code from t1, t2

where....),

col

FROM t

where a.gk= t.gk

...

...

Insert into GK_REC from above query ;

...

...

...

End proc2;

How can I avoid above.

Thank you for all the help!!!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 23 2016
Added on Jun 25 2016
3 comments
1,241 views