Re: column length (collength)
Posted in 2013
Something I wrote some time back.
create procedure collength(p_coltype smallint, p_collength smallint)
returning smallint
DEFINE i,j,k INTEGER;
IF p_coltype>255
THEN LET p_coltype=mod(p_coltype,256);
END IF;
IF p_coltype= 0 THEN return p_collength;
ELIF p_coltype= 1 THEN return p_collength;
ELIF p_coltype= 2 THEN return p_collength;
ELIF p_coltype= 3 THEN return p_collength;
ELIF p_coltype= 4 THEN return p_collength;
ELIF p_coltype= 5 THEN
let i=trunc(p_collength/256);
IF mod(i,2)=0
THEN
let j=(i+4)/2;
ELSE
let j=(i+3)/2;
END IF;
IF mod(j,2)=1
THEN
LET j=j-1;
END IF;
IF j>17 THEN
let j=17;
END IF;
RETURN j;
ELIF p_coltype= 6 THEN return p_collength;
ELIF p_coltype= 7 THEN return p_collength;
ELIF p_coltype= 8 THEN
let i=trunc(p_collength/256);
IF mod(i,2)=0
THEN
let j=(i+4)/2;
ELSE
let j=(i+3)/2;
END IF;
IF mod(j,2)=1
THEN
LET j=j-1;
END IF;
IF j>17 THEN
let j=17;
END IF;
RETURN j;
ELIF p_coltype= 9 THEN return p_collength;
ELIF p_coltype= 10 THEN RETURN MOD(p_collength,256);
ELIF p_coltype= 11 THEN return p_collength;
ELIF p_coltype= 12 THEN return p_collength;
ELIF p_coltype= 13 THEN return mod(p_collength,256);
ELIF p_coltype= 14 THEN RETURN MOD(p_collength,256);
ELIF p_coltype= 15 THEN return p_collength;
ELIF p_coltype= 16 THEN return mod(p_collength,256);
ELIF p_coltype= 17 THEN return p_collength;
ELIF p_coltype= 18 THEN return p_collength;
ELSE RETURN 0;
END IF;
END PROCEDURE;
On Jan 28, 2013, at 5:03 PM, FRANK wrote:
> Just make sure.
> I have a column defined as,
> ingest_dt datetime year to second not null ;
> Its info in syscolumns shows,
> colname ingest_dt
> tabid 267
> colno 7
> coltype 266
> collength 3594
> colmin
> colmax
> extended_id 0
> seclabelid 0
> colattr 0
> So, physically, the ingest_dt column might occupy 3594 bytes in disk for a row?
> I doubt this.
> Thanks,
> Frank
>
> On Sat, Jan 26, 2013 at 6:35 PM, Art Kagel <art.kagel@gmail.com> wrote:
> The values for the parts of the qualifiers are found in the header file datetime.h in $INFORMIXDIR/incl/esql along with macros to extract the values.
>
> Art
>
> Art S. Kagel
> Advanced DataTools (www.advancedatatools.com)
> Blog: http://informix-myview.blogspot.com/
>
> Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Advanced DataTools, the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves.
>
>
> On Thu, Jan 24, 2013 at 7:35 AM, <tomcaml@gmail.com> wrote:
> Thank you much
> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list
>
>
> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list
>
>
> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list