filefield attribute in cffile with CFMX7 and CF9

Recently, I've found that CF9 doesn't give any error if filefield attribute isn't set in cffile. I'm not sure whether it's good or not. Because I've developed simple program for migration data from old server to new server with *.csv file. I've developed and tested it in CF9 and it working fine. But when I deployed it into CFMX server, I got the error just like "filefield attribute in cffile is .....". That's why I was amazed and how come it error is coming out even thought it works fine in our UAT server. So, I've looked through cffile tag and check filefield attribute is missing or not. Oddly, it's really missing. Now, I can convince that CF9 won't give you any error message if you don't want to set filefield attribute cffile. Cool or not, I'm not sure.

view plain print about
1<!--- work fine in CF9 without filefield attribute in cffile --->
2<cffile
3    action="UPLOAD"
4    destination="[dir_path]"
5    nameconflict="MAKEUNIQUE">

6<cfset csvfile = FileRead("[dir_path]\#file.serverfile#")>
7
8<!--- filefield attribute is required in cffile in CFMX --->
9<cffile
10    action="UPLOAD"
11    destination="[dir_path]"
12    nameconflict="MAKEUNIQUE"
13    filefield="fileupl">

14<cfset csvfile = FileRead("[dir_path]\#file.serverfile#")>

Display the latest record with descending in Oracle

This week is very busy time for me. Because I have to implement HL7 segment with Oracle Stored Procedure. As we all know, Oracle SQL command isn't that same with Microsoft SQL. That's why some of command are very complicated for me to implement. Today, I need to retrieve the only one latest record from table with Oracle. In Coldfusion, it's very easy. To put maxrows = "1" and descending in query as follow:

view plain print about
1<cfquery name="qryGetLatest" datasource="myDSN" maxrows="1">
2    SELECT U_ID FROM TBL_USER
3    ORDER BY U_ID DESC
4</cfquery>

In Microsoft, it's very simple. To put TOP command and descending in query as follow:

view plain print about
1SELECT TOP U_ID FROM TBL_USER
2ORDER BY U_ID DESC

In Oracle, it's not that easy. If we put ROWNUM and descending in query, the first record will be returned. Because ROWNUM doesn't work with Order By descending in query. That's why we need to do with query with query formula in Oracle as follow:

view plain print about
1SELECT U_ID FROM
2    (SELECT U_ID FROM TBL_USER
3    ORDER BY U_ID DESC) CLONE_USER
4WHERE ROWNUM = 1

Phweee...!!! Oracle crack my brain again. :)

Coldfusion BlockFactor is damn slow in Oracle

I cannot convince why query execution time is damn slow with "BlockFactor". Last week, I've read the following article from Adobe Performance tuning for ColdFusion applications. In this article, the author recommended that using "BlockFactor" in CFQuery can substantial performance gain.

blockFactor By default, the cfquery tag returns results sets from databases one record at a time. The blockFactor attribute tells ColdFusion server (which passes this information to the database driver) to retrieve between 1 and 100 records at a time. For queries that typically return result sets larger than a single row, requesting multiple rows in a block can result in a substantial performance gain. Setting this value too high can diminish performance as well, so it is recommended that you tune this number based on the expected average size of the result set.

