on ‎2017 Jan 26 11:21 PM
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
Request clarification before answering.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.