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 9203157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:24:35+00:00 2026-06-17T23:24:35+00:00

I am new to ColdFusion, I have written a block of Postgres code in

  • 0

I am new to ColdFusion, I have written a block of Postgres code in CFQuery :

<cffunction name="insertToReport" access="private" returntype="struct" output="false" >

  <cfset var xyz = structNew() >
  <cfset xyz.code = "">
      <cfquery name="querysampleresult" datasource="abc">
            DO            
            $BODY$
                DECLARE resultValue int;
            BEGIN
               resultValue = 1;
               SELECT resultValue INTO resultValue ;    
            END;
            $BODY$
      </cfquery>

            <cfset xyz.code = querysampleresult.resultValue  >

           <cfreturn xyz >
</cffunction>

My problem is that I am unable to access the variable resultValue outside of the CFQuery tag, i.e it is throwing the exception:

Element RESULTVALUE is undefined in querysampleresult

This is occurring at the CFSet statement at the end of function here:

<cfset xyz.code = querysampleresult.resultValue  >

I don’t know how I can set the variable resultValue in the structure and I am bound to return a structure from here to the calling environment.
Please help me in this, Thanks In Advance.

  • 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-17T23:24:36+00:00Added an answer on June 17, 2026 at 11:24 pm

    An anonymous code block (DO) always returns void. You need to use a function to return anything else:

    create function f()
    returns integer as $body$
    declare 
        resultValue integer;
    begin
        resultValue := 1;
        return resultValue;
    end;
    $body$
    language plpgsql
    

    After the function is created you can use it in your query:

    select f() as resultValue;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a coldfusion 8 webservice that returns an array <cffunction access=remote name=testMethod returntype=array>
This question might be naive as I'm new to ColdFusion programming. I have a
I am pretty new to ColdFusion ORM and I have some questions that I
I'm new to coldfusion. I have page called test1.cfm <form action = test2.cfm method
I am using ColdFusion 9.0.1 I have a new site that is accessible through
I have a web-site written in ColdFusion that contains both the usual interactive web
I have an old site built in Coldfusion, a new site built in Rails.
Im new to ColdFusion and I have just read this thread saying that there
I have just started working with a new Coldfusion project, well the project is
I'm a bit new to ColdFusion (coming from Java/OOP world) I have a custom

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.