国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > SQL Server > 正文

SQL Server靜態頁面導出技術4

2024-08-31 00:50:19
字體:
來源:轉載
供稿:網友
本段文章節選自鐵道出版社新出的《用BackOffice建立Intranet/Extranet應用》一書(現已在海淀圖書城有售)。本書詳盡地講述了如何使用微軟BackOffice系列產品來組建Intranet/Extranet應用。通過它您將掌握NT的安裝和設置、使用IIS建立Web站點、通過ILS建立網絡會議系統、用Exchange建立企業的郵件和協作系統、用SQL Server建立Web數據庫應用、用PRoxy Server建立同Internet安全可靠的連接、用Media Server建立網絡電視臺/廣播站、用Chart server建立功能強大的聊天室、用Site Server建立個性化的郵件列表和分析網站的訪問情況、用Commerce Server建立B2B或B2C的電子商務網站。此外本書還對網絡的安全性進行了討論,從而指導您建立一個更為健壯和安全的網絡應用。閱讀本書之后,您將發現實現豐富多彩的網絡應用原來這樣簡單……
絕對原創,歡迎轉載。但請務必保留以上文字。


use test
go
declare
    @riqi  varchar(20),
    @filepath  varchar(255),
    @listfile  varchar(255),
    @command varchar(255)
set @riqi=left(convert(varchar(40),getdate(),20),10)
set @filepath='d:/webout/'+@riqi+'/'
set @command='md '+@filepath
execute master.dbo.Xp_cmdshell @command
set @command='md '+@filepath+'images'
execute master.dbo.Xp_cmdshell @command
set @command ='copy d:/test/files/*.* d:/webout/'+@riqi+'/'
execute master.dbo.Xp_cmdshell @command
set @command ='copy d:/test/files/images/*.* d:/webout/'+@riqi+'/images/'
execute master.dbo.Xp_cmdshell @command
set @command ='copy d:/test/'+@riqi+'/*.* d:/webout/'+@riqi+'/'
execute master.dbo.Xp_cmdshell @command
set @listfile=@filepath+'list.htm'
execute sp_makewebtask
@outputfile=@listfile,
@query='select distinct banmian
from gaojian
where kanwu=''出版報'' and datepart(yy,riqi)=datepart(yy,getdate()) and datepart(dy,riqi)=datepart(dy,getdate())',
@templatefile='d:/test/list.tml',
@codepage=936
    在此段代碼中先定義了一些變量,用來調用存貯過程時使用。其中@riqi變量用于存放當日的日期(其格式為yyy-mm-dd);@filepath變量用于存放產生靜態頁面的路徑;@listfile變量用于存放版面列表頁面文件的路徑和文件名;@command變量用于存放要執行的系統命令。
    隨后我們對各個變量進行賦值。并調用xp_cmdshell存貯過程來完成建立相應目錄、拷貝文件等工作。xp_cmdshell存貯過程是一個用來執行NT系統命令的擴展存貯過程。其語法結構如下:
    xp_cmdshell {'command_string'} [, no_output]
    其中command_string參數為要執行的系統命令。而選項no_output則用來指明不輸出系統命令的執行結果。
    在此段代碼的最后,執行未指明whentype參數的sp_makewebtask存貯過程,導出當日的版面列表頁面文件。使用的模板文件為list.tml。list.tml文件的代碼如下:
<html>
<head><title>出版報</title></head>
<body BACKGROUND="images/WB00703_.gif">
<script>
var t=0;
</script>
<table BORDER="0" ALIGN="CENTER">
<%begindetail%>
<tr>
<td><img SRC="images/Yellowb2.gif" WIDTH="14" HEIGHT="14">
<script>
var t=t+1;
document.write('<a HREF="');
document.write(t);
document.write('.htm" TARGET="show"><b><i><font SIZE="+1">')
</script>
<%insert_data_here%></font></i></b></a></td></tr>
<%enddetail%>
</table></body></html>
    可以看到,靜態頁面導出使用的模板文件同IDC技術中使用的htx文件十分相似。其中也包含<%begindetail%>和<%enddetail%>字段。所不同的是,模板文件中不使用<%字段名%>來標識字段。只是簡單的使用<%insert_data_here%>來指明在何處插入結果集中的數據。如果結果集記錄中包含多個字段的話,<%insert_data_here%>將按照其在記錄中的順序(即按照SELECT語句中的字段順序)來順序地插入數據。也就是說,每個結果記錄中的每個字段只能在頁面中被插入一次。如果要想在頁面中多次使用某個字段,可以先將它賦給一個變量。然后再反復地使用此變量即可。
    在此模板文件中有一段java程序,其用途是為每個版面按照其順序產生超鏈接。其鏈接分別為1.htm~n.htm,n值為當日版面的數目。
    至此我們已經成功地建立了存放頁面文件的目錄、完成了相應文件的拷貝工作、導出了當日版面的列表文件。下面將為每個版面來產生文章列表頁面文件。
declare
@lists int,
@banmian varchar(64),
    @filename varchar(64),
    @search varchar(2000)
set @lists=0
declare point cursor for
select distinct banmian
from gaojian
where kanwu='出版報' and datepart(yy,riqi)=datepart(yy,getdate()) and datepart(dy,riqi)=datepart(dy,getdate())
for read only

open point
fetch point into
  @banmian
while (@@fetch_status=0)
begin
set @lists=@lists+1
set @filename=@filepath+convert(varchar(64),@lists)+'.htm'
set @search='SELECT id,timu,laiyuan
FROM gaojian
WHERE datepart(yy,riqi)=datepart(yy,convert(datetime,'''+@riqi+'''))
and datepart(dy,riqi)=datepart(dy,convert(datetime,'''+@riqi+'''))'+
'and banmian ='''+@banmian+'''and kanwu=''出版報''order by timu'
execute sp_makewebtask
@outputfile=@filename,
@query=@search,
@templatefile='d:/test/list2.tml',
@codepage=936
fetch point into
@banmian
end
close point
deallocate point
    在此段代碼中我們使用了游標。在此之前我們所使用的SQL語句都是用于集合操作的。也就是說,語句只是用來產生結果集合,或對結果集合進行分組。而要想分別對每個返回的結果記錄進行不同的處理,就只有通過游標來實現了。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 漯河市| 恩施市| 阳春市| 富锦市| 房产| 紫阳县| 上饶县| 韶山市| 独山县| 大厂| 石台县| 修文县| 乌恰县| 垫江县| 雷州市| 商河县| 彰武县| 邯郸县| 红原县| 醴陵市| 太和县| 阆中市| 临桂县| 怀来县| 阜宁县| 于田县| 平安县| 黑水县| 壤塘县| 嘉祥县| 攀枝花市| 安新县| 宜黄县| 措美县| 雷波县| 叶城县| 徐州市| 洪湖市| 巴塘县| 于都县| 资中县|