Invalid data '' for CFSQLTYPE CF_SQL_INTEGER

Hello experts.
Using my query i have the error :Invalid data '' for CFSQLTYPE CF_SQL_INTEGER
I get this error for a value with cfparam:
<cfparam name="Form.TUVmonth" default="">
The query is like:
<cfquery name="InsertArtikel" datasource="#dsn#">
INSERT INTO ARTIKEL (.........TUVmonth)
Values (............,<cfqueryparam value="#Form.TUVmonth#" cfsqltype="cf_sql_integer">)
</cfquery>
The type in DB is int.
(i have this problem only when i don't put any value in the formfield Tuvmonth.)
Any help?
LVL 2
PanosAsked:
Who is Participating?
 
erikTsomikSystem Architect, CF programmer Commented:
it probably because the form variable is blank you can do the following
<cfif NOT isNumeric(FORM.TUVmonth)>
   <cfprocparam type="in" cfsqltype="cf_sql_integer" value="0">
<cfelse>
   <cfprocparam type="in" cfsqltype="cf_sql_integer" value="#FORM.TUVmonth#">
</cfif>

or even easier
<cfprocparam type="in" cfsqltype="cf_sql_integer" value="#val( FORM.TUVmonth)#">
0
 
PanosAuthor Commented:
Hi
If i use the cfprocparam in the query must i use the cfparam too?
(<cfparam name="Form.TUVmonth" default="">
<cfquery name="InsertArtikel" datasource="#dsn#">
INSERT INTO ARTIKEL (.........TUVmonth)
Values (............,<cfprocparam type="in" cfsqltype="cf_sql_integer" value="#val( FORM.TUVmonth)#">)
</cfquery>)
0
 
erikTsomikSystem Architect, CF programmer Commented:
try not to use it
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
PanosAuthor Commented:
I have this error:
 Context validation error for tag cfprocparam.
The tag must be nested inside a cfstoredproc tag
0
 
erikTsomikSystem Architect, CF programmer Commented:
use cfqueryparam
0
 
PanosAuthor Commented:
Hi
This is working without cfparam.
Is this OK?
(<cfqueryparam cfsqltype="cf_sql_integer" value="#val(FORM.TUVmonth)#">)
0
 
erikTsomikSystem Architect, CF programmer Commented:
yes that is perfect
0
 
PanosAuthor Commented:
And something else.
If i want to have default values f.e for checkboxes the value 0,is this wrong to use the cfparam tag?
0
 
erikTsomikSystem Architect, CF programmer Commented:
Use the same approach
<cfif NOT isNumeric(FORM.TUVmonth)>
   <cfprocparam type="in" cfsqltype="cf_sql_integer" value="0">
<cfelse>
   <cfprocparam type="in" cfsqltype="cf_sql_integer" value="#FORM.TUVmonth#">
</cfif>
0
 
PanosAuthor Commented:
Hi
Thank you for your help
regards
panos
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.