Pennywise HYIB: The king of Absurdity

Just last week, some dudes came to my office to offer the ever enticing money doubling schemes. I don’t think am being fair in calling Pennywise money doubling or S’ogun D’ogoji because man, Pennywise is something else!
This is how it works. You give them a paltry N2,500 for a slot and over a period of 9 weeks, the scheme will pay out a cumulative of N251,390. Effectively, you multiply any amount you put inside by 100 in 9 weeks. Interesting!
What if I decide to invest just N250K back? Further still, or what happens if I decide to roll over my investment every 9 weeks for a period of 1 year?
With my MS Excel, this is what I get:


So with my humble N2,500 in January 1, I could, by second week of January the next year, be worth over $19 trillion, isn’t that wonderful?
Yeah, this is Pennywise!

Coldfusion Update Function

If you ever had gotten stuck with writing insert and update statement for a table with a zillion columns, you can understand my pain.

And applications (most of them) must work with data. Select is cool, in fact, the dudes that crafted the SQL standards even created the almighty shortcut, *, which can select from 1 to a zillion columns. But how do you have a quick work around to update say a table with 150 columns? The truth, there is not shortcut. You have to do the grunt work.

ColdFusion has a CFUPDATE but I hate it like crazy. When your form has submit and cancel on it, you can imagine the hell. So I invented something. It might be a little crude but it works.

I crafted a function that takes a form struct, the table name and unique identifier. Right now, I only have a function that works with one identifier, extending it to support multiple identifiers won’t be a difficult task.

<cffunction name=“updateTable” returntype=“void” displayname=“Update Table”>
<cfargument name=“formStruct” type=“struct” required=“yes” hint=“This is the form object to be passed” />
<cfargument name=“table” type=“string” required=“yes” hint=“This is the name of the table” />
<cfargument name=“identifier” type=“string” required=“yes” hint=“This is the name of the unique identifier” />
<cfargument name=“datasource” type=“string” required=“yes” hint=“This is the name of the datasource” />

<cfset var fs=arguments.formStruct />
<cfset StructDelete(fs,’fieldnames’) />

<cfloop index=“i” list=“#StructKeyList(fs)#”>
<cfquery name=“colType” datasource=“#arguments.datasource#”>
select name,xtype from syscolumns where name=’#i#’ and id=
(select id from sysobjects where name=’#arguments.table#’)
<cfif colType.recordCount eq 1>
<cfquery name=“update” datasource=“#arguments.datasource#” result=“x”>
update #arguments.table# set #i#=
<cfif ListFind(‘173,175,61,34,239,99,231,58,35,167‘, colType.xtype) >
            <cfelseif ListFind(‘127,104,106,62,56,60,108,59,52,122‘, colType.xtype)>
Where #arguments.identifier#=’#StructFind(form,arguments.identifier)#’

This function has only been tested on SQL Server 2000 and the present code can only work on SQL Server. The same concept can probably be extended to other databases for those who need to.

This is a proof of concept and it has not been secured against stuffs like, em, SQL injection and other bla bla.

Error Selecting on AD Linked Server Columns

Looks like not all columns are born equal on Active Directory linked server on SQL Server.

I have a pretty little view which initially was selecting just four columns (mail, samaccountname, company and displayname) from a linked AD on an SQL Server 2000. Trust me, there was a reason to add more columns to the view. However, my attempt to include all the columns I wanted (valid columns!) was throwing error

Server: Msg 7346, Level 16, State 2, Line 1
Could not get the data of the row from the OLE DB provider ‘ADsDSOObject’. Could not convert the data value due to reasons other than sign mismatch or overflow.

After banging my head on the desk a couple of times, I started debugging by adding a column at a time. In the end, I discovered that the following columns won’t play nice: otherTelephone, otherMobile, otherHomePhone and may be a million other columns like that.