Note: If you know that less than 100 rows will be returned (for example if you're writing a query that either returns 0 or 1 rows), do not bother adding the blockFactor attribute.

[More]

Playing Coldfusion Application CFC

I've found yesterday that Raymond wrote Two quick Application.cfc questions on his blog It's simple questions with so many hidden questions for me. Honestly, I'm too rare to use application.cfc and "this" scope in current projects. Because most of our projects are based on CFMX7. That's why I sometimes self-studying by myself when I wanna learn new things in Coldfusion.

After reading this post and comments, I realized that we can declare two variables between "this" scope in application.cfc. There are "this.name" and "this.datasource". So, I've tested as follow:

view plain print about
1<!--- application.cfc --->
2<cfset this.name = "testingCFC">
3<cfset this.datasource = "DSNTestingCFC">

view plain print about
1<!--- index.cfm --->
2<cfdump var="#application#">

When I run this coding, the result is as follow:

I found that this.name="TestingCFC" is stored as applicationname in Coldfusion. On the other hand, I lost this.datasource = "DSNTestingCFC". It's odd that Coldfusion can automatically recognize that current datasource name is "DSNTestingCFC" in CFQuery tag.

Simple Google Chrome Extension for BlogCFC Feed Reader

Today, I've read how to create Google Chrome extension. It's interesting and want to create Blog Feed Reader. That's why I kept going with this article and create a simple extension for blogCFC.

First of all, I need to create a folder for the extension. Then, create manifest.json file and needed to put following coding into it.

view plain print about
1{
2    "name": "Against All Odds Feeds",
3    "version": "1.0",
4    "description": "Fetching RSS Feeds from BlogCFC",
5    "browser_action": {
6        "default_icon": "pps.gif", <!--- icon --->
7        "popup": "RSS.html" <!--- file which read RSS --->
8    },
9    "permissions": [
10        "http://www.ppshein.net/"
11    ]
12}

After that, I need a image to represent the extension on Google Chrome Toolbar.

[More]

CFLOOP and CFScript Loop between Coldfusion 8 and Coldfusion 9

In my previous post, I've shown To increase the speed of Coldfusion application. Fortunately, @James Moberg commented about between the performance of CFLoop and CFScript Loop. He told me that For Loop in CFScript is oddly slower than CFloop. As some developers' suggestion, using everything (probably) CFScript is faster than others comparing the performance and rendering time. That's why I want to test the different between CFScript Loop and CFLoop with CF8 and CF9.

I've created the following simple coding and render in CF8 first.

view plain print about
1<!--- Start of CFScript --->
2<cfscript>
3 script_startTime = getTickCount();
4 script_value = 0;
5 for(i=1; i lte 1000000; i = i + 1)
6 {
7 script_value = script_value + 1;
8 }
9
10 script_endTime = getTickCount() - script_startTime;
11    
12 WriteOutput("<b>CFScript LOOP:</b> #script_endTIme#ms");
13
</cfscript>
14<!--- End of CFScript --->
15<br>
16<!--- Start of Normal --->
17<cfset normal_startTime = getTickCount()>
18<cfset normal_value = 0>
19<cfloop from="1" to="1000000" index="j">
20    <cfset normal_value = normal_value + 1>
21</cfloop>
22<cfset normal_endTime = getTickCount() - normal_startTime>
23<cfoutput><strong>CFLOOP LOOP</strong> : #normal_endTime#ms</cfoutput>
24<!--- End of Normal --->

[More]

To increase the speed of Coldfusion application

In my previous time, I didn't notice the performance of our CF application. Because all CF applications are fine and working smoothly with less data amount in local internet. Approximately, we don't have no more 20 tables in our database and not more than 100000 records in each tables. That's why never encounter our server is hanging and crushed. When we launched our project to Live, our server sometimes hang and application timeout. My GM told me that it's because of CF cannot handle the large amount of data and we should change to .NET (C#) version. I cannot accept his suggestion. It's not because of CF. It's because of the way of our coding. That's why we need to figure out the solutions and need to enhance our coding. In our coding, we use a lot of evaluate and looping. In Adobe documentation, using evaluate may decrease of CF performance and use other available functions instead of evaluate. That's why we need to change our coding as follow:

view plain print about
1<!--- we used like that which is awful --->
2<cfset value = evaluate("form.field#i#")>
3
4<!--- As suggestion, we change to --->
5
6<cfset value=form["field#i#"]>

[More]

Simple Create User in Oracle with script

Creating user in Microsoft SQL is very simple. It's to go Microsoft SQL enterprise manager and create user it. In Oracle, creating user in sqlplus is simple. I'm not sure whether there is another way or not. But we normally use sqlplus when we need to create user.

First of all, I need to login into sqlplus. Then, need to type following command.

view plain print about
1<!--- create user --->
2create user ppshein identified by ppshein;

view plain print about
1<!---
2The following statement creates the database username "ppshein",
3and grants the RESOURCE system role to alison.
4And mean that username and password is same.
5--->

6grant connect, resource to ppshein;
7
8<!---
9If want to change another password, use following command
10--->

11
12grant connect, resource to ppshein with ppshein123;

view plain print about
1<!---
2Create role
3--->

4grant create role to ppshein;

view plain print about
1<!---
2Create View
3--->

4grant create view to ppshein;

Top of Page