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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:48:26+00:00 2026-05-23T02:48:26+00:00

I am working on migrating a bunch of data from an old database into

  • 0

I am working on migrating a bunch of data from an old database into a new one. In the process of migrating a created a UDF for my script that would give me a bunch of data that I need. When I run a loop that calls the UDF multiple times I find that the first iteration runs fine, but then the UDF disappears from the following iterations.

My code is:

<cffunction name="getCats" access="public">
    <cfargument name="assignments" type="any" />

    <cfquery name="getCats" datasource="pgdold">
        SELECT c1.id AS id1, c1.category AS name1, c2.id AS id2, c2.category AS name2, c3.id AS id3, c3.category AS name3, c4.id AS id4, c4.category AS name4, c5.id AS id5, c5.category AS name5
        FROM category c1
        LEFT JOIN category AS c2 ON c2.parentid = c1.id
        LEFT JOIN category AS c3 ON c3.parentid = c2.id
        LEFT JOIN category AS c4 ON c4.parentid = c3.id
        LEFT JOIN category AS c5 ON c5.parentid = c4.id
    </cfquery>

    <cfquery name="get" dbtype="query">
        SELECT (name1 + '/' + name2 + '/' + name3 + '/' + name4 + '/' + name5) AS category
        FROM getCats
        WHERE
            <cfloop query="Arguments.assignments">
                (id1 = #Arguments.assignments.categoryid# OR id2 = #Arguments.assignments.categoryid# OR id3 = #Arguments.assignments.categoryid# OR id4 = #Arguments.assignments.categoryid# OR id5 = #Arguments.assignments.categoryid#)
                <cfif Arguments.assignments.currentrow IS NOT Arguments.assignments.recordCount> OR </cfif>
            </cfloop>
    </cfquery>
    <cfreturn get />
</cffunction>

<cfscript>
    olddb = {datasource='pgdold'};

    a = new Query(argumentCollection=olddb);
    a.setSQL('SELECT * FROM products LIMIT 10');
    p = a.execute();
    pr = p.getResult();
</cfscript>

<cfscript>
    products = arrayNew();
    for(i=1;i<=pr.recordCount;i++){
        product = {};
        if(!reFind('([0-9]+\-)(G|g)(I|i)(F|f)(T|t)',pr['sku'][i])){
            b = new Query(argumentCollection=olddb);
            b.setSql('SELECT * FROM productpics WHERE sku = :sku ORDER BY picorder');
            b.addParam(name='sku',value=pr['sku'][i]);
            pics = b.execute().getResult();
            picList = '';
            for(j=1;j<=pics.recordCount;j++){
                picList = picList & ';' & pics['imagename'][j];
            }

            d = new Query(argumentCollection=olddb);
            d.setSql('SELECT * FROM skucategories WHERE sku = :sku');
            d.addParam(name='sku', value=pr['sku'][i]);
            assignments = d.execute().getResult();

            categories = getCats(assignments);
            writeDump(categories);
            product = {
                store = 'admin',
                websites = 'base',
                attribute_set = 'Default',
                categories = '',
                type = 'simple',
                sku = pr['sku'][i],
                name = reReplace(reReplace(pr['title'][i],'\"','&##34;','all'),'\,','&##44;','all'),
                price = pr['price'][i],
                description = reReplace(reReplace(pr['detail'][i],'\"','&##34;','all'),'\,','&##44;','all'),
                short_description = '',
                image = pics['imagename'][1],
                small_image = pics['imagename'][1],
                thumbnail = pics['imagename'][1],
                weight = pr['weight'][i],
                has_options = 1,
                is_in_stock = 1,
                qty = 1000,
                disabled = 'No',
                status = 'Enabled',
                options_container = 'Black after info Column',
                tax_class_id = 'Taxable Goods',
                visibility = 'Catalog,Search',
                gallery =  right(picList,len(picList)-1) // Seperate images by semicolon (;)
            };
            arrayAppend(products,product);
        }
    }
</cfscript>

It is the getCats function that disappears.

* yes the code is ugly and inefficient. It wasn’t meant to do anything more than this one job and after it finishes the job it is going to be thrown away, so don’t tell me about the ugliness or inefficiencies.

  • 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-05-23T02:48:27+00:00Added an answer on May 23, 2026 at 2:48 am

    Without reading every line of your code posted, I have a Strong feeling that it has to do with Var scooping… since you are calling that UDF in a Loop.

    Please var scope you query variables.

    Pre CF9:

    <!--- insert after <cfargument> --->
    <cfset var getCats = "">
    <cfset var get = "">
    

    At, or Post CF9 with Local scope:

    <cfquery name="local.getCats" datasource="pgdold">
    <cfquery name="local.get" dbtype="query">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was working on migrating data from MYSQL to HSQL. In MYSQL data file,
I am new to using SSIS 2008 and am currently working on migrating data
Working with a SqlCommand in C# I've created a query that contains a IN
Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB.
I'm working on an application that intersperses a bunch of jython and java code.
hey again stackoverflowers I'm migrating a website from old ASP (in VBScript) and there's
Background: I'm working on migrating from SQL Server 2000 to SQL Server 2005. This
I am working on migrating Weblogic custom Authentication provider from version 8.1.5 to 9.2.3
I'm currently working on migrating an application from MS-Access to MS SQL Server. In
I have a script that appends some rows to a table. One of the

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.