Re: Difference execute immediate within PL SQL

From: hrishy <hrishys_at_yahoo.co.uk>
Date: 16 Oct 2003 03:56:55 -0700
Message-ID: <4ef2a838.0310160256.238da9d8_at_posting.google.com>


Hi Michi

/*SOME HOW THIS STATEMENT I CANT COMPILE*/
    truncate table test_table;

This is static sql and hence it will not compile.Morever your not allowed to do DDL within pl/sql like that using static sql.The reason being oracle's philosophy of considering DDL as bad :-).even create table will not work ;-)     

/*BUT I CAN COMPILE THIS STATEMENT*/

   execute immediate 'truncate table test_table';

well this is dynamic sql and the compiler will not complain as it would consider this as a STRING.This would be evaluated at runtime and hence compiles without error.

You might wnat to check out begining sql programming by Tom Kyte Joel kallman and Sean Dillion co-authored by Howard Rogers <--my favourite teacher ;-)

regards
Hrishy Received on Thu Oct 16 2003 - 12:56:55 CEST

Original text of this message