- 論壇徽章:
- 0
|
########## 請(qǐng)保留下面信息 ####################
作者:Author avid Mount
出處:http://www.texas400.com/BSphyfil.html
翻譯:Eric Kong mail:eric_cc@qq.ccom
關(guān)鍵字: 葡萄牙語(yǔ) Mainframe AS400 Java 廣州 求職 招聘 獵頭 www.puyufanyi.com
備注:本人Java高級(jí)工程師,初學(xué)AS400,有好的職位,可以跟我聯(lián)系,文章如果翻譯不正確,敬請(qǐng)?zhí)岢?br />
################################################
Create a Physical File with or without a key field
創(chuàng)建一個(gè)物理文件(有或者沒(méi)有Key字段)
The AS/400 database, DB2/400 is part of the AS/400 operating system. It is a relational database and has features similar to other databases you may have used such as Microsoft Access, Oracle or Dbase. The standard method of creating files is to define the specifications of the file using DDS. Of course DDS is used for other things on the AS/400 like defining display files and print files.
AS/400數(shù)據(jù)庫(kù),DB2/400是AS/400操作系統(tǒng)的一部分,它是一個(gè)關(guān)系性數(shù)據(jù)庫(kù).和其他的數(shù)據(jù)庫(kù)相比,例如Microsoft Access, Oracle or Dbase有著相似的特性.用DSS文件編寫(xiě)說(shuō)明語(yǔ)句是創(chuàng)建數(shù)據(jù)庫(kù)文件的標(biāo)準(zhǔn)方法.當(dāng)然,也可以使用DSS在AS400做其他東西,例如創(chuàng)建顯示文件或者打印文件
To create a physical database file, enter your source statements in a DDS source file member. For example, name the member "CUS" for customer file. Make sure the member type is " F". This tells the compiler that this is for a physical file. Notice that the first record has an "R" in position 17. This means that this line is specifying the record name, in this case "CUREC". The "TEXT" is optional but helps to document the file.
創(chuàng)建一個(gè)物理文件數(shù)據(jù)庫(kù),你需要在DSS文件中輸入你的數(shù)據(jù)描述代碼.例如,以一個(gè)Customer文件為例,命名為CUS的Member,要確保這個(gè)member的類(lèi)型是" F",這是為了告訴編譯器,這是一個(gè)物理文件.注意到在第一行中,位置17的地方有個(gè)"R"的標(biāo)記,這一行指明了記錄的名字,這里記錄名字就是CUREC.而Text不是一定要,但是也對(duì)文檔化比較有用.
After the line naming the record, each line describes a field. The field name is followed by the field length and its data type.
這一行命名了記錄之后,下面的每一行描述了一個(gè)字段,字段名稱(chēng)后面是字段的長(zhǎng)度和數(shù)據(jù)類(lèi)型
The three most used data types are "A" for alpha or character, "S" for numeric and " " for packed decimal. For numeric fields, you must also specify the number of decimal positions. So here, the company number field is a three digit number with no decimal places. The customer number and zip code are also numeric fields with no decimal places. The credit limit is a numeric, packed decimal field with 9 digits, of which two are after the decimal point. The rest of the fields are character fields.
最常用的數(shù)據(jù)類(lèi)型是下面的三種, "A"代表字符,"S"代表數(shù)值, " "代表packed decimal,對(duì)于數(shù)值字段,你必須指明小數(shù)點(diǎn)的位置,這里,公司號(hào)碼字段就是一個(gè)3個(gè)數(shù)字的號(hào)碼,沒(méi)有小數(shù)點(diǎn),客戶號(hào)碼和郵政編碼同樣是數(shù)字,也是沒(méi)有小數(shù),而信用額度是一個(gè)數(shù)值,它一個(gè)有9個(gè)數(shù)字,其中兩位數(shù)值位于小數(shù)點(diǎn)后面,其他的都是字符的定義
Once you have entered the DDS source code, you must compile it. You do this by keying option 14 next to your member name on the PDM screen. If you pay attention you will see that the AS/400 is actually executing the CRTPF (Create Physical File) command. It knows to use this command because the member type of the source code is " F".
一旦你輸入完DDS代碼,你必須編譯它,在PDM界面中,在你要編譯Member名字的后面輸入14.假如你細(xì)心一點(diǎn),你會(huì)發(fā)現(xiàn)AS400實(shí)際執(zhí)行了CRTPF (Create Physical File)命令,這是因?yàn)檫@個(gè)Member的類(lèi)型是" F"
You now have a database physical file, see Figure 1. This file has built into it the fields and their attributes. Let's modify this file definition to add key fields. If a physical file has key fields, programs can randomly access the records or read them sequentially in the order of the key fields.
現(xiàn)在你已經(jīng)有了數(shù)據(jù)庫(kù)物理文件,如圖1,這個(gè)文件包含了字段和他們的屬性,現(xiàn)在我們就為文件增加key字段,假如這個(gè)物理文件包含了key字段,那么程序就可以通過(guò)Key隨即的訪問(wèn)或者順許的訪問(wèn)記錄
You can see in Figure 2 that it is simple to add key fields.
看圖2,建立key字段是非常簡(jiǎn)單的
The "UNIQUE" record at the beginning of the source is used if you want the AS/400 to insist on having no records with duplicate keys. This is optional. At the end of the source code, there are two lines with "K" in position 17. These lines define the key fields. So, this file will build a key using the company number and then the customer number. Further, it will not allow a duplicate company number / customer number record to be written.
開(kāi)頭的那個(gè)"UNIQUE"表明了你要AS400不能含有重復(fù)key的Record,這是可選的. 代碼的末尾最后兩行,在位置17的有兩個(gè)"K",這兩個(gè)"K"就是定義key字段了,那么,這個(gè)文件就會(huì)用公司號(hào)碼和客戶號(hào)碼來(lái)建立key,進(jìn)一步來(lái)說(shuō),文件不允許含有公司號(hào)碼和客戶號(hào)碼都相同的recored.
The records are written to the file in arrival sequence. If you read the data by specifying keyed access, the records will read as though they have been sorted by company number and customer number. Also, your programs can randomly retrieve records. For example, a "CHAIN" instruction in RPG can now randomly read the record for a specific company number / customer number.
Record是按順序?qū)懭胛募?而假如你讀取數(shù)據(jù)的時(shí)候指明key,讀取的數(shù)據(jù)是已經(jīng)按照公司號(hào)碼和客戶號(hào)碼排好順序,同時(shí),你也可以隨即讀取Record,例如,RPG的"CHAIN"說(shuō)明符就可以用公司號(hào)碼和客戶號(hào)碼隨即讀取文件
Figure 1 - DDS for Physical File Without Key
A R CUREC TEXT('CUSTOMER FILE')
A CUCO 3S 0 TEXT('COMPANY #')
A CUSTS 1A TEXT('STATUS CODE')
A CUNUM 5S 0 TEXT('CUSTOMER #')
A CUNAME 30A TEXT('CUSTOMER NAME')
A CUADR 30A TEXT('CUSTOMER ADDRESS')
A CUCITY 18A TEXT('CUSTOMER CITY')
A CUSTAT 2A TEXT('CUSTOMER STATE')
A CUZIP 9S 0 TEXT('CUSTOMER ZIP')
A CUCRLM 9P 2 TEXT('CUST CREDIT LIMIT')
Figure 2 - DDS for Physical File With Key Fields
A UNIQUE
A R CUREC TEXT('CUSTOMER FILE')
A CUCO 3S 0 TEXT('COMPANY #')
A CUSTS 1A TEXT('STATUS CODE')
A CUNUM 5S 0 TEXT('CUSTOMER #')
A CUNAME 30A TEXT('CUSTOMER NAME')
A CUADR 30A TEXT('CUSTOMER ADDRESS')
A CUCITY 18A TEXT('CUSTOMER CITY')
A CUSTAT 2A TEXT('CUSTOMER STATE')
A CUZIP 9S 0 TEXT('CUSTOMER ZIP')
A CUCRLM 9P 2 TEXT('CUST CREDIT LIMIT')
*
A K CUCO
A K CUNUM
|
|