ADO中的多層次資料集,類似於dataset

2021-09-08 05:50:04 字數 3259 閱讀 9047

shape是做子查詢的操作,我把幫助貼上來給您看吧 語法

shape [[as] parent-alias]

relate parent-column to child-column...) [[as] chapter-alias] ...

組成說明

該命令的組成部分為:

parent-command, child-command 如下之一。

在尖括號(「{}」)中的查詢命令,返回 recordset 物件。命令發布給基本資料提供者,其語法取決於該提供者的要求。雖然 ado 並不要求使用任何指定的查詢語言,但通常是使用結構化查詢語言 (sql)。圓括號(「()」)是必需的關鍵字,它們將子集列追加到引用由查詢命令返回的 recordset 的父。

以前成形的 recordset 的名稱。

另乙個 shape 命令。

table 關鍵字,後跟表的名稱。

parent-column 由 parent-command 返回的 recordset 中的列。

child-column 由 child-command 返回的 recordset 中的列。

... 「parent-column to child-column」子句實際上是列表,並用逗號將每個定義關係分隔開。

chapter-alias 別名,對追加到父的列的引用。

parent-alias 別名,對父 recordset 的引用。

child-alias 別名,對子 recordset 的引用。 操作

發出 parent-command 並返回父 recordset。然後發出 child-command 並返回子 recordset。

例如,parent-command 可以從客戶表返回公司的客戶 recordset,而 child-command 從定貨表返回所有客戶的定單 recordset。

一般,父和子 recordset 物件必須各自擁有用於關聯父和子的列。列在 relate 子句中命名,parent-column 在先,child-column 在後。在各自的 recordset 中,列可以有不同名稱,但必須引用相同資訊以便指定有意義的關係。例如,customers 和 orders recordsets 可以同時擁有 customerid 字段。

資料構形將子集列追加到父 recordset。子集列中的值是對子 recordset 中列的引用,子 recordset 滿足 relate 子句。即在給定父行中的 parent-column 與在子集子的所有行中的 child-column 具有相同的值。

當您訪問在子集列中的引用時,ado 將自動檢索由引用表示的 recordset。注意儘管已經檢索了全部子 recordset,但子集(chapter)僅表示行的子集。

如果追加的列沒有 chapter-alias,則會自動生成其名稱。列的 field 物件將被追加到 recordset 物件的 fields 集合,其資料型別將是 adchapter。

有關定位分級 recordset 的詳細資訊,請參閱訪問分級 recordset 中的行。

引數化命令

如果您正在處理大的子 recordset(尤其是比父 recordset 大),卻只需要訪問部分子子集,那麼,使用引數化命令會更有效。

non-parameterized command(非引數化命令)同時檢索整個父和子 recordsets,並將子集列追加到父,然後為每個父行指定相關子子集的引用。

parameterized command(引數化命令)檢索整個父 recordset,但在訪問子集列時僅檢索子集 recordset。這種檢索策略的差別可以有益的效能好處。

例如,可以指定如下:

"shape

relate cust_id to parameter 0)"

父和子表通常擁有列名 cust_id。child-command 有佔位符(即「?」),受 relate 子句引用(即「...parameter 0」)。關係在於顯性標識的 customer 表 parent-column(即 cust_id)和隱性標識的 orders 表 child-column(即 cust_id)之間,由佔位符和「parameter 0」指定。

注意 parameter 子句僅屬於 shape 命令語法。與 ado parameter 屬性和 parameters 集合均無關聯。

在執行 shape 命令時,發生如下情形:

執行 parent-command,並返回 customer 表的父 recordset。

子集列被追加到父 recordset。

在訪問父行的子集列時,customer.cust_id 列的值將替換 orders.cust_id 的佔位符,並執行 child-command。

orders 表(在此,orders.cust_id 列的值與 customer.cust_id 列的值相匹配)的所有行被檢索。

對檢索到的子行(即子 recordset 的 chapter)的引用被放置在父 recordset 當前行的子集列。

當訪問另乙個行的子集列時,重複步驟 3-5。

用shape命令建立乙個分層的記錄集:

dim conn

dim rs

dim childrs

set conn = server.createobject("adodb.connection")

conn.connectionstring = [your connectionstring]

conn.open

set rs = server.createobject("adodb.recordset")

rs.stayinsync = false

rs.open    "shape  " & _

"relate class to class) as classnum", conn

set childrs = server.createobject("adodb.recordset")

while not rs.eof

set childrs = rs("classnum").value

response.write ""

while not childrs.eof

response.write "" & childrs("class") & "

" &  childrs("name") & "

" & childrs("resume")  & "

" & childrs(regdate)  & ""

childrs.movenext

wend

response.write ""

rs.movenext

wend

海量資料多層次多維度分析

資料庫儲存的資料量從20世紀80年代的兆 m 位元組及千兆 g 位元組過渡到現在的兆兆 t 位元組和千兆兆 p 位元組,同時,使用者的查詢需求也越來越複雜,涉及的已不僅是查詢或操縱一張關係表中的一條或幾條記錄,而且要對多張表中千萬條記錄的資料進行資料分析和資訊綜合,關係資料庫系統已不能全部滿足這一要...

mysql 層次資料 mysql中的層次資料

您希望獲得父id 所以假設你得到了 set parentid 1 toys select from items i inner join categories c on c.id i.categoryid where c.parentid parentid 這將給你想要的專案 乙個主要的設計缺陷 它...

php類的自動載入之連續多層次載入

廢話不多說直接上描述 先看目錄結構 1.php作為主檔案。a.class.php 和b.class.php為純類檔案 註冊自動載入函式 spl autoload register function classname class abc echo 在1.php檔案中輸出 t new abc 建立ab...