(转)Determining equivalent SQL and COBOL data types
2011-08-24 18:01
148 查看
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Frzajp%2Frzajpequivsqlcobol.htm 发送反馈 | 评价本页
Determining equivalent SQL and COBOL data types
The precompiler determines the base SQLTYPE and SQLLEN of host variables based on this table. If a host variable appears with an indicator variable, the SQLTYPE is the base SQLTYPE plus one.
COBOL data type | SQLTYPE of host variable | SQLLEN of host variable | SQL data type |
---|---|---|---|
S9(i)V9(d) COMP-3 or S9(i)V9(d) COMP or S9(i)V9(d) PACKED-DECIMAL | 484 | i+d in byte 1, d in byte 2 | DECIMAL(i+d,d) |
S9(i)V9(d) DISPLAY SIGN LEADING SEPARATE | 504 | i+d in byte 1, d in byte 2 | No exact equivalent use DECIMAL(i+d,d) or NUMERIC (i+d,d) |
S9(i)V9(d)DISPLAY | 488 | i+d in byte 1, d in byte 2 | NUMERIC(i+d,d) |
S9(i) BINARY or S9(i) COMP-4 where i is from 1 to 4 | 500 | 2 | SMALLINT |
S9(i) BINARY or S9(i) COMP-4 where i is from 5 to 9 | 496 | 4 | INTEGER |
S9(i) BINARY or S9(i) COMP-4 where i is from 10 to 18.
Not supported by OPM COBOL. |
492 | 8 | BIGINT |
S9(i)V9(d) BINARY or S9(i)V9(d) COMP-4 where i+d ≤ 4 | 500 | i+d in byte 1, d in byte 2 | No exact equivalent use DECIMAL(i+d,d) or NUMERIC (i+d,d) |
S9(i)V9(d) BINARY or S9(i)V9(d) COMP-4 where 4 < i+d ≤ 9 | 496 | i+d in byte 1, d in byte 2 | No exact equivalent use DECIMAL(i+d,d) or NUMERIC (i+d,d) |
COMP-1
Not supported by OPM COBOL. |
480 | 4 | FLOAT(single precision) |
COMP-2
Not supported by OPM COBOL. |
480 | 8 | FLOAT(double precision) |
Fixed-length character data | 452 | m | CHAR(m) |
Varying-length character data | 448 | m | VARCHAR(m) |
Fixed-length graphic data
Not supported by OPM COBOL. |
468 | m | GRAPHIC(m) |
Varying-length graphic data
Not supported by OPM COBOL. |
464 | m | VARGRAPHIC(m) |
DATE
Not supported by OPM COBOL. |
384 | DATE | |
TIME
Not supported by OPM COBOL. |
388 | TIME | |
TIMESTAMP
Not supported by OPM COBOL. |
392 | 26 | TIMESTAMP |
The following table can be used to determine the COBOL data type that is equivalent to a given SQL data type.
SQL data type | COBOL data type | Notes |
---|---|---|
SMALLINT | S9(m) COMP-4 | m is from 1 to 4 |
INTEGER | S9(m) COMP-4 | m is from 5 to 9 |
BIGINT | S9(m) COMP-4 for ILE COBOL.
Not supported by OPM COBOL. |
m is from 10 to 18 |
DECIMAL(p,s) | If p<64: S9(p-s)V9(s) PACKED-DECIMAL or S9(p-s)V9(s) COMP or S9(p-s)V9(s) COMP-3. If p>63: Not supported | p is precision; s is scale. 0<=s<=p<=63. If s=0, use S9(p) or S9(p)V. If s=p, use SV9(s). |
NUMERIC(p,s) | If p<19: S9(p-s)V9(s) DISPLAY If p>18: Not supported | p is precision; s is scale. 0<=s<=p<=18. If s=0, use S9(p) or S9(p)V. If s=p, use SV9(s). |
FLOAT(single precision) | COMP-1 for ILE COBOL.
Not supported by OPM COBOL. |
|
FLOAT(double precision) | COMP-2 for ILE COBOL.
Not supported by OPM COBOL. |
|
CHAR(n) | Fixed-length character string | 32766≥n≥1 |
VARCHAR(n) | Varying-length character string | 32740≥n≥1 |
CLOB | None | Use SQL TYPE IS to declare a CLOB for ILE COBOL.
Not supported by OPM COBOL. |
GRAPHIC(n) | Fixed-length graphic string for ILE COBOL.
Not supported by OPM COBOL. |
16383≥n≥1 |
VARGRAPHIC(n) | Varying-length graphic string for ILE COBOL.
Not supported by OPM COBOL. |
16370≥n≥1 |
DBCLOB | None
Not supported by OPM COBOL. |
Use SQL TYPE IS to declare a DBCLOB for ILE COBOL.
|
BINARY | None | Use SQL TYPE IS to declare a BINARY.
|
VARBINARY | None | Use SQL TYPE IS to declare a VARBINARY.
|
BLOB | None
Not supported by OPM COBOL. |
Use SQL TYPE IS to declare a BLOB.
|
DATE | Fixed-length character string or DATE for ILE COBOL. | If the format is *USA, *JIS, *EUR, or *ISO, allow at least 10 characters. If the format is *YMD, *DMY, or *MDY, allow at least 8 characters. If the format is *JUL, allow at least 6 characters. |
TIME | Fixed-length character string or TIME for ILE COBOL. | Allow at least 6 characters; 8 to include seconds. |
TIMESTAMP | Fixed-length character string or TIMESTAMP for ILE COBOL. | n must be at least 19. To include microseconds at full precision, n must be 26. If n is less than 26, truncation occurs on the microseconds part. |
DATALINK | Not supported | |
ROWID | None | Use SQL TYPE IS to declare a ROWID. |
-
Notes on COBOL variable declaration and usage
Any level 77 data description entry can be followed by one or more REDEFINES entries. However, the names in these entries cannot be used in SQL statements.
阅读更多
相关文章推荐
- (转)SQL Server Data Types and Their .NET Framework Equivalents
- SQL Server Data Types and Their .NET Framework Equivalents-float类型
- Oracle data types and Microsoft SQL Server data types
- Mapping SQL and Java data types
- Datatypes translation between Oracle and SQL Server
- SQL The data types ntext and varchar are incompatible in the not equal to operator 错误
- An introduction to Redis data types and abstractions
- Data Types and Expressions(Chapter 4 of Programming in Objective-C 2.0)
- More on Variables and Data Types(Chapter 10 of Programming in Objective-C 2.0)
- MCITP Developer: Microsoft SQL Server 2005 Data Access Design and Optimization Study Guide
- SQL Server Index Data Structure and Performance Tuning
- Apache Spark 2.2.0 中文文档 - Spark SQL, DataFrames and Datasets Guide | ApacheCN
- LINQ to SQL and WCF - Sharing types, subverting the DataContext on the client side
- SQL Server error "Xml data type is not supported in distributed queries" and workaround for it
- Java程序设计(Java9版):第2章 数据类型与运算符(Data types and Operators)
- This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary
- Data Types with Different Maximum Sizes in oracle PL/SQL and SQL
- 6.087 Practical Programming in C, lec2: Variables and datatypes, operators.
- powershell execute sql and return a datareader
- System.Data.SqlTypes.SqlTypeException: SqlDateTime 溢出。必须介于 1/1/1753 12:00:00 AM 和 12/31/9999 11:59:59 PM 之间。