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

Home -> Community -> Usenet -> c.d.o.server -> Re: Subquery not valid in a cursor?

Re: Subquery not valid in a cursor?

From: John Darrah <jdarrah_at_veripost.net>
Date: Thu, 4 Apr 2002 17:47:41 +0000 (UTC)
Message-ID: <8bca38159541be215065d640d46f7e9f.36240@mygate.mailgate.org>


This type of ref cursor will still be parsed via the pl/sql parser. What you need to do is change your cursor into a string and pass that to the open statement. Instead of OPEN curs FOR (your cursor here), do something like the following:

m_sql_string VARCHAR2(30000);
BEGIN
m_sql_string := 'SELECT ... (the rest of your select statement here)'; OPEN curs FOR m_sql_string;

This way the pl/sql parser won't try to parse the statement at compile time and it will simply pass the string to the sql engine at run time. A couple of things to note, if there is an error in your sql statment, it will be harder to track down since it will be a runtime error not a compile time error. One thing to look out for is placing single quotes around literals, you'll need to use chr(39) and the || operator to make that work. One last thought, couldn't your subquery be put into an inline view? I know those work in pl/sql version 8.1.6.

-- 
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Received on Thu Apr 04 2002 - 11:47:41 CST

Original text of this message

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