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

asked 26 Jan '17, 23:21

mlenis's gravatar image

mlenis
11112
accept rate: 0%

edited 27 Jan '17, 01:56

Volker%20Barth's gravatar image

Volker Barth
40.1k361549819


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).

permanent link

answered 27 Jan '17, 02:03

Volker%20Barth's gravatar image

Volker Barth
40.1k361549819
accept rate: 34%

edited 27 Jan '17, 02:05

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×43
×19

question asked: 26 Jan '17, 23:21

question was seen: 2,250 times

last updated: 27 Jan '17, 02:05