home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 December
/
PCWorld_1998-12_cd.iso
/
software
/
sybase
/
ASA
/
asa60.exe
/
data1.cab
/
scripts_files
/
upgrinit.sql
< prev
Wrap
Text File
|
1998-07-27
|
4KB
|
164 lines
create variable @dbo_userid int
go
create variable @dbo_exists char(1)
go
create variable @upper_case_views char(1)
go
create variable @finished char(1)
go
create variable @collation_size smallint
go
create variable @upgrade_type int
go
create variable @tableid int
go
create variable @passworddomain int
go
create variable @version int
go
create variable @newest_database_version int
go
create variable @flags binary(256)
go
set @upper_case_views = 'Y'
go
set @finished = 'N'
go
set @upgrade_type = 0
go
set @dbo_exists = 'N'
go
set @newest_database_version = 37
go
set @flags = NULL
go
if exists( select * from SYS.SYSUSERPERM where user_name = 'dbo' ) then
set @dbo_exists = 'Y';
select user_id into @dbo_userid from SYS.SYSUSERPERM where user_name = 'dbo';
if not exists( select * from SYS.SYSTABLE
where table_name = 'sysalternates' and creator = @dbo_userid ) then
set @upper_case_views = 'N';
end if;
end if
go
select width into @collation_size
from SYS.SYSTABLE t, SYS.SYSCOLUMN c
where table_name = 'SYSCOLLATION'
and t.table_id = c.table_id
and creator = 0
and column_name = 'collation_order'
go
if not exists( select * from SYS.SYSTABLE
where table_name = 'SYSPROCEDURE' and creator = 0 ) then
set @upgrade_type = 101 ;
else
if not exists( select * from SYS.SYSTABLE
where table_name = 'SYSUSERMESSAGES' and creator = 0 ) then
set @upgrade_type = 2 ;
end if;
end if
go
if @upgrade_type <> 0 then
if @dbo_exists = 'Y' then
set @upgrade_type = 101 ;
end if;
set @finished = 'Y';
end if
go
if @finished = 'N' then
select domain_id into @passworddomain
from SYS.SYSCOLUMN c, SYS.SYSTABLE t
where column_name = 'password'
and table_name = 'SYSUSERPERM'
and c.table_id = t.table_id;
if @passworddomain = 8 then
set @upgrade_type = 3 ;
set @finished = 'Y';
end if;
end if
go
if @finished = 'N' then
if not exists( select * from SYS.SYSTABLE
where table_name = 'SYSREMOTETYPE' and creator = 0 ) then
set @upgrade_type = 4 ;
set @finished = 'Y';
end if;
end if
go
if @finished = 'N' then
select table_id into @tableid
from SYS.SYSTABLE
where table_name = 'SYSCOLPERM'
and creator = 0;
if not exists( select * from SYS.SYSCOLUMN
where table_id = @tableid
and column_name = 'privilege_type' ) then
set @upgrade_type = 5 ;
set @finished = 'Y';
end if;
end if
go
if @finished = 'N' then
select db_property( 'FileVersion' ) into @version;
if @version >= 33 and
@version <= 35 then
if @version = 33 then
set @upgrade_type = 6 ;
set @finished = 'Y';
else
if exists( select * from SYS.SYSINFO where default_collation
in ('SJIS', 'SJIS2', 'EUC_JAPAN', 'EUC_CHINA', 'EUC_TAIWAN', 'EUC_KOREA', 'UTF8' ) ) then
set @upgrade_type = 7 ;
set @finished = 'Y';
end if;
end if;
end if;
end if
go
if @finished = 'N' then
if not exists( select * from SYS.SYSTABLE
where table_name = 'SYSTYPEMAP' and creator = 0 ) then
set @upgrade_type = 8 ;
set @finished = 'Y';
end if;
end if
go
if @finished = 'N' then
if not exists( select * from SYS.SYSTABLE
where table_name = 'SYSLOGIN' and creator = 0 ) then
set @upgrade_type = 9 ;
set @finished = 'Y';
end if;
end if
go
if @finished = 'N' then
if not exists( select * from SYS.SYSTABLE
where table_name = 'SYSJAR' and creator = 0 ) then
set @upgrade_type = 10 ;
set @finished = 'Y';
end if;
end if
go
if @finished = 'N' then
set @upgrade_type = 100 ;
set @finished = 'Y';
end if
go
drop variable @dbo_userid
go
drop variable @finished
go
drop variable @tableid
go
drop variable @passworddomain
go
DROP variable @version
go
DROP variable @dbo_exists
go