Create a Physical File with or without a key field 創建一個物理文件(有或者沒有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數據庫,DB2/400是AS/400操作系統的一部分,它是一個關系性數據庫.和其他的數據庫相比,例如Microsoft Access, Oracle or Dbase有著相似的特性.用DSS文件編寫說明語句是創建數據庫文件的標準方法.當然,也可以使用DSS在AS400做其他東西,例如創建顯示文件或者打印文件
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 "PF". 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. 創建一個物理文件數據庫,你需要在DSS文件中輸入你的數據描述代碼.例如,以一個Customer文件為例,命名為CUS的Member,要確保這個member的類型是"PF",這是為了告訴編譯器,這是一個物理文件.注意到在第一行中,位置17的地方有個"R"的標記,這一行指明了記錄的名字,這里記錄名字就是CUREC.而Text不是一定要,但是也對文檔化比較有用.
After the line naming the record, each line describes a field. The field name is followed by the field length and its data type.這一行命名了記錄之后,下面的每一行描述了一個字段,字段名稱后面是字段的長度和數據類型
The three most used data types are "A" for alpha or character, "S" for numeric and "P" 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. 最常用的數據類型是下面的三種, "A"代表字符,"S"代表數值, "P"代表packed decimal,對于數值字段,你必須指明小數點的位置,這里,公司號碼字段就是一個3個數字的號碼,沒有小數點,客戶號碼和郵政編碼同樣是數字,也是沒有小數,而信用額度是一個數值,它一個有9個數字,其中兩位數值位于小數點后面,其他的都是字符的定義
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 "PF". 一旦你輸入完DDS代碼,你必須編譯它,在PDM界面中,在你要編譯Member名字的后面輸入14.假如你細心一點,你會發現AS400實際執行了CRTPF (Create Physical File)命令,這是因為這個Member的類型是"PF"
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.現在你已經有了數據庫物理文件,如圖1,這個文件包含了字段和他們的屬性,現在我們就為文件增加key字段,假如這個物理文件包含了key字段,那么程序就可以通過Key隨即的訪問或者順許的訪問記錄
You can see in Figure 2 that it is simple to add key fields. 看圖2,建立key字段是非常簡單的
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. 開頭的那個"UNIQUE"表明了你要AS400不能含有重復key的Record,這是可選的. 代碼的末尾最后兩行,在位置17的有兩個"K",這兩個"K"就是定義key字段了,那么,這個文件就會用公司號碼和客戶號碼來建立key,進一步來說,文件不允許含有公司號碼和客戶號碼都相同的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是按順序寫入文件的,而假如你讀取數據的時候指明key,讀取的數據是已經按照公司號碼和客戶號碼排好順序,同時,你也可以隨即讀取Record,例如,RPG的"CHAIN"說明符就可以用公司號碼和客戶號碼隨即讀取文件
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
A few nouns can be either masculine or feminine. Relatively common among these are: diabetes (also diabete) ‘diabetes’, suéter ‘sweater’ (more often encountered as masculine) and hélice ‘propeller’ (which is more commonly feminine, though can be masculine when referring to the propeller of a ship or boat). 有一些名詞,它們是陽性或者陰性皆可的,其中比較常見的是diabetes (also diabete) ‘diabetes’ 糖尿病, suéter ‘sweater’ 羊毛衫(通常都是陽性的)和 hélice ‘propeller’ 螺旋槳,推進器(通常都是陰性的,但是它也可以是陽性的,當涉及的是輪船或者是小艇。
The gender of a hyphenated compound noun is usually determined by the gender of the first noun in the compound, e.g. posto-chave ‘key post’, which is masculine like posto,and meia-noite, which is feminine like noite. Compounds that begin with a verb stem are masculine, e.g. guarda-chuva ‘umbrella’, para-brisa ‘windscreen’. 復合名詞的性一般取決于第一個名詞的性,例如,posto-chave ‘key post’,關鍵崗位,它們都是陽性的,正如posto郵遞,和meia-noite午夜,而noite夜是陰性的,那些由動詞開頭的復合名詞是陽性的,例如,guarda-chuva ‘umbrella‘傘,para-brisa ‘windscreen’.擋風玻璃 However, compounds referring to people can be masculine or feminine, depending on the sex of the person referred to, regardless of the original gender of the component noun, e.g.sem-teto ‘homeless person’, cabeça-dura ‘pigheaded person’, porta-voz ‘spokesperson’,relações-públicas ‘PR manager’. 但是,那些涉及到人復合名詞,即可以是陽性的也可以是女性的,這決定于所提及的人的性別, 不管這個復合名詞原本的性,例如,sem-teto ‘homeless person’無家可歸的人, cabeça-dura ‘pigheaded person’固執的人, porta-voz ‘spokesperson’代言人,relações-públicas ‘PR manager’公共關系經理
The following nouns are masculine by implication, i.e. there is an unexpressed noun (shown below in parentheses) which determines their gender: 下面這些名詞隱含地為陽性的, (i) months of the year (mês): abril próximo ‘next April’; 月份,下一個四月 (ii) rivers, seas, mountains (rio, mar/oceano, monte): o Amazonas ‘the Amazon’, o Pacífico ‘the Pacific’;河流,海洋,山,阿馬遜河,太平洋
(iii) cardinal points (ponto cardeal): ao norte ‘to the north’;基本方位,在北方 (iv) cars, planes, ships (carro, avião, navio): um Fiat ‘a Fiat’, o Titanic ‘the Titanic’;車,飛機,輪船,一臺菲亞特,泰坦尼克號 (v) bars, restaurants, hotels (bar, restaurante, hotel): o Hilton ‘the Hilton’;吧,飯館,酒店,希爾頓酒店 (vi) newspapers (jornal): o New York Times ‘the New York Times’;報紙雜志,紐約時代雜志 (vii) sports teams (time): o Corinthians ‘Corinthians’;運動,業余運動員 (viii) letters of the alphabet: dois fs ‘two fs’.字母表的字符,兩個fs Words that are feminine by implication 下面這些名詞隱含地為陰性的, (i) cities (cidade): toda Paris ‘all of Paris’, except when the city name contains the masculine definite article, e.g. o Rio de Janeiro (masc.); 城市,巴黎,除了那些城市名詞包含了陽性的冠詞,例如,里約熱內盧 (ii) streets (rua): na esquina da Visconde ‘on the corner of Visconde’;街道, (iii) TV networks (rede): na CNN ‘on CNN’;電視網絡,例如CNN (iv) companies, shops, airlines (empresa, loja, companhia): a Microsoft ‘Microsoft’. 公司,商店,航班,微軟
Nouns that are masculine or feminine depending on meaning,
根據意思決定陽性或者是陰性的名詞
Some words can be masculine or feminine depending on the meaning. Here are some common examples: 某些名詞的陽性或者是陰性,取決于這個詞的在情景中的意思,下面是一些常用的例子 作為陽性名詞 作為陰性名詞 As masculine noun As feminine noun Capital capital (= money) 資金 capital (= city) 城市 Cara guy 家伙 face 名字 grama gram (= measure) 尺寸 grass 玻璃 guia guide (= man or book) 男人或者書 guide (= woman); form, slip 失誤,口誤; 事故 moral morale morality; 道德觀 moral (of a story) 寓意,教訓 rádio radio; 無線電 radium radio station. 無線電電臺
The following nouns are grammatically masculine only, but can refer to females as well as males: cônjuge ‘spouse’, indivíduo ‘individual’, ser ‘being’.The following nouns are grammatically feminine only, but can refer to males as well as females: criança ‘child’, pessoa ‘person’, testemunha ‘witness’, vítima ‘victim’. 下面這些名詞,在語法上只能用于男性,但是也可以用于女性。cônjuge ‘spouse’,配偶, indivíduo ‘individual’個人, ser ‘being’是.下面這些名詞在語法上只能用于女性,但是也可以用于男性。criança ‘child’ 孩子, pessoa ‘person’ 人, testemunha ‘witness’ 目擊證人, vítima ‘victim’受害者.