Re: Truncating a table in Pro*C

From: Scott Urman <surman_at_wwsun10.us.oracle.com>
Date: Thu, 9 Jun 1994 22:38:34 GMT
Message-ID: <1994Jun9.223834.27874_at_oracle.us.oracle.com>


In article <2t4pb4$jda_at_scafell.gtl.demon.co.uk>, lts_at_gtl.demon.co.uk (Lincoln Scott) writes:
|> Dear netters,
|>
|> I'm running Oracle 7 on Sun 4.1.3 and have written some code to truncate a table.
|> Here's a simplified fragment:
|>
|> #include "blah.h"
|>
|> EXEC SQL BEGIN DECLARE SECTION;
|> VARCHAR sqlstmt[2000];
|> EXEC SQL END DECLARE SECTION;
|>
|> main()
|> {
|>
|> /* connect to database removed */
|>
|> strcpy(sqlstmt.arr, "truncate table spdata");
|> sqlstmt.len = strlen(sqlstmt.arr);
|>
|> EXEC SQL PREPARE S FROM :sqlstmt;
|>
|> EXEC SQL EXECUTE S;
|> }
|>
|> Unfortunately, when I step through the code in the debugger, it seems that
|> the truncate occurs at the PREPARE, not at the EXECUTE. I've looked through
|> the guide to Precompilers and no mention is made of using TRUNCATE, whether
|> is allowed, not allowed, recommended, not recommended etc. Can someone tell
|> me why this is happening?
|>
|> Although it appears irrelevant in the above example when the truncation occurs,
|> in the real code it matters heaps.
|>
|> Thanks in advance,
|>
|> Lincoln.

This is because this is a DDL statement. DDL statements are executed at the parse, which is the PREPARE. Received on Fri Jun 10 1994 - 00:38:34 CEST

Original text of this message