All Forums Database
neetu6 2 posts Joined 08/15
11 Aug 2015
[Teradata Database] [3932] Only an ET or null statement is legal after a DDL Statement

I am trying to convert SQL query to Teradata. The below if clause is giving me an error "Statement 1: IF Failed.  [3706] Syntax error: expected something between the beginning of the request and the 'if' keyword."              
if OBJECT_ID('temp db.#temp_tick') is not null
DROP TABLE #temp_tick
and In next part of the query, I am creating a table, insert into and then a select from. And ended up with an error "[Teradata Database] [3932] Only an ET or null statement is legal after a DDL Statement."
 create volatile table #temp_tick
( BNK_NUM Varchar(2),
CUST_FAC Varchar(10),
FAC_NUM Varchar(10),
TICKind varchar(1));
 
insert into #temp_tick
select cast(tick.BNK_NUM as Varchar(2)) AS BNK_NUM,
cast(tick.CUST_FAC as Varchar(10)) AS CUST_FAC,
cast(tick.FAC_NUM as Varchar(10)) AS FAC_NUM
from tablename
group by 
tick.BNK_NUM,
tick.CUST_FAC,
tick.FAC_NUM
Any help is appreciated.
 
Thanks in advance!
neetu

neetu6 2 posts Joined 08/15
13 Aug 2015

Can someone help me with this ??
 
thanks,
neetu

dnoeth 4628 posts Joined 11/04
13 Aug 2015

SQL is a language and not a specific product, even if Microsoft tries to brainwash people to use it for SQL Server :-)
 
#1:

if OBJECT_ID('temp db.#temp_tick') is not null
DROP TABLE #temp_tick

is MS specific syntax which is not supported in Teradata.
#2:
 
Which client do you use for submitting this SQL?
In Teradata a DDL statement must be commited before you can do anything else, so depending on your session mode (and a possible AutoCommit in your client) you might need to add COMMIT; or ET; after the CREATE.
 
Finally you don't specify a Primary Index so it will probably default to the 1st column, BNK_NUM, which might result in bad distribution.

Dieter