Tuesday, November 1, 2011

Null Values within SQL Select Statement with CFQUERYPARAM

I was working on code where I wanted to store nulls into the database and query based on those nulls.

<cfquery name="qRetrieve" datasource="#getDSN().getName()#">
 select semesterID,Major_ID,Campus_ID,AdmTypeReqID,startDate,startOrEndFlag
 from isFull
 where 
  semesterID = <cfqueryparam value="#arguments.DTO.getsemesterID()#" cfsqltype="CF_SQL_INTEGER">
  AND Campus_ID = <cfqueryparam value="#arguments.DTO.getCampus_ID()#" cfsqltype="CF_SQL_INTEGER">
  AND startOrEndFlag = <cfqueryparam value="#arguments.DTO.getstartOrEndFlag()#" cfsqltype="CF_SQL_INTEGER">
  AND AdmTypeReqID= <cfqueryparam value="#arguments.DTO.getAdmTypeReqID()#" cfsqltype="CF_SQL_INTEGER" null="#iif(arguments.DTO.getAdmTypeReqID(),true,false)#">
  
</cfquery>



Notice the last line is using the function IIF instide the null attribute of cfqueryparam.  In the SQL Insert and Update statements, this just works.  I am noticing in interacting with MSSQL 2005 this is not working.  I am getting zero rows back when it should be in the 5-10 rows. For now I have replaced my last line of code with the following 5 rows of code

AND 
   <cfif arguments.dto.getAdmTypeReqID() EQ "">
   AdmTypeReqID is null
   <cfelse>
   AdmTypeReqID = <cfqueryparam value="#arguments.DTO.getAdmTypeReqID()#" cfsqltype="CF_SQL_INTEGER" >
   </cfif>

Has anyone else ran into this?

Monday, October 3, 2011

coldbox environment safe email service

Almost a year ago I updated an interceptor I built for coldBox to allow our non-production environments (development and testing) to have a smart configuration that it DOES NOT send the email to the production users.  And I just realized that I never wrote a blog post on it.

Using the core functionality of coldbox, I configure our development and test environments to have its own configuration.

ie.
function configure() {
     environments = {
          localDevelopment = "URL.local",
          development = "URL"
     };
 }


function localDevelopment() {
     //Register interceptors as an array, we need order
     local.newInterceptors = {class="EnvironmentSafeMailService",
          properties={EmailTrace=true, EmailSend=false, EmailOverrideAddress="email@address.com"}
     };
ArrayAppend(interceptors ,local.newInterceptors);

         }


Here is the link to the two download areas

My WebSite:
http://extra.cfhero.com/coldbox-add-ons/coldbox-environmentsafeemail

ForgeBox:
http://coldbox.org/forgebox/view/ColdBox-Interceptor---Environment-Safe-Mail-Service

If you are curious how I built it, here is my earlier blog post on that.
http://www.cfhero.com/2009/11/enhancing-coldbox-adding-core.html


Thursday, September 15, 2011

coldfusion builder 2 extension not displaying browse button on type=projectdir

I'm in the process of creating an extension that fires from the RDSView (from a database table).  Basically I would like it to create 7 files for me by using the table's columns I selected.  *PERFECT*, I got the files being created, but I have to TYPE in the LOCATION to store the files <-- WHAT --  Yes, I said I have to type in the full path to where I want the files to be stored.

So my question to anyone who might see this blog is -->  Is there a way via (call back, response, etc) in an cfbuilder extension for the user to pick the project and/or folder as an input?

PS.  if you read this and don't know the answer, please "socialize" it (tweet, FaceBook, etc) so possibly the correct person with the answer can answer it.  *THANKS*

**UPDATE 9/29/2011**
I was able to email a contact at Adobe with this issue, and after working back and forth, it came up that the input of type="projectdir" does NOT work when using a REMOTE server. How disappointing!!  Anyways, at the same time I suggested it as a feature as #2988224 within the Adobe ColdFusion Builder Bug/Feature system (bugbase @ https://bugbase.adobe.com/).

Saturday, July 23, 2011

coldfusion builder extensions on remote servers

If you have read my past posts you know I run my development environment with vmware workstation, where I have a "production" like setup on a vm server running within vmware workstation on my development machine.  I do this to keep my laptop footprint small, so if i need to start it up to fix a production issue, I don't have my development environment interrupting my production debugging.

But that is not my point in this article, I just switched to coldfusion builder to use the extensions feature it supports.  But when I first setup the server configuration and extensions in builder it would run but not write any files to my workspaces.  The error it provided was pointing my laptop's workspaces and not the server's directories.

Surprisingly, I have found no other person blog about this (maybe it was my search criteria), but I am hoping this little blog posts help others in need out there.

The solution is in the "mappings" configuration for the server setup.  You have to map the local folder to the remote folder.  Once you do that, when builder sends the folder to the extension it uses the mapping to convert it to the server directories.

Here is a screen shot of the mappings tab in the server configuration within coldfusion builder 2.

Friday, November 5, 2010

feeling like a nub.. an awesome feature existed since coldfusion 7

Yep, I feel like I know coldfusion pretty well. Well I thought I did...

Today, I was looking over cfquery (and now I forget why), but noticed there is an attribute called "RESULT".  I guess I need to go over all the things added since CFMX.

But anyways I quickly wrote a quick page to do insert, select, and delete.

<cfquery name="iRtr" datasource="commons" result="rRtr">
 insert into staff.dbo.test (testData)
 values('test1')
</cfquery>
<cfdump var="#rRtr#">

<cfquery name="qRtr" datasource="commons" result="rRtr">
 SELECT * 
 FROM staff.dbo.test
</cfquery>
<cfdump var="#qRtr#">
<cfdump var="#rRtr#">

<cfquery name="dRtr" datasource="commons" result="rRtr">
 delete
 FROM staff.dbo.test
</cfquery>
<cfdump var="#rRtr#">

And to my suprise, there were some really cool things that appeared. Like the value of the identity column, how many rows were inserted/deleted. Just amazing!  Here is the output of the query above.

Monday, August 9, 2010

coldbox milestone 6 released - moduleExternalLocations

I'm excited to move from m5 to m6 within the coldbox 3.0 milestones. The addition of moduleExternalLocations will allow our team to compile our modules into JAR like packages. For example, we have a bunch of util modules that we now can create a util container folder, and include them all by just providing it in the configuration cfc file!!

We currently have one util module with all those "features" under. This new feature will allow us to split that one module into many giving us better development/release control! (PS. yes there are other ways of solving the same issues, but this provides a simple framework solution)

Awesome work coldBox team!

Wednesday, May 26, 2010

Subversion's post-commit on windows with ANT

I was very disappointed when I installed subversion and noticed that the commit scripts were non-windows based within the windows-installer for subversion. Well I quickly got over that, and realized ANT had all my needs.

I searched the web for ANT Subversion Commit Scripts; and it returned some interesting articles, but no solid examples. So I quickly, researched ANT SVN plugins, then realized, I will be just executing SVN command line utilities to get the info I needed.

First, you can find these details almost anywhere, but quickly for you POST-COMMIT script to work, windows must need to know how to execute it, therefore, it must have a recognizable extension (like .bat). So to start out with rename the file that came with the repository to post-commit.bat

Second, subversion hooks run in a non-initialized dos command. That means you are not going to have any of the environment variables to your exposure.

The following is the code I have within my post script to execute my ANT post-commit.
e:
cd \path-to-hooks

"path-to-ant-executable" -buildfile post-commit.build -Dpath.repository=%1 -Drevision=%2 > post-commit.log

Notice the -buildfile {filename} -Dproperty=value structure. This is how you run ALL ANT scripts. Go and search for ANT on the web if you need more details. Also notice that I'm capturing the output into a log file. If the log file doesn't get created, then you path-to-ant is wrong.

Now that I have my post-commit script trying to execute an ANT script; we need to have an ant script to execute. Our team has many repositories, so we are using the <import> directive in ANT to share code. But before I jump to the import I'm going to jump into the guts first.

The following is the shared code to work with the command line utilities of subversion. Notice svnget.all is the only target that has a depends attribute. This is to make this code as re-usable as possible. ANT allows (from the command line) to execute as many targets as needed. Or as i'll show you later, in our post-commit.build file we will have an empty target that has depends to execute the targets we want from this file.

<?xml version="1.0" encoding="utf-8"?>
<project name="svn-email" default="build">

    <target name="svnget.all" depends="svnget.author,svnget.info,svnget.changed,svnget.diff">
    </target>
    
    <target name="svnget.author">

        <exec executable="svnlook" outputproperty="svnlook.author">
  <arg value="author"/>
  <arg value="${path.repository}"/>
  <arg value="-r ${revision}"/>
 </exec>
 <echo message="${svnlook.author}" />

    </target>
    
    <target name="svnget.info">
    
        <exec executable="svnlook" outputproperty="svnlook.info">
  <arg value="info"/>
  <arg value="${path.repository}"/>
  <arg value="-r ${revision}"/>
 </exec>
 <echo message="${svnlook.info}" />

    </target>
    
    <target name="svnget.changed">

        <exec executable="svnlook" outputproperty="svnlook.changed">
  <arg value="changed"/>
  <arg value="${path.repository}"/>
  <arg value="-r ${revision}"/>
 </exec>
 <echo message="${svnlook.changed}" />

    </target>
    
    <target name="svnget.diff">

        <exec executable="svnlook" outputproperty="svnlook.diff">
  <arg value="diff"/>
  <arg value="${path.repository}"/>
  <arg value="-r ${revision}"/>
  <arg value="--no-diff-deleted"/>
  <arg value="--no-diff-added"/>
 </exec>
 <echo message="${svnlook.diff}" />

    </target>

    <target name="svn.email">

 <property environment="svnlook.author" value=""/>
 <property environment="svnlook.info" value=""/>
 <property environment="svnlook.changed" value=""/>
 <property environment="svnlook.diff" value=""/>

        <mail mailhost="smtp.psu.edu"
            tolist="l-adm-web@lists.psu.edu"
            from="admissions@psu.edu"
            subject="SVN ${path.repository} - ${svnlook.author}" 
            message="
${svnlook.info}

${svnlook.changed}

${svnlook.diff}
"/>

    </target>

</project>


Now that we have a shared code setup, we just need to create a post-commit.build file that looks like the following inside the hooks directory in your repository.

<?xml version="1.0" encoding="utf-8"?>
<project name="post-commit" default="build">

 <import file="path-to-SharedHooks/svn-email.build"/>

 <target name="build" depends="svnget.all,svn.email">
 </target>

</project>