[ic] IC does not see 0.00 is as 0 for DECIMAL(6, 2) fields in MySQL

Mike Heins mike at perusion.com
Tue Jul 6 18:06:23 EDT 2004

Quoting John1 (list_subscriber at yahoo.co.uk):
> I am using MySQL with interchange and would like to format my sale_price
> column as DECIMAL(6,2), rather than the current CHAR(8).
> However, I have noticed that if I do this, then [if-sql-param sale_price]
> always returns true, even if sale_price is nil.
> I am guessing that this is because Interchange stores 0 as "0.00" for
> DECIMAL(6.2) and that consequently [if-sql-param] sees 0.00 as a string of 4
> characters, rather than a numeric zero.
> Is there an efficient way around this problem?  I say, "efficient", because
> I use this [if-sql-param sale_price] within loops, so the tag may get called
> 100s of times, so I really don't want to hurt performace at all by adding
> extra overhead to the loop.  e.g.  I have thought of setting a scratch
> variable inside the loop as follows:

This is pretty efficient:

	[if-sql-param sale_price > 0]

It doesn't spawn a Perl interpreter like [calc] and [if ...] do.

Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>

Friends don't let friends use Outlook. -- Bob Blaylock

More information about the interchange-users mailing list