Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL EXECUTE IMMEDIATE won't parse...help
you've missed out the second concatenation..
should read
EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || tab_name || ' INTO rows';
Cheers
Steve Bright
steve.bright_at_capgemini.co.uk
Mark Brunkhart wrote in message <379E19A9.D8DB6DBF_at_ricochet.net>...
>I'm having trouble getting EXECUTE IMMEDIATE to parse in Oracle 8. The
>following shows a SQL*PLUS session and the resultant error. The command
>is straight out of the PL/SQL User's Guide and Reference. I'm guessing
>this may have to do with the fact that the EXECUTE command is getting
>converted into a BEGIN..END pair. Anyone know what's up?
>
>SQL> CREATE FUNCTION row_count (tab_name CHAR) RETURN INT AS
> 2 rows INT;
> 3 BEGIN
> 4 EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || tab_name INTO rows;
> 5 RETURN rows;
> 6 END;
> 7 /
>
>Warning: Function created with compilation errors.
>
>SQL> show errors function row_count;
>Errors for FUNCTION ROW_COUNT:
>
>LINE/COL ERROR
>--------
>-----------------------------------------------------------------
>4/11 PLS-00103: Encountered the symbol "IMMEDIATE" when expecting
>one
> of the following:
> := . ( @ % ;
Received on Wed Jul 28 1999 - 05:48:15 CDT