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: Materialized view dynamic row count

Re: Materialized view dynamic row count

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Wed, 12 Oct 2005 17:30:18 +0800
Message-ID: <434CD7AA.2441@yahoo.com>


Geoff Muldoon wrote:
>
> postbus_at_sybrandb.demon.nl says...
> > <geoff.muldoon_at_trap.gmail.com> wrote:
> > >
> > >I am in the habit whenever using execute immediate of declaring a varchar2
> > >named v_sql, populating the string and then calling it. Had tried:
> > >
> > >v_sql := 'select count(*) from '||c.view_name||' into '||l_count;
> > >execute immediate v_sql;
> > >
> > >and this was failing.
> >
> > The correct syntax is, IIRC, execute immediate into variable.
> >
>
> Thanks Sybrand,
>
> v_sql := 'select count(*) from '||c.view_name;
> execute immediate v_sql into l_count;
>
> work perfectly (as did Connor's advice), and additionally enables me to
> maintain my preferred coding style.
>
> Sometimes it's just the littlest things ...
>
> Cheers,
>
> Geoff M

You might to consider

v_sql := 'select count(*) from "'||c.view_name||'"';

which is a tag more secure

-- 
Connor McDonald
Co-author: "Mastering Oracle PL/SQL - Practical Solutions"
Co-author: "Oracle Insight - Tales of the OakTable"

web: http://www.oracledba.co.uk
web: http://www.oaktable.net
email: connor_mcdonald_at_yahoo.com


"Semper in excremento, sole profundum qui variat."

------------------------------------------------------------
Received on Wed Oct 12 2005 - 04:30:18 CDT

Original text of this message

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