Join IIUG
 for   
 

Informix News
18 Nov 13 - ZDNet - Top 20 mobile skills in demand... Read
09 Sep 13 - telecompaper - Shaspa and Tatung have shown a new smart home platform at Ifa in Berlin. Powered by the IBM Informix software... Read
06 Sep 13 - IBM data magazine - Mission Accomplished - Miami, Florida will be the backdrop for the 2014 IIUG Informix Conference... Read
01 Feb 13 - IBM Data Magazine - Are your database backups safe? Lester Knutsen (IBM Champion) writes about database back up safety using "archecker"... Read
14 Nov 12 - IBM - IBM's Big Data For Smart Grid Goes Live In Texas... Read
3 Oct 12 - The Financial - IBM and TransWorks Collaborate to Help Louisiana-Pacific Corporation Achieve Supply Chain Efficiency... Read
28 Aug 12 - techCLOUD9 - Splunk kicks up a SaaS Storm... Read
10 Aug 12 - businessCLOUD9 - Is this the other half of Cloud monitoring?... Read
3 Aug 12 - IBM data management - Supercharging the data warehouse while keeping costs down IBM Informix Warehouse Accelerator (IWA) delivers superior performance for in-memory analytics processing... Read
2 Aug 12 - channelbiz - Oninit Group launches Pay Per Pulse cloud-based service... Read
28 May 12 - Bloor - David Norfolk on the recent Informix benchmark "pretty impressive results"... Read
23 May 12 - DBTA - Informix Genero: A Way to Modernize Informix 4GL Applications... Read
9 Apr 12 - Mastering Data Management - Upping the Informix Ante: Advanced Data Tools... Read
22 Mar 12 - developerWorks - Optimizing Informix database access... Read
14 Mar 12 - BernieSpang.com - International Informix User Group set to meet in San Diego... Read
1 Mar 12 - IBM Data Management - IIUG Heads West for 2012 - Get ready for sun and sand in San Diego... Read
1 Mar 12 - IBM Data Management - Running Informix on Solid-State Drives.Speed Up Database Access... Read
26 Feb 12 - BernieSpan.com - Better results, lower cost for a broad set of new IBM clients and partners... Read
24 Feb 12 - developerWorks - Informix Warehouse Accelerator: Continuous Acceleration during Data Refresh... Read
6 Feb 12 - PRLOG - Informix port delivers unlimited database scalability for popular SaaS application ... Read
2 Feb 12 - developerWorks - Loading data with the IBM Informix TimeSeries Plug-in for Data Studio... Read
1 Feb 12 - developerWorks - 100 Tech Tips, #47: Log-in to Fix Central... Read
13 Jan 12 - MC Press online - Informix Dynamic Server Entices New Users with Free Production Edition ... Read
11 Jan 12 - Computerworld - Ecologic Analytics and Landis+Gyr -- Suitors Decide to Tie the Knot... Read
9 Jan 12 - planetIDS.com - DNS impact on Informix / Impacto do DNS no Informix... Read
8 Sep 11 - TMCnet.com - IBM Offers Database Solution to Enable Smart Meter Data Capture... Read
1 Aug 11 - IBM Data Management Magazine - IIUG user view: Happy 10th anniversary to IBM and Informix... Read
8 Jul 11 - Database Trends and Applications - Managing Time Series Data with Informix... Read
31 May 11 - Smart Grid - The meter data management pitfall utilities are overlooking... Read
27 May 11 - IBM Data Management Magazine - IIUG user view: Big data, big time ( Series data, warehouse acceleration, and 4GLs )... Read
16 May 11 - Business Wire - HiT Software Announces DBMoto for Enterprise Integration, Adds Informix. Log-based Change Data Capture... Read
21 Mar 11 - Yahoo! Finance - IBM and Cable&Wireless Worldwide Announce UK Smart Energy Cloud... Read
14 Mar 11 - MarketWatch - Fuzzy Logix and IBM Unveil In-Database Analytics for IBM Informix... Read
11 Mar 11 - InvestorPlace - It's Time to Give IBM Props: How many tech stocks are up 53% since the dot-com boom?... Read
9 Mar 11 - DBTA - Database Administration and the Goal of Diminishing Downtime... Read
2 Feb 11 - DBTAs - Informix 11.7 Flexible Grid Provides a Different Way of Looking at Database Servers... Read
27 Jan 11 - exactsolutions - Exact to Add Informix Support to Database Replay, SQL Monitoring Solutions... Read
25 Jan 11 - PR Newswire - Bank of China in the UK Works With IBM to Become a Smarter, Greener Bank... Read
12 Oct 10 - Database Trends and Applications - Informix 11.7: The Beginning of the Next Decade of IBM Informix... Read
20 Sep 10 - planetIDS.com - ITG analyst paper: Cost/Benefit case for IBM Informix as compared to Microsoft SQL Server... Read
20 Jul 10 - IBM Announcements - IBM Informix Choice Edition V11.50 helps deploy low-cost scalable and reliable solutions for Apple Macintosh and Microsoft Windows... Read
20 Jul 10 - IBM Announcements - Software withdrawal: Elite Support for Informix Ultimate-C Edition... Read
24 May 10 - eWeek Europe - IBM Supplies Database Tech For EU Smart Grid... Read
23 May 10 - SiliconIndia - IBM's smart metering system allows wise use of energy... Read
21 May 10 - CNET - IBM to help people monitor energy use... Read
20 May 10 - ebiz - IBM Teams With Hildebrand To Bring Smart Metering To Homes Across Britain... Read
19 May 10 - The New Blog Times - Misurare il consumo energetico: DEHEMS è pronto... Read
19 May 10 - ZDNet - IBM software in your home? Pact enables five-city smart meter pilot in Europe... Read
17 March 10 - ZDNet (blog) David Morgenstern - TCO: New research finds Macs in the enterprise easier, cheaper to manage than... Read
17 March 2010 - Virtualization Review - ...key components of Big Blue's platform to the commercial cloud such as its WebSphere suite of application ser vers and its DB2 and Informix databases... Read
10 February 2010 - The Wall Street Journal - International Business Machines is expanding an initiative to win over students and professors on its products. How do they lure the college crowd?... Read


