[Field 04: Name ……………………..: //leave blank when no more field
[Maximum Number Of Records ..: SFS_NATURAL_RECORD_LIMIT //default value
[Primary Index Name ………………: id //use id as primary key
[Is Index Unique ? [Y]/N ………….: Y
[Index Field 01: Field Name …….: id
[Index Field 01: Ordering ………..: a[scending]
[Index Field 02: Field Name …….:
[Number Of Pages To Allocate …: 4 //allocate 4 pages(16K) for this file
cicssdt: -> quit
參閱:
關於文件組織形式(KSDS、ESDS和RRDS):
關於使用cicssdt創建文件:
(2)info <fileName>
此命令可以列出指定文件的詳細信息。和所有其他的SDT命令一樣,用戶可以在-c選項後使用,也可以在命令提示符中鍵入。例如:
#cicssdt -s /.:/cics/sfs/OceanLinux64 -c info file1
或者
#cicssdt : -> info file1
用戶將會看到如下關於file1的信息:
cicssdt : -> info file1
[Information For File: file1 ]
———————————————————————————–
[File Organisation ] btreeClustered (KSDS)
[Primary Index Name ] id (Unique index)
[Primary Index Field(s) ] id
[Secondary Index Names ] (None defined)
[Number Of Records In File ] 0
[Number Of Fields Per Record] 3
[Field 001: id ][byteArray ][Size: 3]
[Field 002: name ][byteArray ][Size: 10]
[Field 003: age ][byteArray ][Size: 3]
———————————————————————————–
[No OFD information found for this file. ]
———————————————————————————–
(3)delete <fileName>和empty <fileName>
當用戶想刪除文件時,使用”delete“命令,當需要清除已存在文件中所有記錄時,使用”empty“命令。
(4)write <fileName>
通過使用這條命令,用戶可以一條一條地向文件中寫入數據。以下例子中將向file1中添加3條記錄:
#cicssdt: -> write file1
[id ][ byteArray ][ Size:00003]
[3
[name ][ byteArray ][ Size:00010]
[Mike
[age ][ byteArray ][ Size:00003]
[17
[Another ? [Y]/N Y
[id ][ byteArray ][ Size:00003]
[4
[name ][ byteArray ][ Size:00010]
[Anna
[age ][ byteArray ][ Size:00003]
[18
[Another ? [Y]/N Y
[id ][ byteArray ][ Size:00003]
[1
[name ][ byteArray ][ Size:00010]
[Elsa
[age ][ byteArray ][ Size:00003]
[19
[Another ? [Y]/N N
[3] Record(s) Added OK.
此時使用”info“命令來獲取file1的信息,將看到”Number Of Records In File“已經變成了3。
(5)read <fileName>
read命令不僅可以從文件中讀取記錄,而且可以更新和刪除正在讀取的記錄,需要當詢問”continuous read?”時選擇N。用戶可以從文件的開始或者指定的索引處讀取數據。”cicssdt“會提供足夠的提示來指導用戶讀取、更新或刪除記錄。下面是順序讀取和更新的例子:
cicssdt: -> read file1
[Index To Use ……………………..: id
[Read From Beginning ? [Y]/N : Y
[Continuous Read ? Y/[N] …….: Y
[Read #00000001
[id ][1.. ][000003]
[Hex][310000 ]
[name ][Elsa…… ][000010]
[Hex][456C7361000000000000 ]
[age ][19. ][000003]
[Hex][313900 ]
[Read #00000002
[id ][3.. ][000003]
[Hex][330000 ]
[name ][Mike…… ][000010]
[Hex][4D696B65000000000000 ]
[age ][17. ][000003]
[Hex][313700 ]
[Read #00000003
[id ][4.. ][000003]
[Hex][340000 ]
[name ][Anna…… ][000010]
[Hex][416E6E61000000000000 ]
[age ][18. ][000003]
[Hex][313800 ]
[3 Record(s) Read]
//請注意這裡的記錄順序並和前面”write“步驟時的順序進行對比。可以看到,記錄被自動按id升序存儲。
cicssdt: -> read file1
[Index To Use ……………………..: id
[Read From Beginning ? [Y]/N : N
[Key Value To Search For …….: 3 //read from the record where id=3
[Continuous Read ? Y/[N] …….: N
[Read #00000001
[id ][3.. ][000003]
[Hex][330000 ]
[name ][Mike…… ][000010]
[Hex][4D696B65000000000000 ]
[age ][17. ][000003]
[Hex][313700 ]
[Read Another, Delete or Update ? [Y]/N/D/U U //Y-Yes N-No D-Delete U-Update
[id ][ byteArray ][ Size:00003]
[ //索引不能改變
[name ][ byteArray ][ Size:00010]
[ //如果想保持數據不變,這裡保持空白
[age ][ byteArray ][ Size:00003]
[16
[Record 1 Updated.]
[Read #00000002
[id ][4.. ][000003]
[Hex][340000 ]
[name ][Anna…… ][000010]
[Hex][416E6E61000000000000 ]
[age ][18. ][000003]
[Hex][313800 ]
[Read Another, Delete or Update ? [Y]/N/D/U N
[2 Record(s) Read]
參閱:
關於所有SDT命令的細節:
學習了”cicssdt“命令後,用戶能夠使用測試數據創建一個文件,從而更進一步地學習API。
TXSeries入門系列文章–單元三
數據管理
一部分
文件續
Ye_Guang_Yu | 2017年6月5日 | Visits (801)
2. 文件操作和APIs
我們最終的目標是在應用程序中管理文件,而不是通過鍵入命令。還記得二單元的”Hello World“程序嗎?在源代碼的最後有”EXEC CICS SEND“和”EXEC CICS RETURN“命令,這就是CICS API。C編譯器不能識別它們,所以必須通過”cicstran“或”cicstcl“命令來翻譯它們。本節將聚焦於文件操作所需的APIs,並會涉及其他相關的APIs。
在開始本節的主題前,用戶需要做一些準備工作。
(1)準備工作
現在來回顧一下二單元所學的內容。”只有當存在PD記錄時TXSeries才可以識別程序”,文件也是一樣的。所以用戶首先應該在TXSeries中定義所需的文件。
a. 添加FD
對於文件定義,用戶應該注意以下語法和選項。
語法
cicsadd -c fd -r <regionName> <FD entry name> RSLKey=public
BaseName=<fileName> IndexName=<fieldName>FileServer=”<serverName>”
選項
以下文章點擊率最高
Loading…