DECLARE @WineID Char(36),@AreaID Char(36),@ChateauID Char(36)
,@wineVarietyID char(36),@Names NVARCHAR(100);
Declare @WineVarietyEn nvarchar(50), @WineVarietyCn nvarchar(50)
Declare @AliasCn nvarchar(max), @AliasEn nvarchar(max),@AliasCnCount int,@AliasEnCount int
Declare @GrapeEnName nvarchar(max), @GrapeCnName nvarchar(max), @GrapeCount int
Declare @ChateauCn nvarchar(max), @ChateauEn nvarchar(max)
Declare @AreaCn nvarchar(max), @AreaEn nvarchar(max)
Delete FROM LucenIndexTab;
BEGIN
--定义游标.
DECLARE WineCursor CURSOR FOR
Select ID,Names,AreaID,ChateauID,wineVarietyID
From WineIndexs Order by hitcount --
--where ID='E4907C1D-699F-48A8-9B86-45EB652FDB96'
--FOR UPDATE;
--打开游标.
OPEN WineCursor;
--填充数据.
FETCH NEXT FROM WineCursor INTO @WineID,@Names,@AreaID,@ChateauID,@wineVarietyID;
--假如检索到了数据,才处理.
WHILE @@fetch_status = 0
BEGIN
PRINT '+++++++++++++++++++++++++++++++++++++++++++++++++++++';
PRINT @WineID+'名称:'+@Names;
PRINT '+++++++++++++++++++++++++++++++++++++++++++++++++++++';
--更新数据.
-- UPDATE
-- WineIndexs
-- SET
-- Names = Names + '更新'
--
-- WHERE
-- CURRENT OF WineCursor;
-- 填充下一条数据.
-- 创建数据库
----下边是使用自定义函数部分
---酒种类
set @WineVarietyEn=(select [foreignName] from GetWineVarietyEn(@wineVarietyID));
set @WineVarietyCn=(select [chineseName] from GetWineVarietyCn(@wineVarietyID));
--别名
set @AliasCn=(select Alias from GetUnionAliasTab(@WineID,1));
set @AliasEn=(select Alias from GetUnionAliasTab(@WineID,0));
set @AliasCnCount=(select AliasCount from GetUnionAliasTab(@WineID,1));
set @AliasEnCount=(select AliasCount from GetUnionAliasTab(@WineID,0));
--葡萄种类
set @GrapeEnName=(select GrapeName from GetUnionGrapeTab(@WineID,0));
set @GrapeCnName=(select GrapeName from GetUnionGrapeTab(@WineID,1));
set @GrapeCount=(select GrapeCount from GetUnionGrapeTab(@WineID,0));
-- 酒庄名称
set @ChateauEn=(select [foreignName] from GetChateauEn(@ChateauID));
set @ChateauCn=(select * from GetChateauCn(@ChateauID));
-- 产区名称
set @AreaCn=(select [chineseName] from GetAreaCn(@AreaID));
set @AreaEn=(select [foreignName] from GetAreaEn(@AreaID));
----结束使用自定义函数部分
---插入数据到新表(LucenIndexTab)
insert into LucenIndexTab select *
,@WineVarietyEn,@WineVarietyCn,@AliasCn,@AliasEn,@AliasCnCount,@AliasEnCount
,@GrapeEnName,@GrapeCnName,@GrapeCount,@ChateauEn,@ChateauCn
,@AreaEn,@AreaCn
from WineIndexs where ID=@WineID
print '中文别名:'+@AliasCn
print 'e文别名:'+@AliasEn
PRINT '----------------------------------------------------';
print '葡萄中文名:'+@GrapeEnName
print '葡萄e文名:'+@GrapeCnName
PRINT '----------------------------------------------------';
print '产区中文名:'+@AreaCn
print '产区e文名:'+@AreaEn
FETCH NEXT FROM WineCursor INTO @WineID,@Names,@AreaID,@ChateauID,@wineVarietyID;
END;
--关闭游标
CLOSE WineCursor;
--释放游标.
DEALLOCATE WineCursor;
END;
Go
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。