The PPUPDATE user is used to store Prognoz Platform 9 distribution kit at database server. The distribution kit is saved to this user database and is taken from there on Prognoz Platform 9 update at user workstations. Depending on the MS SQL DBMS version, scripts used to create the PPUPDATE user are slightly different:
A user can be created using the following script:
execute sp_addlogin @loginame = 'PPUPDATE', @passwd = 'PPUPDATE', @defdb = 'master'
go
where
PPUPDATE - user name and password.
To run the script, the Query Analyzer application can be used, which is included in the standard package for both the front and back ends of Microsoft SQL Server DBMS.
A user must be created by the DBMS administrator.
The following script can be used to create a database:
use master;
go
create database PPUPDATE;
go
where
PPUPDATE - name of created database.
The script must run to grant permissions for the database to the ppupdate user:
use PPUPDATE
go
exec sp_changedbowner PPUPDATE
go
where:
PPUPDATE - database name.
ppupdate - user name.
The script1 and the script2 must be run consecutively to create tables in the database.
Script1:
create table B_UPD (
LNAME varchar(127) not null,
UPD numeric(8,0) not null,
STAMP datetime not null,
FNAME varchar(127) not null,
DNAME varchar(127) null,
FSIZE numeric(24,4) null
)
go
alter table B_UPD
add constraint PK_B_UPD primary key (LNAME, UPD)
go
create index IX_B_UPD on B_UPD (
LNAME
)
go
create table B_UPDD (
LNAME varchar(127) not null,
UPD numeric(8,0) not null,
DAT image null
)
go
alter table B_UPDD
add constraint PK_B_UPDD primary key (LNAME, UPD)
go
Script2:
if exists (select 1
from sysobjects
where id = object_id('tu_b_upd')
and type = 'TR')
drop trigger tu_b_upd
go
if exists (select 1
from sysobjects
where id = object_id('td_b_upd')
and type = 'TR')
drop trigger td_b_upd
go
if exists (select 1
from sysobjects
where id = object_id('ti_b_updd')
and type = 'TR')
drop trigger ti_b_updd
go
if exists (select 1
from sysobjects
where id = object_id('tu_b_updd')
and type = 'TR')
drop trigger tu_b_updd
go
/* Update trigger "tu_b_upd" for table "B_UPD" */
create trigger tu_b_upd on B_UPD for update as
begin
declare
@numrows int,
@numnull int,
@errno int,
@errmsg varchar(255)
select @numrows = @@rowcount
if @numrows = 0
return
/* Cannot modify parent code in "B_UPD" if children still exist in "B_UPDD" */
if update(LNAME) or
update(UPD)
begin
if exists (select 1
from B_UPDD t2, inserted i1, deleted d1
where t2.LNAME = d1.LNAME
and t2.UPD = d1.UPD
and (i1.LNAME != d1.LNAME
or i1.UPD != d1.UPD))
begin
select @errno = 50005,
@errmsg = 'Children still exist in "B_UPDD". Cannot modify parent code in "B_UPD".'
goto error
end
end
return
/* Errors handling */
error:
raiserror (N'%d: %s', 10, 1, @errno, @errmsg)
rollback transaction
end
go
/* Delete trigger "td_b_upd" for table "B_UPD" */
create trigger td_b_upd on B_UPD for delete as
begin
declare
@numrows int,
@errno int,
@errmsg varchar(255)
select @numrows = @@rowcount
if @numrows = 0
return
/* Delete all children in "B_UPDD" */
delete B_UPDD
from B_UPDD t2, deleted t1
where t2.LNAME = t1.LNAME
and t2.UPD = t1.UPD
return
/* Errors handling */
error:
raiserror (N'%d: %s', 10, 1, @errno, @errmsg)
rollback transaction
end
go
/* Insert trigger "ti_b_updd" for table "B_UPDD" */
create trigger ti_b_updd on B_UPDD for insert as
begin
declare
@numrows int,
@numnull int,
@errno int,
@errmsg varchar(255)
select @numrows = @@rowcount
if @numrows = 0
return
/* Parent "B_UPD" must exist when inserting a child in "B_UPDD" */
if update(LNAME) or
update(UPD)
begin
if (select count(*)
from B_UPD t1, inserted t2
where t1.LNAME = t2.LNAME
and t1.UPD = t2.UPD) != @numrows
begin
select @errno = 50002,
@errmsg = 'Parent does not exist in "B_UPD". Cannot create child in "B_UPDD".'
goto error
end
end
return
/* Errors handling */
error:
raiserror (N'%d: %s', 10, 1, @errno, @errmsg)
rollback transaction
end
go
/* Update trigger "tu_b_updd" for table "B_UPDD" */
create trigger tu_b_updd on B_UPDD for update as
begin
declare
@numrows int,
@numnull int,
@errno int,
@errmsg varchar(255)
select @numrows = @@rowcount
if @numrows = 0
return
/* Parent "B_UPD" must exist when updating a child in "B_UPDD" */
if update(LNAME) or
update(UPD)
begin
if (select count(*)
from B_UPD t1, inserted t2
where t1.LNAME = t2.LNAME
and t1.UPD = t2.UPD) != @numrows
begin
select @errno = 50003,
@errmsg = 'B_UPD" does not exist. Cannot modify child in "B_UPDD".'
goto error
end
end
return
/* Errors handling */
error:
raiserror (N'%d: %s', 10, 1, @errno, @errmsg)
rollback transaction
end
go
After all the steps have been completed successfully, the PPUPDATE user can be used to create a copy of Prognoz Platform 9 version to be updated at database server.
See also: