Home » SQL & PL/SQL » SQL & PL/SQL » WITH STATEMENT in PL-SQL procedure block
WITH STATEMENT in PL-SQL procedure block [message #9814] |
Fri, 05 December 2003 10:30  |
Alvin
Messages: 7 Registered: December 2000
|
Junior Member |
|
|
Dear all,
Would anyone know if it's possible to include a WITH block inside an anonymous PL/SQL block? Following is the code I would like to perform :
DECLARE
WITH test AS (
SELECT * from subscribers
where id_subs = 1749
);
BEGIN
SELECT * from test;
END;
/
It doesn't work, and I'm not sure if its my syntax, or just the PL/SQL doesn't offer this option.
I am trying to avoid using a cursor because I'm running subsequent SQL select statments to get summarized data from the sql block.
Thanks in advance!
Regards,
Alvin
|
|
|
|
Re: WITH STATEMENT in PL-SQL procedure block [message #9817 is a reply to message #9816] |
Fri, 05 December 2003 12:15   |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
Actually, you can't do what you are asking in 9i either. The WITH clause is only viable in a single SQL construct. In a PL/SQL context, if you need to use the results of that same query over and over again within a proc and the query is expensive, you would need to load the results into a GTT or collection at the start of the proc.
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri May 16 06:29:02 CDT 2025
|