Solved

INSERT INTO COMPONENT

Posted on 2008-10-03
4
237 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 500 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

733 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