?
Solved

INSERT INTO COMPONENT

Posted on 2008-10-03
4
Medium Priority
?
253 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php :…
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…
Suggested Courses

801 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