column length ?
Posted in 2006
Topics: General Discussion
I've probably run across the answer to this in the past, getting old and
don't remember ... anyway if you define a column as ...
create table table_1
(
col_1 decimal(15,0))
the value in the syscolumns for the length is 3840, however if you define
the column as ..
create table table_1
(col_1 decimal(15)) the length is stored as 4095
Can someone refresh my memory as to why?
Thanks in advance.
Peter
The syscolumns.collen column encodes the precision of the column as well as the
actual length. DECIMAL(15,0) is fixed precision, 15 digits to the left of the
decimal, none to the right while DECIMAL(15) is floating point precision of 15
digits total. The encoding is different. See the headers in
$INFORMIXDIR/incl/esql, specifically sqltypes.h, decimal.h, & datetime.h for
macros to decode syscolumns.collen column.
Art S. Kagel
----- Original Message -----
From: Peter_logan.... <ids@iiug.org>
At: 2/27 14:24
I've probably run across the answer to this in the past, getting old and
don't remember ... anyway if you define a column as ...
create table table_1
(
col_1 decimal(15,0))
the value in the syscolumns for the length is 3840, however if you define
the column as ..
create table table_1
(col_1 decimal(15)) the length is stored as 4095
Can someone refresh my memory as to why?
Thanks in advance.
Peter
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
Pass collength into this function (for decimal use tp=0) and it will convert
for you.
FUNCTION fix_nm(num,tp)
DEFINE num integer,
tp smallint,
strg CHAR(8),
i, j SMALLINT,
strg1, strg2 char(3)
LET i = num / 256
LET j = num MOD 256
LET strg1 = i using "<<&"
LET strg2 = j using "<<&"
IF tp = 0 THEN
IF j > i THEN
LET strg = strg1 clipped
ELSE
LET strg = strg1 clipped, ", ", strg2 clipped
END IF
ELSE # varchar is just the opposite
IF i = 0 THEN
LET strg = strg2 clipped
ELSE
LET strg = strg2 clipped, ", ", strg1 clipped
END IF
END IF
RETURN strg
END FUNCTION
j.
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org]On Behalf Of
Peter_Logan....
Sent: Monday, February 27, 2006 2:23 PM
To: ids@iiug.org
Subject: column length ? [6452]
I've probably run across the answer to this in the past, getting old and
don't remember ... anyway if you define a column as ...
create table table_1
(
col_1 decimal(15,0))
the value in the syscolumns for the length is 3840, however if you define
the column as ..
create table table_1
(col_1 decimal(15)) the length is stored as 4095
Can someone refresh my memory as to why?
Thanks in advance.
Peter
****************************************************************************
***
Forum Note: Use "Reply" to post a response in the discussion forum.
With two arguments, decimal(p,s) is referred to as exact number datatyp=
e
and collength for it is:
(precision * 256) + scale
So your decimal(15, 0) is ok.
From the manuals:
If the database is not ANSI-compliant, and you specify fewer than 2
parameters, you declare a floating-point DECIMAL,
which is not an exact number data type.
However, in ANSI-complaint database decimal(p) is implemented as
fixed-point decimal. So if your table is in ANSI
database, you will still get 3840 for decimal(15).
Thanks and Regards,
Gaurav
=
"ART KAGEL, ...." =
<kagel@bloomberg. =
net> =
To
Sent by: ids@iiug.org =
ids-bounces@iiug. =
cc
org =
Subj=
ect
Re: column length ? [6453] =
02/27/2006 01:37 =
PM =
=
=
Please respond to =
ids =
=
=
The syscolumns.collen column encodes the precision of the column as wel=
l as
the
actual length. DECIMAL(15,0) is fixed precision, 15 digits to the left =
of
the
decimal, none to the right while DECIMAL(15) is floating point precisio=
n of
15
digits total. The encoding is different. See the headers in
$INFORMIXDIR/incl/esql, specifically sqltypes.h, decimal.h, & datetime.=
h
for
macros to decode syscolumns.collen column.
Art S. Kagel
----- Original Message -----
From: Peter_logan.... <ids@iiug.org>
At: 2/27 14:24
I've probably run across the answer to this in the past, getting old an=
d
don't remember ... anyway if you define a column as ...
create table table_1
(
col_1 decimal(15,0))
the value in the syscolumns for the length is 3840, however if you defi=
ne
the column as ..
create table table_1
(col_1 decimal(15)) the length is stored as 4095
Can someone refresh my memory as to why?
Thanks in advance.
Peter
***********************************************************************=
********
Forum Note: Use "Reply" to post a response in the discussion forum.
***********************************************************************=
********
Forum Note: Use "Reply" to post a response in the discussion forum.
=