Wednesday, April 27, 2011

Find and Fix Scientific Notation values in a field

Many years ago during some importing or upgrading to a bigger better database one of my fields was converting longer numerical values to scientific notation.  This quit happening but I still had alot of those values in a text field in my database. Originally that field was numeric, but we converted it to text because there were often times when letters were added to the values we receive.

After not being able to find a isScientificNotation() function I found the values like this:

select myfield, LTRIM(str(cast(my field as real))), * from mytable

This worked great and made it easy to write an update statement like so:

update mytable
set myfield = LTRIM(str(cast(myfield as real)))
where myfield like '%e+%'

No more scientific notation in my field. Cool. Should have fixed this years ago, or not let it happen in the first place.

Dave

Friday, July 30, 2010

Railo on mac

I have had a great time at CFUNITED this year.  One of the things that has been a hot topic, which I haven't really caught wind of until today, is the battle between Adobe and the CFML open source alternatives, mainly Railo and Open BD.  I will save that topic for another post.  But that, along with the fact that I have been wanting to do it anyway, prompted me to give Railo a run.

I am mac challenged.  I spend 95% of my time on a PC.  The only time I seriously use my mac is when I travel, and at home in the evening, so maybe I only spend 80% of my time on a PC.  So I can't handle any advanced stuff on a mac.

Railo provides a version that you don't have to install.  That is good for me.  It is called "Railo Express (Jetty)".  It worked just as expected.  I dropped in my apps folder after unzipping the archive and double clicked on "Start" and there you go.  I pointed my browser to http://localhost:8888/ and up came a screen prompting me for a new password.  After selecting one I was presented with the admin interface for railo.

I snooped around the admin interface for a minute, but then I wanted to just see a regular page.  I opened up the index.cfm file in the railo directory (under applications for me, it had a weird name that represented the relase number and everything) under webroot and noticed there was a cflocation:

<cflocation url="railo-context/admin.cfm" addtoken="no">

I commented that out and then I was able to use that page like any other cfm page and add cfml to it however I want.

Pretty nice that railo makes it so easy to get started with CFML.  I have a hard time articulating my thoughts on stuff, like the adobe vs open source battle, but being able to start coding in CFML so easily seems like a good thing for our community.

Monday, May 10, 2010

Coldfusion 9 orm where in clause

I was trying to do a where in clause using coldfusion 9 orm and it just didn't work. I know pretty fast when something is over my head. A quick search revealed this thread: http://groups.google.com/group/cf-orm-dev/browse_thread/thread/19dc48732d58fca0/f47f3d4ef2e75aab?lnk=raot&fwc=1 in the cf9 orm mailing list. This thread discusses the exact issue I was wondering about. At the end, Barney Boisvert gives an example of how to do this (you have to click on "show Text" in the Bob Sivlerberg Post)

Since I can't figure out how to post code to this STUPID blog, you will have to visit the link.

I also had another issue, I wanted to still use offset and maxrows.  That was easy enough even though I tried to make it hard, and you can see that solution in my post to the same group: http://groups.google.com/group/cf-orm-dev/browse_thread/thread/ab1f8badf28dfbb5?hl=en

Wednesday, May 05, 2010

