Solved

INSERT INTO COMPONENT

Posted on 2008-10-03
4
225 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
  • 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

810 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