Vaccination Module with Coldfusion

Vaccination module is one of my pre-sales projects what I've done in our company. The object is to record of the vaccination of children. The nurse can perform the vaccine to the children in hospital and can record of the vaccination of the same children from the other hospitals. On the other hand, the nurse can trace which vaccine has been performed and which vaccine hasn't been performed yet as missed vaccination.

I've developed this module with Coldfusion 8, Oracle and jQuery. In jQuery, I've integrated with facebox jQuery plugin

[More]

truncate table with foreign key constraint

Yesterday, I need to delete data from all tables of our projects. First of all, I thought it's so easy to delete data from tables and don't need to take not much time to delete. When I saw the table structure, it's my godness and speechless. Because they have so many relationship between each others and have over 1 million data. If I use "Delete from" command of Oracle, it would take a long time to delete and server might be crushed. That's why I decided to use Truncate table command of Oracle. Unfortunately, Truncate table command cannot proceed if the table has foreign keys relationship with another table. That's why I googled and how to delete data from all tables with Truncate table command. Finally, I found the following 3 steps I need to do:

  • Disable Foreign Keys
  • Truncate Table
  • Enable Foreign Keys

So, I need to implement above 3 steps with Coldfusion.

view plain print about
1<!---
2Get Primary Keys name of the table.
3Fetch TABLE and CONSTRAINT_NAME of foreign keys table
4--->

5<cfquery name="QryContrList" datasource="#application.datasource#">
6    select TABLE_NAME, CONSTRAINT_NAME
7    from user_constraints
8    where R_CONSTRAINT_NAME = 'TBL_USER_PK'
9</cfquery>
10
11<cfdump var="#QryContrList#">

[More]

Multiple Area Chart in Coldfusion

In my new demo project, I need to draw Area Chart with CFChart for letting know the process rate of data. My boss told me to draw the Area Chart in Coldfusion like that.

As far as I know, CFChart support only single bar in Area Chart type. That's why I was supposed to complaint him that's not possible to draw such area chart style in Coldfusion. But I may need to google it before complaining. Unfortunately, no CF resources sites show how to draw multiple bar in Area Chart and they only recommend to use Line Chart instead of Area Chart for drawing multiple line.

Fortunately, CF Docs show how to draw Area Chart with CFChart as follow.

view plain print about
1<cfchart
2    chartheight="200"
3    chartwidth="300"
4    xaxistitle="Year (Age)"
5    yaxistitle="Data"
6    format="png">

7    
8    <cfchartseries type="area">
9        <cfchartdata item="10" value="40">
10        <cfchartdata item="20" value="50">
11    </cfchartseries>
12</cfchart>

After rendering above coding, the result will be as follow.

[More]

Disguise Oracle Sorting

The more I know the core functions and usage of Oracle, the more I love Oracle. Because if we want to increase days in Oracle query, it's easy to add "+" and the number of days like "SYSDATE + 5". Likewise if you want to concatenate two strings in Oracle query, just put "||" sign between two strings. Now what I know is if we want to sort data in Oracle query without using field name, we can represent 1,2,3 as field name.

Let's see the query. In this query Name, SEX and DOB will be displayed from tbl_Users table. First of all, the youngest users will be displayed first. After that, sorted by alphabet Name second and Sex.

view plain print about
1<cfquery name="SortWithField" datasource="myDSN">
2    SELECT NAME, SEX, DOB from tbl_Users
3    ORDER BY DOB, NAME, SEX
4</cfquery>

Here is the query disguise the field name to sort the query.

view plain print about
1<cfquery name="SortWithNumber" datasource="myDSN">
2    SELECT NAME, SEX, DOB from tbl_Users
3    ORDER BY 3, 1, 2
4</cfquery>

Above query, it will be odd that you will see 3,1,2 number instead of field name. To clarify, 3 represent as DOB, 2 represent as Sex and 1 is Name. How Oracle know these numbers represent as field name in the query. It's because of we declared those field after SELECT command. If we want to display alphabet name in the query, we need to change like that "ORDER BY 1,3,2".

It will be displayed as the format of the first query.

Playing Oracle Timestamp

Today I feel myself to create next timestamp function in Oracle. Because when I want to know the next timestamp of today date, I don't want to put individual coding in the SQL statement. That's why I decided to create one simple Oracle for common usage in my project.

In Oracle, adding timestamp is very simple. Don't need to write so many coding.

If we want to know next year and next month of today date, we must know the usage of ADD_MONTHS function of Oracle of course.

view plain print about
1add_months(date1, number)

Above coding, date1 represent the date of you want to increase and number represent the amount of year/month you want to increase.

  • If I don't create common function in Oracle for next timestamp, we will have to write as follow.
  • If we want to know the next year of today date, you need to write like that, ADD_MONTHS(SYSDATE, 12)
  • If we want to know the next month of today date, you need to write like that, ADD_MONTHS(SYSDATE, 1)

For date, hour, minute and second, we don't need to know ADD_MONTHS function like above timestamps.

  • If we want to know the next day of today date, you need to write like that, SYSDATE + 1
  • If we want to know the next hour of current time, you need to write like that, SYSDATE + 1 * 1/24. For 1/24, 1 day has 24 hours.
  • If we want to know the next minute of current time, you need to write like that, SYSDATE + 1 * 1/24/60. For 1/24/60, 1 day has 24 hours and 1 hour has 60 minutes.
  • If we want to know the next second of current time, you need to write like that, SYSDATE + 1 * 1/24/60. For 1/24/60/60, 1 day has 24 hours, 1 hour has 60 minutes and 1 minute has 60 seconds.

    [More]

Simple change BlogCFC mobile version to jQueryMobile

Yesterday I've upgraded my blogCFC mobile version to jQueryMobile. Currently, blogCFC use jQtouch as their mobile version. Once I saw jQueryMobile, I want to upgrade and test it at my site. Installation jQueryMobile is kinda simple.

First of all, we need to include following stylesheet and JS file into our CFM page.

view plain print about
1[link rel="stylesheet" href="jquery.mobile-1.0a2.min.css" /]
2[script src="jquery-1.4.3.min.js"][/script]
3[script src="jquery.mobile-1.0a2.min.js"][/script]

After that, we need to change a bit of blogCFC mobile version index file like that.

[More]

Simple Learning about Oracle Tuning

Today I have to retrieve data from the largest table of my project in Oracle. Approximately, this table has more than 1 million records and need to retrieve data carefully when we need. Now what I need to do is to retrieve negative quantity from this table.

There are two ways to retrieve negative quantity from the table. One is systemically and second is simple way.

view plain print about
1<cfquery name="CheckOne" datasource="myDSN">
2    select * from nh_inv_trx_tmp
3    where transaction_date < '7-Jan-2008'
4    and abs(quantity) <> quantity
5</cfquery>

view plain print about
1<cfquery name="CheckTwo" datasource="myDSN">
2    select * from nh_inv_trx_tmp
3    where transaction_date < '7-Jan-2008'
4    and quantity < 0
5</cfquery>

[More]

Kill Query Session in Oracle

In Microsoft SQL, we can trace currently which SQL query takes execution time and load of each SQL query in SQL Profiler. In Oracle, what should we do? It's not that simple like Microsoft SQL. Open TOAD and login as SYSTEM authentication. Then type following statement into TOAD SQL.

view plain print about
1<!---
2MYDSN is simple database of mine.
3Put your database name instead of MYDSN.
4--->

5
6SELECT * FROM V$SESSION WHERE STATUS = 'ACTIVE' AND USERNAME = 'MYDSN'

Run this query. After that, all active query will be displayed and note which query execution time takes so long.

[More]

Top of Page