End of Support Dates

IIUG on Facebook IIUG on Twitter

[ View Thread ] [ Post Response ] [ Return to Index ] [ Read Prev Msg ] [ Read Next Msg ]

IDS Forum

Re: Weird request

Posted By: Jonathan Leffler
Date: Saturday, 19 July 2008, at 7:22 p.m.

In Response To: Re: Weird request (MIKE MAGIE)

Someone asked "what's this weird request about?", and the answer is:-

How do I convert the coltype and collength values from syscolumns
into the name of the column. Mike Magie provided a solution as a CASE
statement that could be embedded into the body of an SQL statement
that had an alias b referring to a table that contained coltype and
collength columns of the appropriate types (INTEGER or SMALLINT).

On Fri, Jul 18, 2008 at 6:29 AM, MIKE MAGIE <jmmagie@yahoo.com> wrote:
> Small change to the decimal stuff...
>
> when (b.coltype = 5) and MOD(b.collength,256) = 255 then ('decimal(' ||
> ROUND(b.collength/256) - 1 || ')')
> when b.coltype = 5 then ('decimal(' || ROUND(b.collength/256) || "," ||
> MOD(b.collength,256) || ')')
> when (b.coltype = 261) and MOD(b.collength,256) = 255 then ('decimal(' ||
> ROUND(b.collength/256) - 1 || ') not null')
> when b.coltype = 261 then ('decimal(' || ROUND(b.collength/256) || "," ||
> MOD(b.collength,256) || ') not null')

