Pervasive - настройка
Модераторы: m0p3e, edward_K, Модераторы
Pervasive - настройка
Как настроить аналог SQL Server Service Manager в Pervasive?
Есть такой запрос на MS SQL Server. А как его выполнить в Pervasive?
Если видите смайлик, то он почему-то ставится вместо цифры 8 и никак не убирается?
declare @innum nvarchar(16),@innum_ nvarchar(16),
@nreckatos binary(8), @nrecspkatos binary(8), @nreckatosier binary(8),
@nreckaureff binary(8), @nrecexclassval binary(8), @nrecnaldrag binary(8),@k int,@nom bigint,
@katos binary(8)
set @nreckatos = (select max(f$nrec) from t$katos)
set @nrecspkatos = (select max(f$nrec) from t$spkatos)
set @nreckatosier = (select max(f$nrec) from t$katosier)
set @nreckaureff = (select max(f$nrec) from t$kaureff)
set @nrecexclassval = (select max(f$nrec) from t$exclassval)
set @nrecnaldrag = (select max(f$nrec) from t$naldrag)
declare @@kol float(8),@@innum varchar(15),@i int ,
@@nrec binary(8), @@classcode int ,@@classseg binary(8),@@ckatdrag binary(8)
declare B cursor for select f$kol, f$innum,f$nrec from test
open B
fetch next from B into @@kol,@@innum,@@nrec
while @@fetch_status = 0 begin
set @i= @@kol-1
while @i>0
begin
delete from katos_
delete from spkatos_
delete from katosier_
delete from kaureff_
delete from exclassval_
delete from naldrag_
insert into katos_ select * from kat where kat.f$nrec=@@nrec
set @nreckatos = substring(@nreckatos,1,2)+substring(cast(cast(@nreckatos as int)+1 as binary(8)),3,6)
update katos_ set katos_.f$nrec = @nreckatos
set @nom=cast(@@innum as bigint)+ cast(@@kol as bigint) - cast(@i as bigint)
update katos_ set katos_.f$innum = @nom
insert into spkatos_ select * from spkat where spkat.f$ckatos=@@nrec and spkat.f$cnastros=0x8000000000000004
set @nrecspkatos = substring(@nrecspkatos,1,2)+substring(cast(cast(@nrecspkatos as int)+1 as binary(8)),3,6)
update spkatos_ set spkatos_.f$nrec = @nrecspkatos where spkatos_.f$ckatos=@@nrec and spkatos_.f$cnastros=0x8000000000000004
insert into spkatos_ select * from spkat where spkat.f$ckatos=@@nrec and spkat.f$cnastros=0x8001000000000002
set @nrecspkatos = substring(@nrecspkatos,1,2)+substring(cast(cast(@nrecspkatos as int)+1 as binary(8)),3,6)
update spkatos_ set spkatos_.f$nrec = @nrecspkatos where spkatos_.f$ckatos=@@nrec and spkatos_.f$cnastros=0x8001000000000002
update spkatos_ set spkatos_.f$ckatos = @nreckatos
update spkatos_ set spkatos_.f$stoim = round (spkatos_.f$stoim/@@kol,2)
update spkatos_ set spkatos_.f$sumizn = round (spkatos_.f$sumizn/@@kol,2)
update spkatos_ set spkatos_.f$siznm = round (spkatos_.f$siznm/@@kol,2)
update spkatos_ set spkatos_.f$stoimps = round (spkatos_.f$stoimps/@@kol,2)
update spkatos_ set spkatos_.f$iznosps = round (spkatos_.f$iznosps/@@kol,2)
insert into katosier_ select * from ier where ier.f$CRECDS=@@nrec and ier.f$Cgroup=@@nrec
set @nreckatosier = substring(@nreckatosier,1,2)+substring(cast(cast(@nreckatosier as int)+1 as binary(8)),3,6)
update katosier_ set katosier_.f$nrec = @nreckatosier,katosier_.f$cgroup = @nreckatos where katosier_.f$CRECDS=@@nrec and katosier_.f$Cgroup=@@nrec
insert into katosier_ select * from ier where ier.f$CRECDS=@@nrec and ier.f$Cgroup=0x8000000000000000
set @nreckatosier = substring(@nreckatosier,1,2)+substring(cast(cast(@nreckatosier as int)+1 as binary(8)),3,6)
update katosier_ set katosier_.f$nrec = @nreckatosier where katosier_.f$CRECDS=@@nrec and katosier_.f$Cgroup=0x8000000000000000
update katosier_ set katosier_.f$crecds = @nreckatos
insert into kaureff_ select * from kau where kau.f$crec=@@nrec
set @nreckaureff = substring(@nreckaureff,1,2)+substring(cast(cast(@nreckaureff as int)+1 as binary(8)),3,6)
update kaureff_ set kaureff_.f$nrec = @nreckaureff,kaureff_.f$crec = @nreckatos
insert into exclassval_ select * from val where val.f$crec=@@nrec and val.f$wtable=3000
update exclassval_ set exclassval_.f$crec = @nreckatos
declare e cursor for
select f$classcode,f$cclassseg from exclassval_
open e
fetch next from e into @@classcode, @@classseg
while @@fetch_status = 0 begin
set @nrecexclassval = substring(@nrecexclassval,1,2)+substring(cast(cast(@nrecexclassval as int)+1 as binary(8)),3,6)
update exclassval_ set exclassval_.f$nrec = @nrecexclassval where exclassval_.f$cclassseg=@@classseg and exclassval_.f$classcode=@@classcode
fetch next from e into @@classcode, @@classseg
end
close e
deallocate e
insert into naldrag_ select * from drag where drag.f$ckatos=@@nrec
update naldrag_ set naldrag_.f$ckatos = @nreckatos
declare n cursor for
select f$ckatdrag from naldrag_
open n
fetch next from n into @@ckatdrag
while @@fetch_status = 0 begin
set @nrecnaldrag = substring(@nrecnaldrag,1,2)+substring(cast(cast(@nrecnaldrag as int)+1 as binary(8)),3,6)
update naldrag_ set naldrag_.f$nrec = @nrecnaldrag where naldrag_.f$ckatdrag=@@ckatdrag
fetch next from n into @@ckatdrag
end
close n
deallocate n
set @i= @i-1
insert into katos select * from katos_
insert into spkatos select * from spkatos_
insert into katosier select * from katosier_
insert into kaureff select * from kaureff_
insert into exclassval select * from exclassval_
insert into naldrag select * from naldrag_
end
fetch next from B into @@kol,@@innum,@@nrec
end
close B
deallocate B
Если видите смайлик, то он почему-то ставится вместо цифры 8 и никак не убирается?
declare @innum nvarchar(16),@innum_ nvarchar(16),
@nreckatos binary(8), @nrecspkatos binary(8), @nreckatosier binary(8),
@nreckaureff binary(8), @nrecexclassval binary(8), @nrecnaldrag binary(8),@k int,@nom bigint,
@katos binary(8)
set @nreckatos = (select max(f$nrec) from t$katos)
set @nrecspkatos = (select max(f$nrec) from t$spkatos)
set @nreckatosier = (select max(f$nrec) from t$katosier)
set @nreckaureff = (select max(f$nrec) from t$kaureff)
set @nrecexclassval = (select max(f$nrec) from t$exclassval)
set @nrecnaldrag = (select max(f$nrec) from t$naldrag)
declare @@kol float(8),@@innum varchar(15),@i int ,
@@nrec binary(8), @@classcode int ,@@classseg binary(8),@@ckatdrag binary(8)
declare B cursor for select f$kol, f$innum,f$nrec from test
open B
fetch next from B into @@kol,@@innum,@@nrec
while @@fetch_status = 0 begin
set @i= @@kol-1
while @i>0
begin
delete from katos_
delete from spkatos_
delete from katosier_
delete from kaureff_
delete from exclassval_
delete from naldrag_
insert into katos_ select * from kat where kat.f$nrec=@@nrec
set @nreckatos = substring(@nreckatos,1,2)+substring(cast(cast(@nreckatos as int)+1 as binary(8)),3,6)
update katos_ set katos_.f$nrec = @nreckatos
set @nom=cast(@@innum as bigint)+ cast(@@kol as bigint) - cast(@i as bigint)
update katos_ set katos_.f$innum = @nom
insert into spkatos_ select * from spkat where spkat.f$ckatos=@@nrec and spkat.f$cnastros=0x8000000000000004
set @nrecspkatos = substring(@nrecspkatos,1,2)+substring(cast(cast(@nrecspkatos as int)+1 as binary(8)),3,6)
update spkatos_ set spkatos_.f$nrec = @nrecspkatos where spkatos_.f$ckatos=@@nrec and spkatos_.f$cnastros=0x8000000000000004
insert into spkatos_ select * from spkat where spkat.f$ckatos=@@nrec and spkat.f$cnastros=0x8001000000000002
set @nrecspkatos = substring(@nrecspkatos,1,2)+substring(cast(cast(@nrecspkatos as int)+1 as binary(8)),3,6)
update spkatos_ set spkatos_.f$nrec = @nrecspkatos where spkatos_.f$ckatos=@@nrec and spkatos_.f$cnastros=0x8001000000000002
update spkatos_ set spkatos_.f$ckatos = @nreckatos
update spkatos_ set spkatos_.f$stoim = round (spkatos_.f$stoim/@@kol,2)
update spkatos_ set spkatos_.f$sumizn = round (spkatos_.f$sumizn/@@kol,2)
update spkatos_ set spkatos_.f$siznm = round (spkatos_.f$siznm/@@kol,2)
update spkatos_ set spkatos_.f$stoimps = round (spkatos_.f$stoimps/@@kol,2)
update spkatos_ set spkatos_.f$iznosps = round (spkatos_.f$iznosps/@@kol,2)
insert into katosier_ select * from ier where ier.f$CRECDS=@@nrec and ier.f$Cgroup=@@nrec
set @nreckatosier = substring(@nreckatosier,1,2)+substring(cast(cast(@nreckatosier as int)+1 as binary(8)),3,6)
update katosier_ set katosier_.f$nrec = @nreckatosier,katosier_.f$cgroup = @nreckatos where katosier_.f$CRECDS=@@nrec and katosier_.f$Cgroup=@@nrec
insert into katosier_ select * from ier where ier.f$CRECDS=@@nrec and ier.f$Cgroup=0x8000000000000000
set @nreckatosier = substring(@nreckatosier,1,2)+substring(cast(cast(@nreckatosier as int)+1 as binary(8)),3,6)
update katosier_ set katosier_.f$nrec = @nreckatosier where katosier_.f$CRECDS=@@nrec and katosier_.f$Cgroup=0x8000000000000000
update katosier_ set katosier_.f$crecds = @nreckatos
insert into kaureff_ select * from kau where kau.f$crec=@@nrec
set @nreckaureff = substring(@nreckaureff,1,2)+substring(cast(cast(@nreckaureff as int)+1 as binary(8)),3,6)
update kaureff_ set kaureff_.f$nrec = @nreckaureff,kaureff_.f$crec = @nreckatos
insert into exclassval_ select * from val where val.f$crec=@@nrec and val.f$wtable=3000
update exclassval_ set exclassval_.f$crec = @nreckatos
declare e cursor for
select f$classcode,f$cclassseg from exclassval_
open e
fetch next from e into @@classcode, @@classseg
while @@fetch_status = 0 begin
set @nrecexclassval = substring(@nrecexclassval,1,2)+substring(cast(cast(@nrecexclassval as int)+1 as binary(8)),3,6)
update exclassval_ set exclassval_.f$nrec = @nrecexclassval where exclassval_.f$cclassseg=@@classseg and exclassval_.f$classcode=@@classcode
fetch next from e into @@classcode, @@classseg
end
close e
deallocate e
insert into naldrag_ select * from drag where drag.f$ckatos=@@nrec
update naldrag_ set naldrag_.f$ckatos = @nreckatos
declare n cursor for
select f$ckatdrag from naldrag_
open n
fetch next from n into @@ckatdrag
while @@fetch_status = 0 begin
set @nrecnaldrag = substring(@nrecnaldrag,1,2)+substring(cast(cast(@nrecnaldrag as int)+1 as binary(8)),3,6)
update naldrag_ set naldrag_.f$nrec = @nrecnaldrag where naldrag_.f$ckatdrag=@@ckatdrag
fetch next from n into @@ckatdrag
end
close n
deallocate n
set @i= @i-1
insert into katos select * from katos_
insert into spkatos select * from spkatos_
insert into katosier select * from katosier_
insert into kaureff select * from kaureff_
insert into exclassval select * from exclassval_
insert into naldrag select * from naldrag_
end
fetch next from B into @@kol,@@innum,@@nrec
end
close B
deallocate B