Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: syntax error
Karsten Schenk wrote:
> I 'm a beginner and I have following question:
> Something seems to be wrong with the syntax of these lines.
> It must be something tiny.
> Can anyone help me?
>
> EXECUTE IMMEDIATE 'SELECT COUNT(*) - COUNT ('|| c || ') AS nulls,
> COUNT(DISTINCT ' || c || ') AS different , COUNT ('||c||') AS total'
> FROM ' || t INTO nulls, different, total;
> EXECUTE IMMEDIATE 'INSERT INTO ' || dest || ' (id, nulls, different,
> total) VALUES ( :1, :2, :3, :4)' USING (id, nulls, different, total);
>
> Thanks in advance
>
> Karsten
It is almost always beter to write NDS in the following fashion.
DECLARE
sqlstr := '<your SQL statement here>';
BEGIN
dbms_output.put_line(sqlstr); -- delete line when it works.
EXECUTE IMMEDIATE sqlstr
USING (v1, v2, v3, v4);
END;
/
As it allows you to visually see the mess you asking Oracle to run.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Thu Jun 22 2006 - 12:48:37 CDT
![]() |
![]() |