Обновление хранимых процедур при помощи isql.exe
Релиб
Форумы       Участники    Календарь    Кто он-лайн?
Добро пожаловать, гость ( Вход | Регистрация )
        



Обновление хранимых процедур при помощи... Expand / Collapse
Автор
Сообщение
13.05.2006 17:05
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

участник
Last Login: 17.10.2006 7:27
Сообщ.: 113, Visits: 1 241
Необходимо удобным способом отдавать скрипты обновления БД клиенту. Он просто запускает bat файл и всё.

Вызываю файл со скриптом создания хранимой процедуры, но вылетают ошибки. в Query Analyzer проходит нормально...

Сообщ. #896919
13.05.2006 17:19


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

модератор
Last Login: 29.10.2007 14:45
Сообщ.: 1 833, Visits: 16 863
Пример скрипта и bat файла приведите.

Скорее всего проблема в базе по дефолту или пермишенах.

Сообщ. #896921
13.05.2006 18:04
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

участник
Last Login: 17.10.2006 7:27
Сообщ.: 113, Visits: 1 241
          bat файл

isql -S renat -d concierge -U sa -P -i files.sql -b

           files.sql

:r struct\location.sql

:r sp\spCreateKey.sql

         location.sql

-- Изменение полей таблицы

alter table dbo.tblKeys  
   alter column KeyLocation varchar(50)

alter table dbo.tblBuildingBooking
   alter column BookingLocation varchar(50)

alter table dbo.tblBuildingResources 
   alter column ResourceLocation varchar(50)

       spCreateKey.sql

-- Добавление ресурса
CREATE PROCEDURE spCreateKey
(
   @userid             int,
   @location           varchar(50),
   @keyAuthorization   varchar(250),
   @contractor         varchar(50),
   @keyLocation        varchar(500), 
   @notes              varchar(250)  
)
AS
BEGIN

 
   insert
   into tblKeys(location, status,keyAuthorization,
                contractor, keyLocation, notes,
                lastupdated, updatedby)
   values(@location, 1,@keyAuthorization, @contractor,
          @keyLocation, @notes,
          getdate(), @userid)
 
END

ошибка в консоли

F:\Security\update>isql -S renat -d concierge -U sa -P -i files.sql -b
1> 13> 14> 50> Msg 111, Level 15, State 1, Server RENAT, Line 23
'CREATE PROCEDURE' must be the first statement in a query batch.
Msg 137, Level 15, State 2, Server RENAT, Line 40
Must declare the variable '@location'.


 

Сообщ. #896923
13.05.2006 18:17


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

модератор
Last Login: 29.10.2007 14:45
Сообщ.: 1 833, Visits: 16 863
Перед CREATE PROCEDURE и после END (завершение создания процедуры)  поставьте GO
Сообщ. #896925
13.05.2006 19:24
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

участник
Last Login: 17.10.2006 7:27
Сообщ.: 113, Visits: 1 241
GO

-- Добавление ресурса
CREATE PROCEDURE spCreateKey1
(
   @userid             int,
   @location           varchar(50),
   @keyAuthorization   varchar(250),
   @contractor         varchar(50),
   @keyLocation        varchar(500), 
   @notes              varchar(250)  
)
AS
BEGIN

 
   insert
   into tblKeys(location, status,keyAuthorization,
                contractor, keyLocation, notes,
                lastupdated, updatedby)
   values(@location, 1,@keyAuthorization, @contractor,
          @keyLocation, @notes,
          getdate(), @userid)
 
END
GO

вот что получаю

D:\update>isql -S renat -d concierge -U sa -P -i files.sql -b
1> 13> 14> 50> Msg 170, Level 15, State 1, Server RENAT, Line 20
Line 20: Incorrect syntax near 'GO'.
Msg 111, Level 15, State 1, Server RENAT, Line 23
'CREATE PROCEDURE' must be the first statement in a query batch.
Msg 137, Level 15, State 2, Server RENAT, Line 40
Must declare the variable '@location'.

Сообщ. #896926
13.05.2006 19:33


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

модератор
Last Login: 29.10.2007 14:45
Сообщ.: 1 833, Visits: 16 863
В конце первого файла поставьте GO.

В аналайзере вы запускаете по одному файлу, по этому и работает. Это тоже самое, что написать следующее:

select '1'

--go

create procedure tratata

as

begin

print ''

end

Если раскоментировать "--Go", то работать будет. Иначе процедура не создастся.

Сообщ. #896927
14.05.2006 10:21
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

участник
Last Login: 17.10.2006 7:27
Сообщ.: 113, Visits: 1 241
Добавил GO в конец первого файла

D:\update>isql -S renat -d concierge -U sa -P -i files.sql -b
1> 14> 15> 16> Msg 170, Level 15, State 1, Server RENAT, Line 11
Line 11: Incorrect syntax near 'go'.

тогда он на go  в первом файле ругается

Сообщ. #896937
14.05.2006 11:17
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

участник
Last Login: 17.10.2006 7:27
Сообщ.: 113, Visits: 1 241
вот так заработало

 files.sql

:r struct\location.sql

go

:r sp\spCreateKey.sql

go

Сообщ. #896939
« пред. тема | след. тема »


Эту тему читают Expand / Collapse
Посетители: