My Account   Contact Us    
  
» HomeProductsSupportDeveloper CommunityCompany
Missing Column List in Insert Into Statement
Although it is syntatically correct to omit the column list, it leads to difficult maintenance

Type: bugprone
Severity: (2)

Incorrect example
<cfquery>
  INSERT INTO table
  VALUES (1,2,3)
</cfquery>

Resolution

<cfquery>
  INSERT INTO table (one,two,three)
  VALUES (1,2,3)
</cfquery>
Explanation

Many old school database developers prefer to leave out the column list in the INSERT INTO statement. While this is syntactically correct (providing your value list is in the correct order) on most RDBMS's, it makes it very difficult to maintain the code, and can lead to bugs. To use this method you must ensure that the value list is in the order that the database columns were defined in, which is a bug prone task to complete every time you want to add data to a table.

 



Sign up for our newsletter: | Subscribe with RSS: RSS
© ActivSoftware 1999 to 2005 | Privacy Statement