Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > ColdFusion

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-22-2010, 07:14 PM   PM User | #1
JohnShell
New Coder

 
Join Date: Dec 2009
Posts: 42
Thanks: 13
Thanked 0 Times in 0 Posts
JohnShell is on a distinguished road
Help with cfif and cfqueryparam

I do not know how to accomplish what I want to do. Have SQL Insert statement with cfqueryparam.
Have form that users can add begin date | end date | type of hrs | number of hrs
The type of hrs is a list with 4 selections. If user selects "Rel Comp" then they are required to complete additional begin and end dates in RCbeginDate and RCendDate fields.
Database has following date fields: startdate | enddate | RCbeginDate | RCendDate. If "Rel Comp" not selected then db fields RCbeginDate and RCendDate are null.
If user has two or more entries - one not "Rel Comp" and the other is, then user is prompted to enter dates for RCbeginDate and RCendDate. Those dates post to the db for the row that is not "Rel Comp" and it should not.
It seems an if (cfif) statement should stop that but how?

Code:
<cfloop from="1" to="4" index="i" step="1">
	<cfif IsDate(evaluate("Form.StartDate" & i))>
<cfquery name="qInsertRequest" datasource="RAWH">
Insert into RAWH 
       (EmpPIN,
	Empname,
    	dateRequested,
	startdate,
       	stopdate,
       	TypeHrs, (option list showing Comp Time|Credit Hrs|OT|Rel Comp) 
	NoOfHours,
             projects,
             justification,
             RCbeginDate,
	RCendDate,
             RCLvSlip,
             reqDecision,
             denialReason)
VALUES (
     <cfqueryparam cfsqltype="cf_sql_varchar" value="#Form.EmpPIN#" null="#IIF(Len(Trim(Form.EmpPIN)), DE('no'), DE('yes'))#" />,

     <cfqueryparam cfsqltype="cf_sql_varchar" value="#Form.EmpName#" null="#IIF(Len(Trim(Form.EmpName)), DE('no'), DE('yes'))#" />,	 
       
       getdate(),
       
     <cfqueryparam cfsqltype="cf_sql_timestamp" value="#Evaluate("Form.startdate" & i)#" />,
	  
     <cfqueryparam cfsqltype="cf_sql_timestamp" value="#Evaluate("Form.stopdate" & i)#" />,

     <cfqueryparam cfsqltype="cf_sql_varchar" value="#Evaluate("Form.TypeHrs" & i)#" />,  (option list which should have if statement)		
     <cfqueryparam cfsqltype="cf_sql_decimal" scale="2" value="#Evaluate("Form.NoOfHours" & i)#" />,
              
     <cfqueryparam cfsqltype="cf_sql_varchar" value="#Form.projects#" null="#IIF(Len(Trim(Form.projects)), DE('no'), DE('yes'))#" />,     
          
     <cfqueryparam cfsqltype="cf_sql_varchar" value="#Form.justification#" null="#IIF(Len(Trim(Form.justification)), DE('no'), DE('yes'))#" />,    
       
     <cfqueryparam cfsqltype="cf_sql_timestamp" value="#Form.RCbeginDate#" null="#IIF(Len(Trim(Form.RCbeginDate)), DE('no'), DE('yes'))#" />,    
       
     <cfqueryparam cfsqltype="cf_sql_timestamp" value="#Form.RCendDate#" null="#IIF(Len(Trim(Form.RCendDate)), DE('no'), DE('yes'))#" />,       
       
     <cfqueryparam cfsqltype="cf_sql_char" value="#Form.RCLvSlip#" null="#IIF(Len(Trim(Form.RCLvSlip)), DE('no'), DE('yes'))#" />,
       
        null, 
        null)
         
      </cfquery>
	</cfif>
</cfloop>
Would appreciate help with the if statement and where and how to place it.

John
JohnShell is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:30 PM.


Advertisement
Log in to turn off these ads.