1 year ago

#326837

test-img

Nicolas Pacheco

expected something between the beginning of the request and the 'IF' keyword error when using IF in TeraData

I am trying to make a "drop if exist" in TeraData with the following statement

SELECT 1 
FROM DBC.TABLES 
WHERE DatabaseName = 'test1'
  AND TableName = 'test2';
  

IF ACTIVITYCOUNT = 0 THEN .GOTO l2; -- no result, skip SQL 1

DROP TABLE test1.test2;

.EXIT;  -- don't run SQL2

.LABEL l2;

   IF hNoAccts = 1 THEN
     INSERT INTO temp_table VALUES (hNoAccts, 'One Customer');
   END IF;
END

But I got the error "Syntax error: expected something between the beginning of the request and the 'IF' keyword." I also tried with ".IF" but I got the same error. Does anyone know how to do the drop if exist or why this error is occurring? Thankss

sql

teradata

teradata-sql-assistant

teradatasql

0 Answers

Your Answer

Accepted video resources