Неверный синтаксис рядом с ключевым словом «конец» - PullRequest
0 голосов
/ 14 ноября 2011

Кто-нибудь может мне помочь?

Я не знаю, почему следующий SQL дает синтаксическую ошибку:

if not exists (select 1 from sysobjects where type='U' and name='pg_result')
    create table pg_result (parent char(10), child char(10)) 
else
    delete from pg_result
end if

Я получаю следующую ошибку:

[Ошибка] Строки сценария: 141-146

Неверный синтаксис рядом с ключевым словом «конец».

Сообщение: 156, Уровень: 15, Состояние: 2

Сервер: SYBDEV, строка: 5

Я работаю:

Adaptive Server Enterprise / 12.5.4 / EBF 16785 ESD # 10 / P / Sun_svr4 /OS 5.8 / ase1254 / 2159/64-bit / FBO / Mon 2 ноября 13:08:08 2009

Есть идеи, пожалуйста?

Ответы [ 2 ]

2 голосов
/ 14 ноября 2011

Вам не нужно end, если вы не используете begin

1 голос
/ 14 ноября 2011

попробовать

if not exists (select 1 from sysobjects where type='U' and name='pg_result')
    create table pg_result (parent char(10), child char(10)) 
else
    delete from pg_result

или

if not exists (select 1 from sysobjects where type='U' and name='pg_result')
begin
    create table pg_result (parent char(10), child char(10)) 
end
else
begin
    delete from pg_result
end

см. http://infocenter.sybase.com/help/topic/com.sybase.help.ase_15.0.commands/html/commands/commands61.htm

...