No Row with the Given Identifier Exists: [contact#0]

So I was setting up coldfusion 9 orm and dumping an object that had lots of related objects, an they had lots of related objects etc.. I kept getting the above error when outputting a one-to-many related object. After searching the database I noticed that that particular foreign key was being set to a 0, instead of a null value, but both those values where present in the linking table.

The solution was to use the missingrowignored="true" option in my orm definition. The record with id = 0 didn't exist and cf 9 orm tried pulling a record with that value (usually it expects a null value when nothing related exists). This caused it to error but I also got a positive from hasContact(). Anyway the missingrowignored="true" was the fix.

Tuesday, May 04, 2010

Specifying Security Credentials in Amazon Web Services AWS EC2

At cfobjective this year Chris Peterson gave a great presentation on running coldfusion in the cloud. In his demo he showed Amazon EC2 and showed how he used it for cloud computing. I was excited about this and I have been checking it out.

Right off the bat I got confused on how to enter my security credentials. I created a key pair and tried to enter that, but it didn't work. So after a couple weeks (I only was able to look at it for a few minutes a couple of different times) I found out what was going on. To get the necessary information, I had to go to the AWS EC2 website and after you login you click "Account" then you click "Security Credentials". Now, after this click, I always have to logon again. NO problem. Then, down below, you will see a section "Access Credentials" with 3 tabs, Choose the "Access Keys" tab, it is probably already selected since it is the first one. You see where it says "Your Access Keys" you can see the Access Key Id, and you simply click on show under the "Secret Access Key" column to see your Secret Key.

Then, using elsaticfox I click on credentials, or it prompts me for them. You can enter anything for the "Account Name" and the AWS Access Key and AWS Secret Access Key where those that we saw above.

Seems simple enough but one of those things that tripped me up.

Wednesday, April 28, 2010

How do I install the latest version of JAVA on Linux Ubuntu?

This is not easy. It's no wonder more people don't use Linux. I cannot see any normal person doing this. Until stuff like this is resolved and made easier Linux won't be coming to many desktops any time soon.

I found this article that walked me through it, but I had no idea what I was doing, just followed the instructions.

http://ubuntuforums.org/showthread.php?t=1437100

Monday, January 11, 2010

Error while executing the Hibernate query.

org.hibernate.hql.ast.QuerySyntaxException: state is not mapped [from state]

This is the error I got when trying to do a simple ORMExecute("from state"). This happened because the from statement is case sensitive. I did change the name of the .cfc but I still am forced to use a uppercase "s" in "State". The tablename is tblState, so I am still confused on this one, but changing the case to match the original cfc did fix it.

Sunday, January 03, 2010

ColdFusion Builder Beta 3 and subclipse (subversion)

The ColdFusion Beta Builder 2 expired on Jan 1, 2010 so I was forced to do something that I wanted to do anyway, install beta 3. I did that on my mac over the weekend. Once I installed it I had a problem getting subversion back on so I could update my repositories.

The first problem was when i selected the subversion components from their site http://subclipse.tigris.org/ It had required dependencies. After unchecking a few, I think mylyn and the graphing one It allowed me to go to the accept licenses screen. However the next and finish buttons stayed greyed out no matter what I chose. I chose the radio button to accept the license agreements and even made sure to scroll through all of them to the end and everything. Nothing worked. Google search gave me this: http://hippiex.instantspot.com/blog/2009/07/13/Easy-Subclipse-and-Coldfusion-Builder. I don't know how it made a difference because I didn't choose any of the components from that site, but just adding it as a site seemed to fix the licensing issue.

After that, I got subclipse to install but upon trying to update to head my repository I got the error "Thread attempted to read nesting count of a lock it did not own". After googling that I found some advice to add all the optional components, which I went back and did, one at a time. I can't remember what order I did them in but I ended up having to add them all except for collabnet merge client before it actuall worked without giving me that error.

Friday, November 13, 2009

How to call a controller in FW/1

Sean Corfiled wrote a simple MVC framework a few months ago called FW/1 (check it out here). I have been following the discussion list since the beginning. Last night I finally gave it a try. I was very impressed by it's simplicity. There isn't alot of documentation but there doesn't need to be a whole lot because it is so easy and Convention based. I had a view up and running based on the getting started doc in just a few minutes. Very nice. It is not only easy, understanding the conventions will surely help my development in model-glue and other frameworks, even when I don't use a framework this will help with my mental and code organization.

Then I moved to controllers. I just couldn't grasp how they were called. I reread the docs a few times and finally went to bed a defeated man. This morning I reread once more and it clicked, and the docs explain it perfectly, I was just a little thrown by the verbage, which I shouldn't have been. In model glue I call an event like so:

<event-handler name="maint.city">
<broadcasts>
<message name="needCity"/>
</broadcasts>
<results />
<views>
<include name="body" template="maint/city.cfm" />
</views>
</event-handler>

In FW/1 your url would be http://www.whatever.com/myapp/index.cfm?action=maint.city

FW/1 automatically calls the city() function in the controllers/maint.cfc controller. It seems almost silly that I couldn't figure this out, but It did escape me for a minute. I knew to create a controller and where to put it, but I wasn't sure how to call different functions etc.. In model-glue I would broadcast different messages. So I was thinking maybe I needed to call functions from my view or something, like city = rc.controller.getCityById().

Turns out, as mentioned that FW/1 calls the city() function automatically and i can call other stuff from inside that function.

Wednesday, November 11, 2009

Posting Code Snippets in blogger

I have always wanted a good way to post code snippets on this blog. My favorite is the way that Ben Nadel does it at his blog: http://www.bennadel.com/. I sent him a message asking him how he does this, but I have not heard back from him. I found a way to post code snippets but it ain't that pretty.

You use blockquote and the returned output from this parser: http://www.blogcrowds.com/resources/parse_html.php
ColdFusion Report Builder has Report Functions

I stumbled on a discussion at: http://www.justskins.com/forum/archive/index.php?t-5171.html that made me realize that Report Functions are available in ColdFusion Report Builder. I had been struggling with the expression builder using iif to conditional show fields. iif is a bear, you have to use DE(" ") and different things and it can be ugly.

As mentioned in the article, you cant use cfml syntax in the expression builder. But you can using report functions. This is a very nice feature. Since I get mad at adobe for that bad things better get happy for the good things. Nice one Adobe!
Coldfusion Report Builder Frustration

In my detail band I want to eliminate the blank lines when a field has no value. I my situation I return a lot # and subdivision and often times there isn't any listed so the line is blank. I don't want a blank line to show up. In Crystal Reports they let you add sections and you can choose to not print the whole section if it is blank anyway.

Coldfusion report builder has an option "Remove Line When Blank" but it flat out does not work for me. Nothing is removed. Whatever the secret combination of options is to make this work, I can't figure it out. C'mon Adobe, we really need this tool, please upgrade and fix it.

Thursday, October 29, 2009

Salesforce.com frustration

We are nearing our limit of 1GB storage space in salesforce.com. I emailed my sales rep about increasing storage and his reply was $1500 for an additional 1GB. After some frantic screaming (by me) he said he had made a mistake and new pricing was actually$750. Anyway it sent me on a tyraid because I feel such a sense of vendor lockin with salesforce and such a prisoner to their EXPENSIVE product line that I did some research on alternatives. My post to a blog that sums up my problems very well eplains my thoughts pretty good. We are currently at 95% usage. See image below for our actual usage right now.

Blog Post: http://forcemonkey.blogspot.com/2009/08/salesforcecom-data-storage-space.html

My Comments:

Great post. This is exactly the problem we have and our stats look exactly like yours. 61% used up in tasks, and our usage grows about 5-7 % per month. Problem is that 15 of our users are sales people who call, email and do stuff all day long. So 50 - 80 tasks is nothing when you consider, emails, calls etc..

It is pretty scary the strangle hold salesforce is applying to my company. The quoted price for more data was at first $1500 per year for 500 meg, but after screaming loud enough he told me he made a mistake and the new pricing was $750. We have 30 users and pay approx $36,000 per year for salesforce. In a world where google gives me 17 GB free, salesforce should be a little more liberal with their storage space. They aren't the only kid on the block any more either.

I could save 70% with sugarcrm and 88% with zoho. Admittedly, especially since we are so comfortable with it, salesforce is still top dog (in my opinion) and worth some extra bucks. But at some point you break the camels back. Then you give up a few features (increasingly fewer) to save $25 to $30 K per year.

Monday, October 26, 2009

Using IIF with ColdFusion Report Builder

I was trying to do some conditional logic in coldfusion report builder and having some problems. Evidently the problem was with my misunderstanding of IIF. I was trying the following:

IIF (len(myvar), myVar, myVar2)

The way IIF works is that it expects strings, indicating variables, which to me is counterintuitive. But the solution that worked was:

IIF (len(myvar), 'myVar', 'MyVar2')

This evaluated to the correct values of those variables and works great.
Inserting a Line Break in ColdFusion Report Builder

I had a field that I wanted to insert a line break. This field needed to be dynamic in it's sizing and it is very possible that it will have to wrap. So It was not an option to just place another field box or textbox below the current one, because if it wrapped and expanded, then the text would flow over the box below.

So I needed a way to force a line break inside the expression builder.

Turns out I just needed to insert a "Chr(10)". More detail: query.fieldname & Chr(10) & ' more text here if you want'

That worked great and now the size of the text in query.fieldname doesn't matter. If it wraps everything is just pushed down, as I wanted.

Wednesday, October 21, 2009

Screen Capture and Screen Recording Free Software

Ray Camden posted to his blog using a demo he recorded using the following software to record his screen: http://www.jingproject.com/.

Recording is capped at 5 minutes in both the free and pro version. The pro version is only $14.95 per year. Since it is capped it won't work for long demos. But for short instruction clips or demos of individual items it looks like a great tool, and such a good price.
Displaying the Copyright Symbol &copy in Coldfusion Report Builder

I wanted to display the copyright symbol in coldfusion report builder. We put that at the bottom of each page in our report to state our copyright protection of our content. This took me a while to find, but it is simple. I created a query field and added the following to that field:

chr(169) & ' Copyright 2009 Companyname'

The chr(169) was the trick.

Tuesday, September 08, 2009

mySql server won't start after upgradge to mac osx 10.6 Snow Leopard

After upgrading to Snow Leopard the mySQL server would not start. I found the solution here:

http://www.macintouch.com/readerreports/snowleopard/topic4883.html. You have to search down the page to find the solution, search for Ralph Martin or mySql.

The upgrade to Snow Leopard seems to have broke the symbolic link.


Ralph Martin

I too found that MySQL wouldn't start after upgrading to Snow Leopard.

The answer seems straightforward. Previously there was a symbolic link from
/usr/local/mysql
to
/usr/local/mysql-5.1.37-osx10.5-x86_64
and this seems to have been deleted by the upgrade process.

I got MySQL working again by doing

cd /usr/local
sudo ln -s mysql-5.1.37-osx10.5-x86_64 mysql

(note that you may have to modify this slightly if your MySQL is a different version).


Sunday, August 02, 2009

Show hidden files in finder

There are many times when I want to see hidden files and folders when using my mac. When making changes to the Apache config is one of those times. So how do I make it so I can easily see those files? I found talk of this on this page:

http://www.macworld.com/article/51830/2006/07/showallfinder.html


Which has a link in one of the comments to this nifty little program:

http://gotoes.org/sales/ShowHiddenFilesMacOSX/

I installed this and it makes it easy toggle on and off the ability to see hidden files and folders.

Monday, July 20, 2009

Fixing the IE 8 warning - ‘Do you want to view only the webpage content that was delivered securely?’

Ever since upgrading to IE8 this warning has been driving me crazy. It pops up on almost every page I visit. I found a great article on how to disable it and program for it.

http://blog.httpwatch.com/2009/04/23/fixing-the-ie-8-warning-do-you-want-to-view-only-the-webpage-content-that-was-delivered-securely/