Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Dynamic "In" w a Cursor in a Package
"DA Morgan" <damorgan_at_psoug.org> wrote in message news:1190564835.98331_at_bubbleator.drizzle.com...
> CapCity wrote:
> > This is possibly one of the most asked about capabilities and I find > myself referring people to this demo more often than any other. > > Go to www.psoug.org > Click on Morgan's Library > Click on Conditions > Scroll down to "Complex IN Demo" > -- > Daniel A. Morgan > University of Washington > damorgan_at_x.washington.edu (replace x with u to respond) > Puget Sound Oracle Users Group > www.psoug.org
Oracle 10.2.0.1, WindowsXP Pro SP2
When I enter the following command at the SQL*Plus prompt:
SELECT COUNT(*) FROM DBA_TABLES WHERE OWNER IN ( 'SYS','SYSTEM'); I receive a count of 844.
However, when I attempt the "Complex IN" I keep receiving a count of 0.
DECLARE
v_user VARCHAR2(30) := '''SYS'',''SYSTEM''';
v_cnt PLS_INTEGER := 0;
BEGIN
SELECT COUNT(*) INTO v_cnt FROM dba_tables WHERE owner IN (v_user);
DBMS_OUTPUT.PUT_LINE(v_cnt);
END;
Can the Complex IN work with strings? If so, what am I doing wrong? I was
able to get a LIKE to work but can't seem to get the IN logic working.
LIKE Code:
DECLARE
v_user VARCHAR2(30) := 'SYS%';
v_cnt PLS_INTEGER := 0;
BEGIN
SELECT COUNT(*) INTO v_cnt FROM dba_tables WHERE OWNER LIKE v_user;
DBMS_OUTPUT.PUT_LINE(v_cnt);
END;
Thanks for any insights.
Received on Sun Sep 23 2007 - 15:03:50 CDT
![]() |
![]() |