Justin, did you ever resolve the problem you raised
below? Did the suggestions help at all? Just
thought I'd double-check in case you might have any useful news to share from
your experience on this problem.
/charlie
http://www.carehart.org/blog/
From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Charlie Arehart Sent: Sunday, August 06, 2006 9:11 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: StructInsert Problem Are you assuming that the query is returning a single
record? If it does not, then because your creation of the array and struct are
outside the loop, you *will* get duplicates simply because you already have a
value from the previous record. If you want to make it so you never process more
than one record, you could of course add MAXROWS to the CFOUTPUT (though that
may not make sense for your app), or you could also use the 4th argument of
StructInsert, a boolean that says you want to allow an overwrite of any
previously existing key of that name (again, which may not really make
sense).
All that said, you may also find that a function at the
cflib.org site may give you all that you need without a lot of effort. Hope it
works out well.
/charlie
http://www.carehart.org/blog/
From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Justin Raymond Sent: Sunday, August 06, 2006 8:45 PM To: cfaussie@googlegroups.com Subject: [cfaussie] StructInsert Problem Hi all, Posted below is a function that queries a
table and returns a single element array with struct keys named as per the data
in the table. Can anyone provide any insight as to why
this may be happening? (CF7, Win2003 server,
IIS) I was fairly certain that my code on line
75 would stop a duplicate being created? I am randomly getting the following error
(approx 1 in 10 - 15 calls or so): Error Occurred
While Processing Request Cannot insert
item with key dsn1. This key
already exists.
The error
occurred in
C:\Inetpub\wwwroot\SPS2\appFramework\packages\types\applicationObj.cfc: line
77 75 :
<cfif StructKeyExists(aAppSettings[1],
setting)> 76 :
<cfelse> 77 :
<cfset temp =
structInsert(aAppSettings[1],setting,setting_value)> 78 :
</cfif> 79 :
</cfloop> Here is the
function:
<cfquery name="getSettings"
datasource="#dsn1#">
SELECT setting, setting_value
FROM application_settings
WHERE app_id = '#app_id#'
ORDER BY setting ASC
</cfquery>
<cfset aAppSettings = arraynew(1)>
<cfset aAppSettings[1] = structnew()>
<cfloop query="getSettings">
<cfif StructKeyExists(aAppSettings[1],
setting)>
<cfelse>
<cfset temp =
structInsert(aAppSettings[1],setting,setting_value)>
</cfif>
</cfloop>
<cfreturn aAppSettings> Thanks in
advance Justin Note:
This correspondence and any files
transmitted with it are confidential. If you are not the intended recipient, you
must not disclose or use the information contained in
it.
If you have received this correspondence in error
please notify Abbotsleigh immediately by phone (612 9473 7900)
or email ([EMAIL PROTECTED]).
Neither the sender or ABBOTSLEIGH
warrants that any communication via the Internet is free of
errors, viruses, interception or interference. Information is distributed
without warranties of any kind.
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie -~----------~----~----~----~------~----~------~--~--- |
- [cfaussie] FW: [cfaussie] Re: StructInsert Problem Charlie Arehart
- [cfaussie] Re: FW: [cfaussie] Re: StructInsert Proble... Justin Raymond