Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Sub-query in Oracle cursor

Re: Sub-query in Oracle cursor

From: Daniel Morgan <damorgan_at_exesolutions.com>
Date: Sun, 11 Aug 2002 15:13:32 +0100
Message-ID: <3D56710C.DA98E4F2@exesolutions.com>


Ola wrote:

> I'm trying to create a cursor with a subquery and this seems to upset
> Oracle...
> The following snippet shows what I'm trying to do.
>
> CREATE OR REPLACE PROCEDURE PRC_MyTest AS
>
> CURSOR MyCursor IS
> SELECT
> (SELECT COUNT(*) FROM Table1) MyCount ,
> Column1,
> Column2
> FROM Table1;
>
> BEGIN
> return;
> END;
>
> The procedure compiles when I take out the line "(SELECT COUNT(*) FROM
> MyTable) MyCount ,"
>
> Executing the SQL below, in isolation from the procedure also works
> fine from the command line
>
> SELECT (SELECT COUNT(*) FROM Table1) MyCount,
> Column1,
> Column2
> FROM Table1;
>
> Any ideas of what the problem is and any solutions will save my sanity
> and hence will be most appreciated.
>
> Thanks

Oracle's not having a problem with a sub-query: You are.

This is no way to write a sub-query.

Please check Oracle documentation, web sites, books, etc. and learn the correct syntax.

If, from the above, I had a clue as to what you are try to do I'd give you the correct syntax but your statement is so tortured I can't even guess.

Daniel Morgan Received on Sun Aug 11 2002 - 09:13:32 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US