有跟一般開放系統又不一致,所以在限定的範圍與多樣需求的現實需求上,IBM產生出
一些它特有的方式,並且配合開放的Java 使用 產生出不一樣的做法,在經過專案的歷練下後整理出下列項目,
- AS400 與 資料庫 對照
- 系統連結設定
- SQL Function
- CCSID 的轉換
在 AS400 跟資料庫 的名詞對照 如下
Table = Physical file
View =Non-keyed logical file
Index Keyed= logical file
Column =Field
Row=Record
Schema Library= collection
Log= Journal
Isolation level Commitment = control level
系統連結設定
1. Driver:
一般系統連結在JDBC 的規範 可使用 Jtopen 其網址(http://jt400.sourceforge.net/)一般使用的規範須以下列格式
需使用 的 jar: jt400.jar
The class name to register is com.ibm.as400.access.AS400JDBCDriver
URL : jdbc:as400://ip;name1=value1;name2=value2;...
2. URL 的設定參數
設定參數 將決定 AS400 的型態 並且在連結上的特性 其中包含幾個項目:
(根據 http://www.i5tools-eu-download.net/reference/jtopen/6.6/com/ibm/as400/access/doc-files/JDBCProperties.html)
設定 有使用
;libraries=cshr1;prompt=false;char.encoding=UTF-8
但是 在連結 CCSID =65535 的欄位 需要將該欄位 進行調整
如設為 ccsid =937 有時候 會解決此問題
ccsid=<ccsid code>
convert _ccsid_65535=yes|no
一般
prompt
database name" *SYSBAS
libraries *LIBL
package ccsid dafault ==> 13488(UTF16)
translate hex =false 一般僅在使用 binary 型態的欄位使用
欄位設定
date format ==>
date separator
decimal separator
naming ==> sql ==>
schema.table system==>
schema/table
time format
time separator
ccsid=<ccsid code> and convert _ccsid_65535=yes|no
bidi string type ==>http://www.i5tools-eu-download.net/reference/jtopen/6.6/com/ibm/as400/access/BidiStringType.html#navbar_top
translate binary ==> BINARY and VARBINARY fields to char and varchar
SQL Function日期相關
Function | Description |
---|---|
CURDATE() CURTIME() | Returns the system's current date/time. |
DATE(D) DATE(T) | Converts a string representation of a date/time into into a date/time value. |
DAY(D) | Returns the day(1-31) from the date D. |
WEEK(D) | Returns the week (1-54) from the date D. |
MONTH(D) | Returns the month (1-12) from the date D. |
YEAR(D) | Returns the year from the date D. |
DAYOFWEEK(D) | Returns the week day (1-7) from the date D where 1 is Sunday. |
DAYOFWEEK_ISO(D) | Returns the week day (1-7) from the date D where 1 is Monday. |
DAYOFYEAR(D) | Returns the number of the day, in a year (1-366). |
HOUR(T) | Returns the hour (0-24) from the time T. |
MINUTE(T) | Returns the minute from the time T. |
SECOND(T) | Returns the second from the time T. |
MICROSECOND(T) | Returns the microsecond from the time |
String 相關
CHAR(N) | Returns the the string representation of the number N. |
CHAR_LENGTH(S) | Returns the length of a string. |
CONCAT(S1, S2) | Concatenates S1 with S2. |
SUBSTR(S, I, L) | Returns a substring of S, starting at index I of lenght L. |
LOWER(S) | Returns the lowercase representation of S. |
UPPER(S) | Returns the uppercase representation of S. |
TRIM(S) | Removes spaces from the beggining and and of S. |
RTRIM(S) LTRIM(S) | Removes spaces at the begging (right) or end (left) of S. |
<未完待續>
沒有留言:
張貼留言