[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

INSERT INTO COMPONENT

Posted on 2008-10-03
4
Medium Priority
?
259 Views
Last Modified: 2013-12-24
Hello experts.
I have o INSERT INTO query like:
<cfparam name="Form.Mobile_ID" default="1">
<cfparam name="Form.Mobile_Sub_ID" default="1">

<cfset art_uuid = createuuid()>
<cfquery name="InsertArtikel" datasource="#dsn#">
INSERT INTO ARTIKEL (uuid,Mobile_ID,Mobile_Sub_ID)
VALUES
(<cfqueryparam cfsqltype="cf_sql_integer" value="#val(art_uuid)#">,
   <cfqueryparam cfsqltype="cf_sql_integer" value="#val(Form.Mobile_ID)#">,
   <cfqueryparam cfsqltype="cf_sql_integer" value="#val(Form.Mobile_Sub_ID)#">
   )
</cfquery>
and i want to replace this with a component and cffunction.
Any help?
0
Comment
Question by:Panos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Expert Comment

by:azadisaryev
ID: 22632713
why?
why do you want to convert it to a cfc function? do you ave more than 3 pages that use this same query in it? do you need to offer it as a web service? is your application using a cf framework that requires use of components instead of in-line queries?
if none of the above reasons apply to your case, do not bother - you will be a lot better off ith an in-line query. trust me.
0
 
LVL 2

Author Comment

by:Panos
ID: 22634174
Hi again azadisaryev.
I use this query in more than 5 pages but the reason i'm asking for is that i have read that the site is working better and faster with components.Is this not correct?
0
 
LVL 25

Accepted Solution

by:
dgrafx earned 2000 total points
ID: 22636013
here ya go

<cfinvoke component="#comPath#.test" method="doInsert">
      <cfinvokeargument name="Mobile_ID" value="#Form.Mobile_ID#"/>
        <cfinvokeargument name="Mobile_Sub_ID" value="#Form.Mobile_Sub_ID#"/>
        <cfinvokeargument name="art_uuid" value="#CreateUUID()#"/>
</cfinvoke>

<!--- function doInsert --->
<cfcomponent>
      <cffunction name="doInsert">
            <cfquery datasource="#Application.DSN#">
                  INSERT INTO ARTIKEL
            (uuid,Mobile_ID,Mobile_Sub_ID)
                  VALUES                  
                  (
                  <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.art_uuid#">,
                     <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.Mobile_ID#">,
                     <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.Mobile_Sub_ID#">
                  )
            </cfquery>                  
      <cfreturn />
      </cffunction>
</cfcomponent>
0
 
LVL 2

Author Closing Comment

by:Panos
ID: 31502678
Hi dgrafx.
Than you for your help.
regards
panos
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question