cancel
Showing results for 
Search instead for 
Did you mean: 

Syntax Error

Former Member
0 Kudos
2,700

Hey out there. Was wondering if someone can take a look at this and see where I messed up at?

Thank you

Could not execute statement. syntax error near ',' on line 14 SQLCODE=-131, ODBC 3 STATE="42000" Line 26, column 1

/* FileVersion=3.14.101 */
-------------------------------------------------------------------------------
--  DT8281 - Trent 2016.07.27
--  1. Create table PUBLIC_EMAIL_DOMAIN
--  2. Insert records into table PUBLIC_EMAIL_DOMAIN
-------------------------------------------------------------------------------



--  1. Create table PUBLIC_EMAIL_DOMAIN
IF NOT EXISTS
    (SELECT 1
    FROM SYSTABLE
    WHERE table_name = 'PUBLIC_EMAIL_DOMAIN'
    )
BEGIN
    CREATE TABLE "DBA"."PUBLIC_EMAIL_DOMAIN"(
    "email_domain_name" CHAR(50) NOT NULL
    ,PRIMARY KEY ("email_domain_name" ASC) 
    )
END

GO

--  2. Insert records into table PUBLIC_EMAIL_DOMAIN
IF EXISTS
    (SELECT 1
    FROM SYSTABLE
    WHERE table_name = 'PUBLIC_EMAIL_DOMAIN'
    )

    IF (Select count(*) FROM PUBLIC_EMAIL_DOMAIN) = 0

    BEGIN
        INSERT INTO "DBA"."PUBLIC_EMAIL_DOMAIN"
        (email_domain_name)
        VALUES
        ('007addict.com') ,
        ('020.co.uk') ,
        ('123.com') ,
        ('123box.net') ,
        ('123india.com') ,
        ('123qwe.co.uk') ,

    END

Accepted Solutions (0)

Answers (1)

Answers (1)

VolkerBarth
Contributor

Just omit the last comma before the "END", i.e. close the SQL batch with

    ...
        ('123india.com') ,
        ('123qwe.co.uk')

    END

Aside: Unless you need T-SQL compatibility, I'd recommend to use SQL Anywhere with the original Watcom-SQL dialect instead of T-SQL. IMHO it makes nested IF statements easier to read (and check).