(转)Determining equivalent SQL and COBOL data types

2 篇文章 0 订阅


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.

Table 1. COBOL declarations mapped to typical SQL data types
COBOL data typeSQLTYPE of host variableSQLLEN of host variableSQL data type
S9(i)V9(d) COMP-3 or S9(i)V9(d) COMP or S9(i)V9(d) PACKED-DECIMAL484i+d in byte 1, d in byte 2DECIMAL(i+d,d)
S9(i)V9(d) DISPLAY SIGN LEADING SEPARATE504i+d in byte 1, d in byte 2No exact equivalent use DECIMAL(i+d,d) or NUMERIC (i+d,d)
S9(i)V9(d)DISPLAY488i+d in byte 1, d in byte 2NUMERIC(i+d,d)
S9(i) BINARY or S9(i) COMP-4 where i is from 1 to 45002SMALLINT
S9(i) BINARY or S9(i) COMP-4 where i is from 5 to 94964INTEGER
S9(i) BINARY or S9(i) COMP-4 where i is from 10 to 18.

 

Not supported by OPM COBOL.
4928BIGINT
S9(i)V9(d) BINARY or S9(i)V9(d) COMP-4 where i+d ≤ 4500i+d in byte 1, d in byte 2No 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 ≤ 9496i+d in byte 1, d in byte 2No exact equivalent use DECIMAL(i+d,d) or NUMERIC (i+d,d)
COMP-1

 

Not supported by OPM COBOL.
4804FLOAT(single precision)
COMP-2

 

Not supported by OPM COBOL.
4808FLOAT(double precision)
Fixed-length character data452mCHAR(m)
Varying-length character data448mVARCHAR(m)
Fixed-length graphic data

 

Not supported by OPM COBOL.
468mGRAPHIC(m)
Varying-length graphic data

 

Not supported by OPM COBOL.
464mVARGRAPHIC(m)
DATE

 

Not supported by OPM COBOL.
384DATE
TIME

 

Not supported by OPM COBOL.
388TIME
TIMESTAMP

 

Not supported by OPM COBOL.
39226TIMESTAMP

The following table can be used to determine the COBOL data type that is equivalent to a given SQL data type.

Table 2. SQL data types mapped to typical COBOL declarations
SQL data typeCOBOL data typeNotes
SMALLINTS9(m) COMP-4m is from 1 to 4
INTEGERS9(m) COMP-4m is from 5 to 9
BIGINTS9(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 string32766≥n≥1
VARCHAR(n)Varying-length character string32740≥n≥1
CLOBNoneUse 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
DBCLOBNone

 

Not supported by OPM COBOL.
Use SQL TYPE IS to declare a DBCLOB for ILE COBOL.

 

BINARYNoneUse SQL TYPE IS to declare a BINARY.

 

VARBINARYNoneUse SQL TYPE IS to declare a VARBINARY.

 

BLOBNone

 

Not supported by OPM COBOL.
Use SQL TYPE IS to declare a BLOB.

 

DATEFixed-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.
TIMEFixed-length character string or TIME for ILE COBOL.Allow at least 6 characters; 8 to include seconds.
TIMESTAMPFixed-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.
DATALINKNot supported
ROWIDNoneUse SQL TYPE IS to declare a ROWID.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值