scripter73
Programmer
Hi,
I'm having trouble displaying an arrray I've created from 2 queries. Basically, I did a query on a table, and used the results to get data from another query on a table. Here's the pseudocode:
<create Array "fullArray">
<Query 1>
<loop through Query 1>
<Query 2> ...where items from Q1 match
<if Q2.recordcount neq 0>
populate fullArray
<end if>
<end of loop>
Output contents of fullArray.
The problem is when I try to output the contents of the array, I receive the following error:
The element at position 1 in dimension 2 ob object "fullArray" cannot be found. That dimension of the object is empty. Please modify the index expression."
But I know at least one record was found to populate the array. And when I do #ArrayLen#, I get a number.
Here's my code. Please note the SQL where clause. The funny thing is if I just scale down the where clause to pull 2 records, the code works just fine.
<cfset fullArray = ArrayNew(2)>
<!--- Populate fullArray --->
<CFLOOP FROM="1" TO="#POLDATA.recordcount#" index="P1">
<cfquery name="GETEND" datasource="#session.dsn#">
select wend_policy_alpha,
wend_policy_number,
wend_renewal_seq_number,
wend_endorsement_no,
wend_end_code_1,
wend_end_code_2,
wend_end_code_3,
wend_end_code_4,
wend_end_code_5,
wend_end_code_6,
wend_end_code_7,
wend_end_code_8,
wend_end_code_9,
wend_end_code_10
from PLWEBEND
where (wend_policy_alpha = '#POLDATA.wpol_policy_alpha[P1]#' and wend_policy_number = #POLDATA.wpol_policy_number[P1]# and wend_renewal_seq_number = #POLDATA.wpol_renewal_seq_number[P1]# and wend_endorsement_no = #POLDATA.wpol_endorsement_no[P1]#)
</cfquery>
<!--- Only populate array if a record was found in 2nd query --->
<cfif #GETEND.recordcount# neq 0>
<cfset fullArray[P1][1] = "#POLDATA.wpol_ins_name[P1]#">
<cfset fullArray[P1][2] = #POLDATA.wpol_endorse_date[P1]#>
<cfset fullArray[P1][3] = #POLDATA.wpol_activity_date[P1]#>
<cfset fullArray[P1][4] = "#POLDATA.wpol_agent_code[P1]#">
<cfset fullArray[P1][5] = "#POLDATA.wpol_policy_alpha[P1]##POLDATA.wpol_policy_number[P1]#">
<cfset fullArray[P1][6] = Trim("#GETEND.wend_end_code_1##GETEND.wend_end_code_2##GETEND.wend_end_code_3##GETEND.wend_end_code_4##GETEND.wend_end_code_5##GETEND.wend_end_code_6##GETEND.wend_end_code_7##GETEND.wend_end_code_8##GETEND.wend_end_code_9##GETEND.wend_end_code_10#">
</cfif>
<cfoutput>#GETEND.recordcount#</cfoutput>.<br>
</CFLOOP>
Number of records in fullArray is <cfoutput>#ArrayLen(fullArray)#</cfoutput>.<br>
Show populated array (fullArray). <br>
<cfloop from="1" to="#ArrayLen(fullArray)#" index="a1">
<cfloop from="1" to="6" index="a2">
<cfoutput>#fullArray[a1][a2]# | </cfoutput>
</cfloop> <!--- array output --->
<hr><br>
</cfloop>
Please help if you can.
Thanks in advance,
scripter73
Change Your Thinking, Change Your Life.
I'm having trouble displaying an arrray I've created from 2 queries. Basically, I did a query on a table, and used the results to get data from another query on a table. Here's the pseudocode:
<create Array "fullArray">
<Query 1>
<loop through Query 1>
<Query 2> ...where items from Q1 match
<if Q2.recordcount neq 0>
populate fullArray
<end if>
<end of loop>
Output contents of fullArray.
The problem is when I try to output the contents of the array, I receive the following error:
The element at position 1 in dimension 2 ob object "fullArray" cannot be found. That dimension of the object is empty. Please modify the index expression."
But I know at least one record was found to populate the array. And when I do #ArrayLen#, I get a number.
Here's my code. Please note the SQL where clause. The funny thing is if I just scale down the where clause to pull 2 records, the code works just fine.
<cfset fullArray = ArrayNew(2)>
<!--- Populate fullArray --->
<CFLOOP FROM="1" TO="#POLDATA.recordcount#" index="P1">
<cfquery name="GETEND" datasource="#session.dsn#">
select wend_policy_alpha,
wend_policy_number,
wend_renewal_seq_number,
wend_endorsement_no,
wend_end_code_1,
wend_end_code_2,
wend_end_code_3,
wend_end_code_4,
wend_end_code_5,
wend_end_code_6,
wend_end_code_7,
wend_end_code_8,
wend_end_code_9,
wend_end_code_10
from PLWEBEND
where (wend_policy_alpha = '#POLDATA.wpol_policy_alpha[P1]#' and wend_policy_number = #POLDATA.wpol_policy_number[P1]# and wend_renewal_seq_number = #POLDATA.wpol_renewal_seq_number[P1]# and wend_endorsement_no = #POLDATA.wpol_endorsement_no[P1]#)
</cfquery>
<!--- Only populate array if a record was found in 2nd query --->
<cfif #GETEND.recordcount# neq 0>
<cfset fullArray[P1][1] = "#POLDATA.wpol_ins_name[P1]#">
<cfset fullArray[P1][2] = #POLDATA.wpol_endorse_date[P1]#>
<cfset fullArray[P1][3] = #POLDATA.wpol_activity_date[P1]#>
<cfset fullArray[P1][4] = "#POLDATA.wpol_agent_code[P1]#">
<cfset fullArray[P1][5] = "#POLDATA.wpol_policy_alpha[P1]##POLDATA.wpol_policy_number[P1]#">
<cfset fullArray[P1][6] = Trim("#GETEND.wend_end_code_1##GETEND.wend_end_code_2##GETEND.wend_end_code_3##GETEND.wend_end_code_4##GETEND.wend_end_code_5##GETEND.wend_end_code_6##GETEND.wend_end_code_7##GETEND.wend_end_code_8##GETEND.wend_end_code_9##GETEND.wend_end_code_10#">
</cfif>
<cfoutput>#GETEND.recordcount#</cfoutput>.<br>
</CFLOOP>
Number of records in fullArray is <cfoutput>#ArrayLen(fullArray)#</cfoutput>.<br>
Show populated array (fullArray). <br>
<cfloop from="1" to="#ArrayLen(fullArray)#" index="a1">
<cfloop from="1" to="6" index="a2">
<cfoutput>#fullArray[a1][a2]# | </cfoutput>
</cfloop> <!--- array output --->
<hr><br>
</cfloop>
Please help if you can.
Thanks in advance,
scripter73
Change Your Thinking, Change Your Life.