Solved

INSERT INTO COMPONENT

Posted on 2008-10-03
4
201 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
Comment Utility
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
Comment Utility
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 24

Accepted Solution

by:
dgrafx earned 500 total points
Comment Utility
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
Comment Utility
Hi dgrafx.
Than you for your help.
regards
panos
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. 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 : Go t…

762 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now