Here's a stored procedure (ok, a pair of stored procedures) based on
Mike's CASE statement, but with some more rigour in the formatting of
MONEY, INTERVAL, DATETIME, VARCHAR and NVARCHAR. Note that because
this is a procedure instead of a CASE statement, it can process the
null-ness separately - reducing the complexity by about a half (and,
strictly, correcting the algorithm for types such as INT8 NOT NULL).
It also uses a procedure to map the parts of a DATETIME or INTERVAL
encoding into strings. The rest of the encoding for them is mostly a
matter of knowing from the datetime.h header how the type information
is encoded.

I ran it on my stores database, which includes a table whose name is
128 double quotes, and another table which contains 32511 separate
CHAR(1) columns, and the complete set of possible DECIMAL, MONEY,
DATETIME and INTERVAL types (test case for DBD::Informix), and it
works on all of these. About the only stuff it doesn't handle is
user-defined types - such as distinct types, or UDTs in datablades.
Someone else can do that extension work. It does seem to cover the
base types OK.

Sorry about line breaks...I'll upload it to the IIUG Software Archive too.

-- @(#)$Id: informixtypes.spl,v 1.3 2008/07/19 23:14:22 jleffler Exp $
-- @(#)Create InformixTypeName Stored Procedure
--
-- Basic coding provided by Mike Magie (jmmagie@yahoo.com) in a posting
-- to ids@iius.org mailing list, one of them on 2008-07-18.
-- Converted to two stored procedures by J Leffler.

CREATE PROCEDURE DateTimeFieldName(field SMALLINT, lead SMALLINT DEFAULT 0)

RETURNING VARCHAR(11) AS FieldName;

DEFINE retval VARCHAR(11);

IF field = 0 THEN LET retval = 'YEAR';

ELIF field = 2 THEN LET retval = 'MONTH';

ELIF field = 4 THEN LET retval = 'DAY';

ELIF field = 6 THEN LET retval = 'HOUR';

ELIF field = 8 THEN LET retval = 'MINUTE';

ELIF field = 10 THEN LET retval = 'SECOND';

ELIF field = 11 THEN LET retval = 'FRACTION(1)';

ELIF field = 12 THEN

IF lead == 0 THEN

LET retval = 'FRACTION(2)';

ELSE

LET retval = 'FRACTION';

END IF;

ELIF field = 13 THEN LET retval = 'FRACTION(3)';

ELIF field = 14 THEN LET retval = 'FRACTION(4)';

ELIF field = 15 THEN LET retval = 'FRACTION(5)';

ELSE LET retval = 'BOGUS';

END IF;

RETURN retval;
END PROCEDURE;

CREATE PROCEDURE InformixTypeName(coltype INT, collength INT)

RETURNING VARCHAR(64) AS typname;

DEFINE retval VARCHAR(64);

DEFINE suffix VARCHAR(9);

IF coltype >= 256 AND coltype < 512 THEN

LET suffix = " NOT NULL";

LET coltype = coltype - 256;

ELSE

LET suffix = "";

END IF;

IF coltype = 0 THEN LET retval = 'CHAR(' || collength || ')';

ELIF coltype = 1 THEN LET retval = 'SMALLINT';

ELIF coltype = 2 THEN LET retval = 'INTEGER';

ELIF coltype = 3 THEN LET retval = 'FLOAT';

ELIF coltype = 4 THEN LET retval = 'SMALLFLOAT';

ELIF coltype = 5 AND MOD(collength,256) = 255 THEN

LET retval = 'DECIMAL(' || TRUNC(collength/256) || ')';

ELIF coltype = 5 THEN

LET retval = 'DECIMAL(' || ROUND(collength/256) || "," ||
MOD(collength,256) || ')';

ELIF coltype = 6 THEN LET retval = 'SERIAL';

ELIF coltype = 7 THEN LET retval = 'DATE';

ELIF coltype = 8 THEN

-- MONEY is always fixed point

LET retval = 'MONEY(' || ROUND(collength/256) || "," ||
MOD(collength,256) || ')';

ELIF coltype = 9 THEN LET retval = 'NULL';

ELIF coltype = 10 THEN

BEGIN

DEFINE lead SMALLINT;

DEFINE tail SMALLINT;

LET tail = MOD(collength, 16);

LET lead = MOD(TRUNC(collength/16), 16);

LET retval = 'DATETIME ' || DateTimeFieldName(lead,1) || ' to
' || DateTimeFieldName(tail);

END;

ELIF coltype = 11 THEN LET retval = 'BYTE';

ELIF coltype = 12 THEN LET retval = 'TEXT';

ELIF coltype = 13 THEN

BEGIN

DEFINE INFO VARCHAR(9);

IF TRUNC(collength/256) = 0 THEN

LET INFO = MOD(collength, 256);

ELSE

LET INFO = MOD(collength, 256) || ',' || TRUNC(collength/256);

END IF;

LET retval = 'VARCHAR(' || INFO || ')';

END;

ELIF coltype = 14 THEN

BEGIN

DEFINE lead SMALLINT;

DEFINE tail SMALLINT;

DEFINE tlen SMALLINT;

DEFINE rlen SMALLINT;

DEFINE ldig VARCHAR(4);

LET tail = MOD(collength, 16);

LET lead = MOD(TRUNC(collength/16), 16);

LET tlen = TRUNC(collength/256);

LET rlen = tlen - (tail - lead);

IF (lead == 0 AND rlen == 4) OR

(lead != 0 AND rlen == 2) THEN

LET ldig = '';

ELSE

LET ldig = '(' || rlen || ')';

END IF;

LET retval = 'INTERVAL ' || DateTimeFieldName(lead) || ldig ||
' to ' || DateTimeFieldName(tail);

END;

ELIF coltype = 15 THEN LET retval = 'NCHAR(' || TRIM(collength) || ')';

ELIF coltype = 16 THEN

BEGIN

DEFINE INFO VARCHAR(9);

IF TRUNC(collength/256) = 0 THEN

LET INFO = MOD(collength, 256);

ELSE

LET INFO = MOD(collength, 256) || ',' || TRUNC(collength/256);

END IF;

LET retval = 'NVARCHAR(' || INFO || ')';

END;

ELIF coltype = 17 THEN LET retval = 'INT8';

ELIF coltype = 18 THEN LET retval = 'SERIAL8';

ELIF coltype = 19 THEN LET retval = 'SET';

ELIF coltype = 20 THEN LET retval = 'MULTISET';

ELIF coltype = 21 THEN LET retval = 'LIST';

ELIF coltype = 22 THEN LET retval = 'ROW';

ELIF coltype = 23 THEN LET retval = 'COLLECTION';

ELIF coltype = 24 THEN LET retval = 'ROWREF';

ELIF coltype = 40 AND collength = 2048 THEN LET retval = 'LVARCHAR';

ELIF coltype = 40 THEN LET retval = 'LVARCHAR(' || collength || ')';

ELSE

LET retval = "Unknown type (" || coltype || ", " || collength || ")";

END IF;

LET retval = retval || suffix;

RETURN retval;

END PROCEDURE;

SELECT T.tabname, T.tabid, C.colno, C.colname, C.coltype, C.collength,

informixtypename(C.coltype, C.collength) AS coltypename

FROM SysTables T, SysColumns C

WHERE C.tabid = T.tabid

ORDER BY T.tabname, C.colno;

--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2008.0513 -- http://dbi.perl.org/
"Blessed are we who can laugh at ourselves, for we shall never cease
to be amused."
NB: Please do not use this email for correspondence.
I don't necessarily read it every week, even.

Messages In This Thread

[ View Thread ] [ Post Response ] [ Return to Index ] [ Read Prev Msg ] [ Read Next Msg ]

IDS Forum is maintained by Administrator with WebBBS 5.12.