Skip to main content
September 17, 2010
Answered

What does this error mean?

  • September 17, 2010
  • 1 reply
  • 1802 views

Error executing databse query

[Macromedia][SQLServer JDBC Driver]Syntax error at token 0, line 0 offset 0.

Here is my code:

<!--- new array --->
<cfset users = ArrayNew(1)>
<cfset IDsToDelete = "">

<!--- populate array via loop --->
<cfloop from="1" to="#qNumberOfRecords.RecordCount#" index="i">
<cfset sub_id = Trim(qNumberOfRecords.sub_id)>
<cfset group_id = Trim(qNumberOfRecords.group_id)>

                 <!--- Master query to perform all operations --->
                 <cfquery name="qMaster" datasource="#Application.dsn#">
                 <!--- execute queries based on array length --->
                 <cfloop from="1" to="#ArrayLen(users)#" index="j">
                    UPDATE  SUBSCRIPTION
                    SET group_id = '#group_id#'
                    WHERE sub_id = #sub_id#<!---in (SELECT #tableName#.sub_id FROM #tableName#)--->;
                   
                   
                   
                    <!--- delete user from Account_User_Group table --->
                    DELETE FROM ACCOUNT_USER_GROUPS
                    WHERE sub_id = some_value

                   
                   
                   
                            <!--- insert users into ACCOUNT_USER_GROUPS --->
                            <cfloop from="1" to="#ListLen(users.sub_group_id)#" index="k">
                                INSERT INTO ACCOUNT_USER_GROUPS
                                   (sub_id,
                                    group_id,
                                    account_id,
                                    active)
                                VALUES
                                   (<cfqueryparam cfsqltype="cf_sql_integer" value="#users.sub_id#" />,
                                    <cfqueryparam cfsqltype="cf_sql_integer" value="#ListGetAt(users.group_id, k)#" />,
                                    '291',
                                    '1');
                            </cfloop><!--- close k loop --->
                  </cfloop><!--- close j loop --->
                  </cfquery><!--- close qMaster query --->

    This topic has been closed for replies.
    Correct answer existdissolve

    Why do you need the array with what you're doing?

    And the reason that the users array in your code has a length of 0 is because you haven't put any data into it, at least not from what I can see.

    1 reply

    September 17, 2010

    I have figured out the the error means not records are being passed. So there is something wrong with my array.

    Here is my original query to populate my array:

        <cfquery name="qNumberOfRecords" datasource="WENS_IMPORT">
            SELECT * FROM #tableName# where sub_id = 1706531
        </cfquery>

    And here is my array. I want the results of the query to populate my array. for testing purposes, I have set it up so that 1 record is passed, yet when I do the following <cfoutput>#ArrayLen(users)#</cfoutput><cfabort>, it displays 0. something is wrong with my code but i cant figure it out.

    <cfset users = ArrayNew(1)>
    <cfset IDsToDelete = "">

    <cfloop from="1" to="#qNumberOfRecords.RecordCount#" index="i">
    <cfset sub_id = Trim(qNumberOfRecords.sub_id)>
    <cfset group_id = Trim(qNumberOfRecords.group_id)>

    </cfloop>

    Inspiring
    September 17, 2010

    Totally ignoring questions of performance and parameter safety for a moment ... the code looks very complicated. Quite possibly, too complicated. So I cannot help but wonder if there is a simpler way. Can you explain in plain English (not code) what the code is supposed to be doing?

    -Leigh

    September 17, 2010

    You have the right answer, I really over complicated this. There was no need for an array in what I was doing.

    Thank you