Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8132901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:27:28+00:00 2026-06-06T09:27:28+00:00

My instructions are to call a function when passing variables into an insert statement

  • 0

My instructions are to call a function when passing variables into an insert statement to prevent code injection. What does the following code do and what actually gets inserted into the database? Why doesn’t this have a value statement and it appears to have a select inside the insert?

<CFQUERY NAME="Survey1" DATASOURCE="#APPLICATION.mainDSN#">
    INSERT INTO TWHSurvey_QA
    (Comment, QuestionID, SurveyID, Rank)
    <cfloop from="1" to="#SESSION.lastPage#" index="curPage">
        <cfloop from="1" to="#ArrayLen(SESSION.HQQuestionStruct.pagesQuestions[curPage])#" index="curQuestion">
            SELECT  
                <cfif SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Type eq 1>
                    <cfif SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Cur_Ans neq "">
                        '#SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Cur_Ans#',
                    <cfelse>
                        NULL,
                    </cfif>
                <cfelse>
                    <cfif SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Comment_Val neq "">
                        '#SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Comment_Val#',
                    <cfelse>
                        NULL,
                    </cfif>
                </cfif>

                #SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].QuestionID#,
                #getLatestSurveyID.SurveyID#,

                <cfif SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Type eq 2>
                    <cfif SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Cur_Ans neq "" AND SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Cur_Ans neq 0>
                        #SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Cur_Ans#
                    <cfelse>
                        NULL
                    </cfif>
                <cfelseif SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Type eq 3>
                    <cfif SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Cur_Ans eq "Yes">
                        1
                    <cfelseif SESSION.HQQuestionStruct.pagesQuestions[curPage][curQuestion].Cur_Ans eq "No">
                        0
                    <cfelse>
                        NULL
                    </cfif>
                <cfelse>
                    NULL
                </cfif>
            <CFIF curPage eq SESSION.lastPage AND curQuestion eq ArrayLen(SESSION.HQQuestionStruct.pagesQuestions[curPage])>
            <CFELSE> 
                UNION ALL
            </CFIF>
        </cfloop>
    </cfloop>
</CFQUERY>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:27:30+00:00Added an answer on June 6, 2026 at 9:27 am

    When using an INSERT there are two ways:

    INSERT INTO yourTable (col1, col2)
    VALUES (val1, val2)
    

    OR

    INSERT INTO yourTable (col1, col2)
    SELECT col1, col2
    FROM table1
    

    Your query is Inserting into your table TWHSurvey_QA, but it is Selecting variables, but you have If statements around some of the values you will be inserting.

    Basically it is selecting the variables:

    INSERT INTO TWHSurvey_QA (Comment, QuestionID, SurveyID, Rank)
    SELECT 
        If statement to decide the comment value
        , QuestionId
        , SurveyID
        , If statement to decide the Rank value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a function that gives users instructions. When I call it I
I have the following pseudo-code in my book for a breadth-first search: function breadth_first_search:
I'd like to know how many instructions are needed for a function call in
I've followed the instructions in this MSDN article: http://msdn.microsoft.com/en-us/library/dd206945.aspx Is it possible to call
I've followed the instructions to integrate spotlight into a non-document based Core Data application
Following Ryan Bates' instructions on creating a before_filter that sets a time_zone like so
I'm following these instructions in order to set up Django on Windows. I have
I use the following types to create a new function at runtime: typedef int
I'm trying to call a native function from a managed assembly. I've done this
I have to call a c function declared in a lib file from c++.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.