CFLoop Condition

For a CFLoop, I want to set the condition so that the loop will run if there is any "step" in the text I am itterating over. I wrote:
<cfloop condition = FindNoCase("step",Code)>
</cfloop>
I am getting an error that says:
Just in time compilation error
Invalid token found on line 45 at position 30. ColdFusion was looking at the following text:"
Whats wrong with what I have done?

Reed Powell wrote:
Since the expression is inside of double quote marks, you need to put hash marks around the function
NO YOU DON'T.  <cfloop condition...> is a bit of odd duck.  You don't put a function or expression.  You put a string that represents the function or expression you want evaluated each loop itteration.  It is somewhat like an evaluate() string.
For example, from the docs.
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_j-l_12.html
<cfloop condition = "CountVar LESS THAN OR EQUAL TO 5">
You will note that the condition is in quotes, but there are NO hash|pound|number|othotrope|# characters used.

Similar Messages

  • Unique ID's in ColdFusion 8?

    What tools are available to create UNIQUE ID's for an application?
    I know in ColdFusion we can use CreateUUID() but this generates a string that is very long.
    What I want to be able to do is create a string of say no more than 6 characters long that can be considered unique for a number of records that could reach the millions.
    For example, the website TinyURL seems to do this quite well with a link like the following:
    http://tinyurl.com/dlz23k
    How do you think they ensure it's uniqu everytime??
    Cheers,
    Mikey

    I've done quite a bit of research on URL shortening due to a customer's desire. After review of 8th grade math (permutations and combinations), there are two solutions to URL shortening. These schemes assume that the URL cannot be recycled and put back into circulation.
    Base 36 - a 6 character URL key consisting of letters a-z and 0-9 for a total of 36 characters, and hence base 36. (26 characters (a-z) and 10 digits). This scheme provides  2,238,976,116 unique URL keys ((36^7-36)/35). Notice, this is case-insensitive. For example, http://foo.com/?ItsMagic and http://foo.com/?itsmagic resolve to the same real URL. If over 2 billion URLs is sufficient, this scheme is for you.
    Base 62 - a 6 character URL key consisting of letters a-z, A-Z, and 0-9 for a total of 62 characters (26 +26 + 10 = 62). This scheme provides 57,731,386,986 ((62^7-62)/61) unique URLs. For example, http://foo.com/?ItsMagic and http://foo.com/?itsmagic resolve to DIFFERENT real URLs. If over 5 billion URLs is sufficient, this scheme is for you. (ref: http://www.bennadel.com/blog/1540-Converting-Numbers-To-A-Character-Set-Based-Radix-Using- ColdFusion.htm)
    Scheme 1 code:
            <!--- number of times to try getting a unique suffix before quiting --->
            <cfset var tries = 10>
            <!--- current number of trys --->
            <cfset var trycnt = 1>
            <!--- flag that suffix is unique --->
            <cfset var isunique = false>
            <!--- try to generate a random url suffix --->
            <cfloop condition="(not isunique and trycnt lte tries)">
                <!--- number of epoch seconds --->
                <cfset epochs = DateDiff("s", "January 1 1970 00:00", Now())>
                <!--- the suffix is a base 36 number --->
                <cfset suffix = FormatBaseN((RandRange(1,100000000) + epochs),36)>
                <!--- make sure this URL key is unique among those already created --->
                <cfset isunique = URLDAO.isURLUnique(this,suffix);
                <cfset trycnt = trycnt + 1>
            </cfloop>
    Scheme 2 code:
    See http://www.bennadel.com/blog/1540-Converting-Numbers-To-A-Character-Set-Based-Radix-Using- ColdFusion.htm)

  • Need To Return Calendar Events For Current Day

    Hello,
    I have a calendar which includes seperate start and end date fields. I need to write a query that will return events for each day in a month, but I need to be mindful of the fact that some events span multiple days. Here is my query so far which isn't working quite right.
    <cfquery name="qTodayEvents" datasource="#getDatasource()#">
    SELECT eventID, title, summary, code, description
    FROM events INNER JOIN eventTypes ON events.typeID=eventTypes.typeID
    WHERE deleted=0
    AND
      startDate >= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayStartTime#" />
      AND startDate <= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayEndTime#" />
    ) OR (
      endDate >= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayStartTime#" />
      AND endDate <= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayEndTime#" />
    ) OR (
      startDate <= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayStartTime#" />
      AND endDate >= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayEndTime#" />
    </cfquery>
    The query is located inside a loop which loops through the days in a given month.
    Does anyone know what I am doing wrong? Any assistance would be appreciated.
    Many thanks,
    Simon

    You have to do nested loops - one for the days of the month, and once for the query.  It probably does not matter which is nested inside of what.  You want your query ordered by EndDate.  Then you can do something like this.
    ControlDate = Date1;
    MaxDate = arraymax(yourquery["enddate"]);
    <cfloop condition = ControlDate lt Date2>
    <cfloop from = "1" to = yourquery.recordcount index = 1>
    <cfif ControlDate >= StartDate and ControlDate <= EndDate>
    your code goes here
    <cfelse>
    break
    </cfif>
    <cfloop>
    add a day to ControlDate
    maybe break if the control date is greater than the max date.
    </cfloop>

  • Query WHERE statement to compare db record date pt 2

    I'm sorry, I hit the answered button on my last post. I didn't mean to. I have been working on this code and have gotten closer to the solution. I just need to tweek out the WHERE statement to get rid of the time from the output, and I believe my cfif needs a little work to allow it to be taken into the actually dates. I cfdumped my variables from my query and finally got an output and not an [empty string]. This is my code now, and I will leave in the cfdump and abort tags so you can see where I put them:
    <cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
    SELECT events.eventDate, events.ID AS ID
    FROM events
    WHERE eventDate Between #NextMonthYear# and #NextMonth# AND eventDate >= #dateFormat(Days, 'dd')#
    </cfquery>
    this is my cfif stement
    <cfoutput query="CaleventRec">
    <cfdump var="#eventDate#">
    <cfabort>
    <cfif Days EQ '#eventDate#'>
    <a href = "detail.cfm?id=#ID#">#Days#</a>
    </cfif>
    </cfoutput>
    this is the whole code:
    <cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
    SELECT events.eventDate, events.ID AS ID
    FROM events
    WHERE eventDate Between #NextMonthYear# and #NextMonth# AND eventDate >= #dateFormat(Days, 'dd')#
    </cfquery>
                            <!--- Set the ThisDay variable to 0. This value will remain 0 until the day of the week on which the first day of the month falls on is reached. --->
                            <cfset ThisDay = 0>
                            <!--- Loop through until the number of days in the month is reached. --->
                            <cfloop condition = "ThisDay LTE Days">
                                <tr>
                                <!--- Loop though each day of the week. --->
                                <cfloop from = "1" to = "7" index = "LoopDay">
                                <!--- This turns each day into a hyperlink if it is a current or future date --->
                                  <cfoutput query="CaleventRec">
              <cfdump var="#eventDate#">
                                   <cfabort>
              <cfif Days EQ '#eventDate#'>
                                   <a href = "detail.cfm?id=#ID#">#Days#</a>
                                   </cfif>
              </cfoutput>
                                <!---
                                    If ThisDay is still 0, check to see if the current day of the week in the loop matches the day of the week for the first day of the month.
                                    If the values match, set ThisDay to 1.
                                    Otherwise, the value will remain 0 until the correct day of the week is found.
                                --->
                                    <cfif ThisDay IS 0>
                                        <cfif DayOfWeek(ThisMonthYear) IS LoopDay>
                                            <cfset ThisDay = 1>
                                        </cfif>
                                    </cfif>
                                <!---
                                    If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay
                                    the day of the mnth and increment the value.
                                --->
                                        <cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
                                        <cfoutput>
                                        <!--- I choose to highlight the current day of the year using an IF-ELSE. --->
                                            <cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
                                                <td align = "center" bgcolor="##FFFF99">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                <font class = "calendartoday">#ThisDay#</font>
                                                </td>
                                            <cfelse>
                                                <td align = "center">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                <font class = "calendar">#ThisDay#</font>
                                                </td>
                                            </cfif>
                                        </cfoutput>
                                        <cfset ThisDay = ThisDay + 1>
                                        <cfelse>
                                            <td></td>
                                    </cfif>
                                </cfloop>
                                </tr>
                        </cfloop>
    the output from the cfdump is this: the first event date in the month of june.
    I need this to match the thisday part of the code in the cfloop function through the days of the week.
    Can anyone help me figure this part out?
    thank you, and really sorry about the 2nd post. I just woke up and hit the wrong button. again, really sorry all.
    CFmonger

    This is a small calendar. it will move to the next month at the end of this one, it can also go to the next month with a next / prev button that will let you go as far as you want. It is like all we have seen before. What I need to do it get the eventDate in my DB, that is set as date and put in as mm/dd/yyyy now, basically what I believe the query needs to do it to not only tell what month the calendar is on, but it needs to match any db records with any of the days in that month. Say we are in June: I have 3 records in June, on the 5th, 20th, and 26th. In all the 31 days in the month of June, just those 3 will show a link with an ID to the record that matches in the DB.
    I had it narrowed down with that query, but lose the variable once I try and cfif it. So I knew either my query is wrong, or my cfif is, probably both.
    does that help? can I make this work? am I even close?
    thank you.
    CFmonger
    By the way, here is the entire code with the next / prev nav for cycling through the months.
    <!--- Declaration of the variables --->
           <cfparam name = "month" default = "#DatePart('m', Now())#">
    <cfparam name = "year" default = "#DatePart('yyyy', Now())#">
    <cfparam name = "currentday" default = "#DatePart('d', Now())#">
    <cfparam name = "startmonth" default = "#DatePart('m', Now())#">
    <cfparam name = "startyear" default = "#DatePart('yyyy', Now())#">
    <!--- Set a requested (or current) month/year date and determine the number of days in the month. --->
    <cfset ThisMonthYear = CreateDate(year, month, '1')>
    <cfset Days = DaysInMonth(ThisMonthYear)>
    <!--- Set the values for the previous and next months for the back/next links.--->
    <cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear)>
    <cfset LastMonth = DatePart('m', LastMonthYear)>
    <cfset LastYear = DatePart('yyyy', LastMonthYear)>
    <cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear)>
    <cfset NextMonth = DatePart('m', NextMonthYear)>
    <cfset NextYear = DatePart('yyyy', NextMonthYear)>
    <cfset PreviousDay = DateAdd('d', -1, ThisMonthYear)>
    <cfset CurrentYear = DatePart('yyyy', Now())>
    <table border="0" width="100%" bgcolor ="#ffffff">
                <tr>
                    <td align = "center" valign="top">
                        <table border="0" width="100%" height="100%">
       <tr>
          <th align="center" colspan="7" bgcolor="#2b4e6e">
       <cfoutput>
       <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="15%" align="left" valign="middle">
      <cfif (LastYear lt CurrentYear) OR (LastYear lte CurrentYear AND LastMonth lt startmonth)>
    <cfelse>
      <a href ="index.cfm?month=#LastMonth#&year=#LastYear#" class="calNav">Prev</a></cfif></td>
            <td width="72%" align="center" valign="middle"><FONT SIZE="3" face="Arial, Helvetica, sans-serif" color="##ffffff">#MonthAsString(month)# #year#</FONT></td>
            <td width="13%" align="right" valign="middle">
      <cfif (NextYear lt CurrentYear) OR (NextYear lte CurrentYear AND NextMonth lt startmonth)>
    <cfelse>
    <a href = "index.cfm?month=#NextMonth#&year=#NextYear#" class="calNav">Next</a>  </cfif></td>
          </tr>
        </table></cfoutput></th>
       </tr>
       <tr>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sun</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Mon</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Tue</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Wed</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Thu</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Fri</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sat</FONT></td>
       </tr>
    <cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
    SELECT events.eventDate, events.ID AS ID
    FROM events
    WHERE eventDate Between #NextMonthYear# and #NextMonth# AND eventDate >= #dateFormat(Days, 'dd')#
    </cfquery>
                            <!--- Set the ThisDay variable to 0. This value will remain 0 until the day of the week on which the first day of the month falls on is reached. --->
                            <cfset ThisDay = 0>
                            <!--- Loop through until the number of days in the month is reached. --->
                            <cfloop condition = "ThisDay LTE Days">
                                <tr>
                                <!--- Loop though each day of the week. --->
                                <cfloop from = "1" to = "7" index = "LoopDay">
                                <!--- This turns each day into a hyperlink if it is a current or future date --->
             <cfoutput query="CaleventRec">
              <!---  <cfdump var="#eventDate#">
                                   <cfabort>--->
              <cfif #dateFormat(eventDate, 'dd')# IS ('Days, LoopDay')>
              <cfdump var="#eventDate#">
                                   <cfabort>
                                   <a href = "detail.cfm?id=#ID#">#Days#</a>
                                   </cfif>
              </cfoutput>
                                <!---
                                    If ThisDay is still 0, check to see if the current day of the week in the loop matches the day of the week for the first day of the month.
                                    If the values match, set ThisDay to 1.
                                    Otherwise, the value will remain 0 until the correct day of the week is found.
                                --->
                                    <cfif ThisDay IS 0>
                                        <cfif DayOfWeek(ThisMonthYear) IS LoopDay>
                                            <cfset ThisDay = 1>
                                        </cfif>
                                    </cfif>
                                <!---
                                    If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay
                                    the day of the mnth and increment the value.
                                --->
                                        <cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
                                        <cfoutput>
                                        <!--- I choose to highlight the current day of the year using an IF-ELSE. --->
                                            <cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
                                                <td align = "center" bgcolor="##FFFF99">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                <font class = "calendartoday">#ThisDay#</font>
                                                </td>
                                            <cfelse>
                                                <td align = "center">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                <font class = "calendar">#ThisDay#</font>
                                                </td>
                                            </cfif>
                                        </cfoutput>
                                        <cfset ThisDay = ThisDay + 1>
                                        <cfelse>
                                            <td></td>
                                    </cfif>
                                </cfloop>
                                </tr>
                        </cfloop>
                        </table>
                    </td>
                </tr>
            </table>

  • Trying to get various nodes to show with onclick

    I've successfully managed to deploy SPRY which is marvelous.
    However I've run into a wall.
    I have a set of links which were propagated via a cold fusion
    function.
    <cfloop condition="x lt ArrayLen(r_links)">
    <cfset x=x+1>
    <cfoutput>
    <span onClick="dsSpecials.setCurrentRow(#x-1#);"
    class="kklink">#r_links[x]#</span>   
    </cfoutput>
    </cfloop>
    Within the cfm document I have the following statement
    <div id="Specials_DIV" spry:region="dsSpecials"
    align="center">
    <!--Display the data in a table-->
    <table id="Specials_Table" background="{bg}"
    class="infoAreaMainPage">
    <tr >
    <td>
    <div class="navbar" align="center"><cfinclude
    template="headerAJAX.cfm"></div>
    </td>
    </tr>
    <tr spry:"dsSpecials">
    <td>
    <h3 class="page" spry:detailregion="dsSpecials"
    spry:content="{id}">{id}</h3>
    <div class="infoAreaMainPageInner"
    spry:detailregion="dsSpecials" spry:content="{info}">
    {info}
    </div>
    </td>
    </tr>
    </table>
    Now my question is; Why is there no data change when I click
    on the links? What am I missing?
    I'd appreciate all your help here

    I believe your problem is due to the fact that you are
    nesting a spry:detailregion *inside* a spry:region.
    Spry currently does not support nested regions. If you really
    want the entire table to update whenever you click on one of your
    links, remove the spry:detailregion on the h3 and make the
    Specials_DIV be a spry:detailregion.
    --== Kin ==--

  • Getting PDF annotations in ColdFusion

    Currently, I am using coldfusion 9 and I am trying to get information about annotations from within a PDF file.  The problem is that there are two types of annotations: text and popup.  I am using iText and I can get an annotation array that has 7 objects.
    <cfset reader = CreateObject("java","com.lowagie.text.pdf.PdfReader").init(expandPath("test.pdf"))>
    <cfset pageDict = reader.getPageN(1)>
    <cfset pdfname = createObject("java","com.lowagie.text.pdf.PdfName")>
    <cfset annots = pageDict.getAsArray(pdfname.ANNOTS)>
    So now I see that I have 7 annotations ( I know one is text, and the other 6 are popup). At this point I want to loop through the annotation array and get the informartion
    <cfset iterator = annots.listIterator()>
    <cfloop condition="iterator.hasNext()">
           <cfset annot = reader.getPdfObject(iterator.next())>
           <cfset content = reader.getPdfObject(annot.get(pdfname.CONTENTS))>
           <cfif not isNull(content)>
                   <cfoutput>
                   <p>
                   Text Comment =#content#    <!--- This works for the text comments --->
                   </p>
                   </cfoutput>
           <cfelse>
                   <!--- This happends to be the Popup contents, and where I get lost ---->
           </cfif>
    </cfloop>
    So in the part where I am trying to get the popup contents, I have tried <cfset x  = reader.getPdfObject(annot.getAsDict(pdfname.popup))>  This works, but I can't seem to extract the data.  All I need is to get either the Subject or Name from the popup innotation as they are set to a set number of possibilities in our system.  How do I extract the name or subject info drom the popup object? 

    Thank you!  I had been trying to get the subject off of the annot obj.  I didn't realize that the I had to init Subj.  Once I tried that I was able to do annot.get(subjKey).toString() and get the values I needed!
    Thank you again!

  • Accessing a tab of a specific web page using cfhttp

    Hello, CFers!
    I need to access a remote page using the cfhttp. To be more specific, I need to access this page: https://sistemas.dnpm.gov.br/SCM/Extra/site/admin/dadosProcesso.aspx?numero=861738&ano=2013 (Sorry, Brazilian government sites works better only in the I.E.)
    This is a site of the Brazillian government that supervises mining areas all over the country. Each mining area has its own "numero" (number) and the "ano" (year) when it was registered at the National Department of Mineral Production - DNPM agency. As you can see (if you clicked the link to the DNPM website) there's a tab "Poligonal" at the top of it. Clicking on it will start a function created probably by the ASP.NET and it will generate a PNG image showing the area and some other processes near it. Example of the link above:
    So here is the problem: Can I get the data from the "poligonal" tab using the CFHTTP, knowing the poligonal page doesn't have a direct link? I tried all I could to find a way to get this image, checked I the sourcecode, but I couldn't find any way to solve my problem. That's why I came here to see if somebody can help me with this.
    Sorry for my bad English. I hope you guys undertand me.
    Being sure of your pacience and attention, since now I thank you.

    Aegis Kleais, I have tried contacting the developer, but I got no answer from him so far.
    I tried something and now I can access the content that the tab shows me (with a little help of a library of Ben Nadal):
    <!--- 
    Função escrita pelo Ben Nadel
    Detalhe de funcionamento em http://www.bennadel.com/blog/779-Parsing-HTML-Tag-Data-Into-A-ColdFusion-Structure.htm
    --->
    <cffunction name="ParseHTMLTag" access="public" returntype="struct" output="false" hint="Parses the given HTML tag into a ColdFusion struct.">
    <cfargument name="HTML" type="string" required="true" hint="The raw HTML for the tag."/>
        <cfset var LOCAL = StructNew() />
    <cfset LOCAL.Tag = StructNew() />
    <cfset LOCAL.Tag.HTML = ARGUMENTS.HTML />
    <cfset LOCAL.Tag.Name = "" />
    <cfset LOCAL.Tag.Attributes = StructNew() />
    <cfset LOCAL.NamePattern = CreateObject("java","java.util.regex.Pattern").Compile("^<(\w+)")/>
    <cfset LOCAL.NameMatcher = LOCAL.NamePattern.Matcher(ARGUMENTS.HTML) />
        <cfif LOCAL.NameMatcher.Find()>
    <cfset LOCAL.Tag.Name = UCase(LOCAL.NameMatcher.Group( 1 )) />
    </cfif>
    <cfset LOCAL.AttributePattern = CreateObject("java","java.util.regex.Pattern").Compile("\s+(\w+)(?:\s*=\s*(""[^""]*""|[^\ s>]*))?")/>
    <cfset LOCAL.AttributeMatcher = LOCAL.AttributePattern.Matcher(ARGUMENTS.HTML) />
    <cfloop condition="LOCAL.AttributeMatcher.Find()">
    <cfset LOCAL.Name = LOCAL.AttributeMatcher.Group( 1 ) />
    <cfset LOCAL.Tag.Attributes[ LOCAL.Name ] = "" />
    <cfset LOCAL.Value = LOCAL.AttributeMatcher.Group( 2 ) />
    <cfif StructKeyExists( LOCAL, "Value" )>
    <cfset LOCAL.Value = LOCAL.Value.ReplaceAll("^""|""$","") />
    <cfset LOCAL.Tag.Attributes[ LOCAL.Name ] = LOCAL.Value />
    </cfif>
    </cfloop>
        <cfreturn LOCAL.Tag />
    </cffunction>
    <cfset urlDestino = "https://sistemas.dnpm.gov.br/SCM/Extra/site/admin/dadosProcesso.aspx?numero=861738&ano=201 3"/>
    <!--- Primeira chamada, com o objetivo de obter os cabeçalhos e os campos ocultos para dar continuidade à navegação aqui você poderá dinamizar o resultado de acordo com o que você precisar --->
    <cfhttp url="#urlDestino#" method="get" charset="utf-8" result="gResult" timeout="900"/>
    <!---//OBTER O CABEÇALHO DA PÁGINA //--->
    <!---capturo o cabeçalho da página  e delimito em uma lista apenas os que quero passar para as páginas seguintes --->
    <cfset requestHeaders = getHttpRequestData().headers/>
    <cfset rhList              = 'accept,accept-encoding,accept-language,cookie,cache-control,connection,pragma,user-agent '/>
    <!---//OBTER OS CAMPOS OCULTOS DA PÁGINA //--->
    <!--- expressão regular para localizar todos os inputs do html da página
       que pode ser aprimorada para localizar apenas os hiddens --->
    <cfset hiddenFields = reMatchNoCase("(?i)<input [^>]*[^>]*?>",gResult.fileContent)/>
    <!--- A partir da função do Ben, eu extraio o nome e os valores dos inputs
       que serão postados para a página seguinte, excluindo os valores que desviam do resultado esperado --->
    <cfset formFields     = []/>
    <cfloop index="input" from="1" to="#arrayLen(hiddenFields)#">
    <cfset inputResult = ParseHTMLTag(hiddenFields[input])/>
        <cfif  NOT findNoCase('btnConsultarProcesso',inputResult.ATTRIBUTES.name)
        AND NOT findNoCase('btnDadosBasicos',inputResult.ATTRIBUTES.name)>
    <cfset formFields[input]["name"]  = inputResult.ATTRIBUTES.name/>
            <cfset formFields[input]["value"] = inputResult.ATTRIBUTES.value/>
    </cfif>
    </cfloop>   
    <!---//NAVEGAR PARA PÁGINA POLIGONAL //--->
    <cfhttp url="#urlDestino#" method="post" charset="utf-8" result="fResult" timeout="900">
         <!--- injeta os form fields --->  
        <cfloop array="#formFields#" index="key">
            <cfhttpparam type="formfield" name="#key.name#" value="#key.value#"/>
        </cfloop>
        <!--- injeta o cabeçalho--->
        <cfloop collection="#requestHeaders#" index="key">
             <cfif listFind(rhList,key)>
             <cfhttpparam type="header" name="#key#" value="#requestHeaders[key]#"/>
            </cfif>
        </cfloop>
    </cfhttp>        
    <!---//VISUALIZA A PÁGINA POLIGONAL //--->
    <cfoutput>#fResult.fileContent#</cfoutput>
    That's it.
    And thanks for helping me!

  • Output of an Array

    Hi everybody,
    I was just playing with the CFLIB metaheaders and everything works fine for a beginner (http://cflib.org/udf/GetMetaHeaders). Now I see all the results in the cfdump, but I want these results in a cfoutput. How can I work it out, that I can have an output of this array, because I want to save these results in a database?
    Any help is appreciated

    If it's a 1D array, it's a simple loop from 1 to the arraylen.
    For 2D arrays, I'd try something like this, and this will only work if there are no blank cells in the array.
    <cfset Columns = 1>
    <cfset FoundNumCols = false>
    <cfloop condition = "FoundNumCols is false">
    <cftry>
    <cfset x = TheArray[1][Columns]>
    <cfset Columns = Columns + 1>
    <cfcatch>
    <cfset FoundNumCols = true>
    closing tags.
    Same thing for rows.
    <cfoutput>
    <cfloop from = 1 to = Rows index = "row">
    <cfloop from = 1 to = Columns index = "column">
    #TheArray[row][column]
    closing tags

  • CFC method memory problem

    Hi all,
    I use CFCs a lot, so when I was creating a tool to migrate
    some database tables, I built the actual data transfer function as
    a method of a CFC. The basic code just reads a block of 1000
    records from the old db, does some minor manipulation of the data,
    and then inserts the records into the new db a record at a time
    inside a cfloop. Lather, rinse, repeat, until all of the 500K+
    records have been transferred.
    I was surprised to find that this leads to Java out of memory
    errors around the 200Kth record (given my current JVM memory
    settings). Having run across a similar problem when sending
    broadcast emails from a CFC method, I simply moved the code out of
    the CFC method and into the calling cfm page, and it ran through
    all of the records without any problems.
    The only explanation I can think of for this behavior is that
    when the code is inside a CFC method, the query object used to read
    the blocks of 1000 records keeps getting reallocated rather than
    reused, so when it gets to the point of trying to store 200 blocks
    of 1000 records in memory, it runs out of room. If that's the case,
    it would seem to be a significant bug that needs to be fixed.
    Does anyone know if that's what is really going on?
    Thanks,
    Russ

    > Actually, there is a good reason to put the code in a
    cfc: there are almost 100
    > tables to migrate, so the code gets rather long and
    cumbersome to wade through
    > if it isn't broken up.
    Fair enough. Youd didn't really tell us that part before,
    though.
    So you have a calling template which calls an equivalent to
    this function
    for 100-odd tables? Yikes. I'll reiterate my question whether
    this can't
    possibly be done DB to DB or via a bulk insert.
    > thing, but ultimately my question really has nothing to
    do with this particular
    > tool. I would really just like to understand why the out
    of memory issue exists
    > when the code is in a CFC method versus when it is in a
    CFM. This issue has
    Well it kinda is about this particular tool, because it's
    this code that's
    causing the problems (or something about the calling code, or
    something
    like that). Obviously there's some idiosyncasy of it which
    gives you
    problems when it's in a CFC method as opposed to mainline
    code, but I would
    not immediately say it's a generic problem with CFCs vs CFMs.
    Just yet.
    Is this the first table that's being migrated? Or is it
    buried somewhere
    within the other 100-odd? Is it always this one, or can it
    happen on any
    of them?
    Can you inspect the memory usage between each table's
    function, and see if
    there's anything unexpected going on (other than it running
    out of memory,
    which is - in itself - unexpected!).
    Do you have 100-odd methods (one for each table) in the CFC,
    or lots of
    individual CFCs?
    I guess you could call a GC in between each table's
    processing, and see if
    you can keep check on memory usage that way. Or maybe check
    memory levels
    within that loop you've got, and if it starts flaring up, doa
    GC then.
    It's not advised to call GCs "by hand", but I have found it's
    helped some
    times.
    Have you sued CF's server monitor or something like
    FusionReactor to check
    if anything unexpected is consuming RAM?
    I think you should try adding <cfqueryparam> tags to
    your queries: CF might
    be cachinng some info about them, and that could be leaking
    memory or
    something. Maybe try <cfobjectcache action = "clear">
    between each method
    callor something.
    I wonder if there's something about the fact you're replacing
    oldInfo with
    a new query within a loop that has a condition based on
    oldInfo's record
    count. Possibly this is forcing CF to maintain the previous
    oldInfo
    queries in the background, so you're not actually overwriting
    the previous
    one with the next one when you requery, you're actually just
    getting a new
    pointer assigned. Do me a favour, and do this:
    <cfset iRecCount = OldInfo.RecordCount>
    <cfloop condition="iRecCount GT 0">
    <!--- Load the old info --->
    <cfquery name="OldInfo" datasource="dsOld"
    maxrows="#GetRecsCount#">
    </cfquery>
    <cfset iRecCount = OldInfo.RecordCount>
    </cfloop>
    This is a slightly far-fetched notion, but it doesn't hurt to
    try: it's a
    pretty easy change.
    > come up enough times now that I'd like to determine if
    there is a workaround.
    > Due to the deadline I'm on, I haven't tried simply
    assigning the query object
    > to an empty string at the end of each iteration yet, but
    I will try to do so
    > soon so I can report on the result.
    It might pay to apply a test rig to this notion first:
    0) on a dev machine without any other activity
    1) grab the heap usage
    2) load a big query in
    3) grab the heap usage (should losely reflect the fact you've
    just stuck a
    chunk of data in RAM)
    4) set the query variable to be an empty string
    5) grab the heap usage. Check to see if the memory is
    reclaimed straight
    away.
    You might need to do a GC between 4+5 for it to take effect.
    I speculate
    that the RAM won't get freed up straight away, and you might
    be consuing it
    faster than the JVM can clear it.
    Adam

  • Dynamic to Static URL

    Dynamic to Static URL's
    what is the best program to use to do this? Because I dont'
    want to make hundreds of static pages, is there a easy way to show
    this properly and get better indexing at the same time. I have
    heard of wordpress, but don't know if it is automated and I think I
    need htaccess file.
    ie:
    FROM:
    www.mysite.com/products.php?store=27
    TO:
    www.mysite.com/products/nike.htm
    thanks

    I did this for a client by simply modifying the 404 error
    page. You do not have to install any special renaming software onto
    your server whatsoever.
    First create a custom 404 error page outputting the
    cgi.query_string of the error page. In that you will see the
    incorrectly called url, which in your case will include the unique
    username.
    Ex:
    404;https://www.yourdomain.com:443/username/
    Extract the username using a combination of your list
    functions...
    Ex:
    <cfset username = listdeleteat(listgetat(CGI.QUERY_STRING,
    3, ":"), 1, "/") />
    Remove the trailing slash if needed...
    Ex:
    <cfset username = listgetat(username, 1, "/") />
    Then cfquery the username. If found, cfinclude the relevant
    index page (if you want the url to stay the same), or cflocation to
    the actually page assigning the username as a url variable. If the
    username is not found, just goto home page.
    Remember to disallow any special characters or top level
    directory names in your usernames.
    <cfloop condition='findoneof("\/:*?""<>|",
    form.urlname)'>
    <cfset form.urlname = removechars(form.urlname,
    findoneof("\/:*?""<>|", form.urlname), 1) />
    </cfloop>
    <cfdirectory action="list" name="alldirs"
    directory="#expandpath('/')#" />
    <cfquery dbtype="query" name="dirs">
    SELECT name
    FROM alldirs
    WHERE type = "Dir"
    AND name = #lcase(form.urlname)#
    </cfquery>

  • Re: Using ScopeCache custom tag

    Hi, I am quite new to ColdFusion and I have a calendar that
    is quite slow due to the cfloops it uses to build the calendar. As
    the page does not change very often I wanted to use Raymond
    Camden's ScopeCache custom tag. However, for some reason the custom
    tag was not getting picked up from the custom tag folder on the
    server. I have successfully used components so have tried to
    convert the custom tag to a component but get the following error
    message:
    Routines cannot be declared more than once.
    The routine scope_Cache has been declared twice in the same
    file.
    This is the component:
    <!---
    Name : scopeCache
    Author : Raymond Camden ([email protected])
    Created : December 12, 2002
    Last Updated : November 6, 2003
    History : Allow for clearAll (rkc 11/6/03)
    : Added dependancies, timeout, other misc changes (rkc
    1/8/04)
    Purpose : Allows you to cache content in various scopes.
    Documentation:
    This tag allows you to cache content and data in various RAM
    based scopes.
    The tag takes the following attributes:
    name/cachename: The name of the data. (required)
    scope: The scope where cached data will reside. Must be
    either session,
    application, or server. (required)
    timeout: When the cache will timeout. By default, the year
    3999 (i.e., never).
    Value must be either a date/time stamp or a number
    representing the
    number of seconds until the timeout is reached. (optional)
    dependancies: This allows you to mark other cache items as
    dependant on this item.
    When this item is cleared or timesout, any child will also
    be cleared.
    Also, any children of those children will also be cleared.
    (optional)
    clear: If passed and if true, will clear out the cached
    item. Note that
    this option will NOT recreate the cache. In other words, the
    rest of
    the tag isn't run (well, mostly, but don't worry).
    clearAll: Removes all data from this scope. Exits the tag
    immidiately.
    disabled: Allows for a quick exit out of the tag. How would
    this be used? You can
    imagine using disabled="#request.disabled#" to allow for a
    quick way to
    turn on/off caching for the entire site. Of course, all
    calls to the tag
    would have to use the same value.
    License : Use this as you will. If you enjoy it and it helps
    your application,
    consider sending me something from my Amazon wish list:
    http://www.amazon.com/o/registry/2TCL1D08EZEYE
    --->
    <cfcomponent>
    <cffunction name="scope_Cache" access="public"
    returntype="string">
    <cfargument name="cachename" type="string"
    required="yes">
    <cfargument name="scope" type="string" required="yes">
    <cfargument name="timeout" type="string"
    required="yes">
    <cfprocessingdirective pageencoding="utf-8">
    <!--- allow for quick exit
    <cfif isDefined("arguments.disabled") and
    arguments.disabled>
    <cfexit method="exitTemplate">
    </cfif>
    <!--- Allow for cachename in case we use cfmodule --->
    <cfif isDefined("arguments.cachename")>
    <cfset arguments.name = arguments.cachename>
    </cfif>--->
    <!--- Attribute validation --->
    <cfif (not isDefined("arguments.name") or not
    isSimpleValue(arguments.name)) and not
    isDefined("arguments.clearall")>
    <cfthrow message="scopeCache: The name attribute must be
    passed as a string.">
    </cfif>
    <cfif not isDefined("arguments.scope") or not
    isSimpleValue(arguments.scope) or not
    listFindNoCase("application,session,server",arguments.scope)>
    <cfthrow message="scopeCache: The scope attribute must be
    passed as one of: application, session, or server.">
    </cfif>
    <!--- The default timeout is no timeout, so we use the
    year 3999. --->
    <cfparam name="arguments.timeout"
    default="#createDate(3999,1,1)#">
    <!--- Default dependancy list --->
    <cfparam name="arguments.dependancies" default=""
    type="string">
    <cfif not isDate(arguments.timeout) and (not
    isNumeric(arguments.timeout) or arguments.timeout lte 0)>
    <cfthrow message="scopeCache: The timeout attribute must
    be either a date/time or a number greather zero.">
    <cfelseif isNumeric(arguments.timeout)>
    <!--- convert seconds to a time --->
    <cfset arguments.timeout =
    dateAdd("s",arguments.timeout,now())>
    </cfif>
    <!--- create pointer to scope --->
    <cfset ptr = structGet(arguments.scope)>
    <!--- init cache root --->
    <cfif not structKeyExists(ptr,"scopeCache")>
    <cfset ptr["scopeCache"] = structNew()>
    </cfif>
    <cfif isDefined("arguments.clearAll")>
    <cfset structClear(ptr["scopeCache"])>
    <cfexit method="exitTag">
    </cfif>
    <!--- This variable will store all the guys we need to
    update --->
    <cfset cleanup = "">
    <!--- This variable determines if we run the caching.
    This is used when we clear a cache --->
    <cfset dontRun = false>
    <cfif isDefined("arguments.clear") and arguments.clear
    and structKeyExists(ptr.scopeCache,arguments.name) and
    thisTag.executionMode is "start">
    <cfif
    structKeyExists(ptr.scopeCache[arguments.name],"dependancies")>
    <cfset cleanup =
    ptr.scopeCache[arguments.name].dependancies>
    </cfif>
    <cfset structDelete(ptr.scopeCache,arguments.name)>
    <cfset dontRun = true>
    </cfif>
    <cfif not dontRun>
    <cfif thisTag.executionMode is "start">
    <!--- determine if we have the info in cache already
    --->
    <cfif structKeyExists(ptr.scopeCache,arguments.name)>
    <cfif
    dateCompare(now(),ptr.scopeCache[arguments.name].timeout) is -1>
    <cfif not isDefined("arguments.r_Data")>
    <cfoutput>#ptr.scopeCache[arguments.name].value#</cfoutput>
    <cfelse>
    <cfset caller[arguments.r_Data] =
    ptr.scopeCache[arguments.name].value>
    </cfif>
    <cfexit>
    </cfif>
    </cfif>
    <cfelse>
    <!--- It is possible I'm here because I'm refreshing. If
    so, check my dependancies --->
    <cfif structKeyExists(ptr.scopeCache,arguments.name) and
    structKeyExists(ptr.scopeCache[arguments.name],"dependancies")>
    <cfif
    structKeyExists(ptr.scopeCache[arguments.name],"dependancies")>
    <cfset cleanup = listAppend(cleanup,
    ptr.scopeCache[arguments.name].dependancies)>
    </cfif>
    </cfif>
    <cfset ptr.scopeCache[arguments.name] = structNew()>
    <cfif not isDefined("arguments.data")>
    <cfset ptr.scopeCache[arguments.name].value =
    thistag.generatedcontent>
    <cfelse>
    <cfset ptr.scopeCache[arguments.name].value =
    arguments.data>
    </cfif>
    <cfset ptr.scopeCache[arguments.name].timeout =
    arguments.timeout>
    <cfset ptr.scopeCache[arguments.name].dependancies =
    arguments.dependancies>
    <cfif isDefined("arguments.r_Data")>
    <cfset caller[arguments.r_Data] =
    ptr.scopeCache[arguments.name].value>
    </cfif>
    </cfif>
    </cfif>
    <!--- Do I need to clean up? --->
    <cfset z = 1>
    <cfloop condition="listLen(cleanup)">
    <cfset z = z+1><cfif z gt 100><cfthrow
    message="ack"></cfif>
    <cfset toKill = listFirst(cleanup)>
    <cfset cleanUp = listRest(cleanup)>
    <cfif structKeyExists(ptr.scopeCache, toKill)>
    <cfloop index="item"
    list="#ptr.scopeCache[toKill].dependancies#">
    <cfif not listFindNoCase(cleanup, item)>
    <cfset cleanup = listAppend(cleanup, item)>
    </cfif>
    </cfloop>
    <cfset structDelete(ptr.scopeCache,toKill)>
    </cfif>
    </cfloop>
    <cfreturn scope_Cache>
    </cffunction>
    </cfcomponent>

    Hi, thanks to both of you for your help. I reverted back the
    custom tag and it was picked up this time - I don't know what
    happened before. The functionality works as expected but I have hit
    another problem and I am hoping I can tap your combined ColdFusion
    wisdom to solve!!
    The calendar returns leave records for staff and filters the
    records using a querystring variable appended when the user clicks
    on a particular month. However, what members of staff the user sees
    depends on the data held in the users' session variables based on
    their authority. The reason I wanted to use caching is because the
    page takes a good ten seconds to run because of the use of cfloops
    for the members of staff and the days of the week to dynamically
    build the page. Using the custom tag would have worked if all
    members of staff saw the same calendar data and could only see one
    month. Can you see anyway I can speed up the page and do you think
    caching is the way forward here?

  • Merging two lists?

    I need to know if it is possible to merge two lists using coldfusion.  I have one list uploaded to the site then they want the ability to upload a second list with may have additional fields and/or different number of records.  Need to know if this is possible, how to do it if it is, and how the two list will match up.  Thanks in advance for the help.

    Right, well in that case this isn't really anything to do with merging lists per se, hence the confusion I believe. Technically, you'd do this:
    <cfset newData = fileOpen("c:\newlist.csv","read") />
    <!--- Loop through your file, one line at a time --->
    <cfloop condition="NOT fileIsEof(newData)">
      <!--- Create a string of the line, this is a true list --->
      <cfset thisLine = fileReadLine(newData) />
      <!--- Get the elements of the list we want for the query --->
      <cfset thisForename = listGetAt(thisLine,1) />
      <cfset thisSurname = listGetAt(thisLine,2) />
      <!--- Check if this person exists --->
      <cfquery datasource/username/password name="qCheckExists">
        SELECT    id
        FROM      mytable
        WHERE     firstname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#thisForename#" />
        AND       surname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#thisSurname"#" />
      </cfquery>
      <!--- If we found rows, update --->
      <cfif qCheckExists.RECORDCOUNT eq 1 >
        <cfquery datasource/username/password>
            UPDATE   mytable
            SET      forename = <listGetAt,thisLine, FIELD>,
                     surname = <listGetAt,thisLine, FIELD>,
                     address = <listGetAt,thisLine, FIELD>,
                         etc etc etc
            WHERE    id = qCheckExists.id
        </cfquery>
      <cfelseif qCheckExists.RECORDCOUNT >
        <!--- here you found more than one matching row, up to you what to do --->
      <cfelse>
        <!--- here you didn't find a match, so do an insert --->
      </cfif>
    </cfloop>
    <cfset fileClose(newData) />
    That's how you'd do it on a technical level, the Business decisions are yours. What if it's John not Jon? What if it's Jonathan? That's not a programming problem, that's up to you to decide - I'm not sure we can help you there.
    O.

  • Redirecting to www

    Hi,
    We have a code snippet that does a permanent redirect from domain.com to www.domain.com.  We place this code in onSessionStart and onRequestStart functions in Application.cfc  (let's just assume that there is a reason why we place it in both functions).
    So the code has been working until last week when we moved from CF8 to CF9 (with Windows Server 2008).  Suddenly, instead of redirecting from http://domain.com/index.cfm to http://www.domain.com/index.cfm, the code redirects to http://www.domain.com/index.cfm,http://www.domain.com/index.cfm (yes, repeated with a comma).
    After many testings, we finally figured out that this problem only occurs because we put the code in both onSessionStart and onRequestStart.  Somehow, both redirections get triggered though I don't quite understand how.  My understanding is that if a user types in domain.com in the beginning, onSessionStart will redirect him/her to www.domain.com.  The redirection code in onRequestStart should only get triggered if a user types in domain.com in the middle of his/her session.
    Any idea why?  It worked fine in CF8 but not in CF9.
    Thank you in advance!
    <cffunction name="onSessionStart" returnType="void" output="true">
        <cfif cgi.server_name neq 'www.domain.com'>
            <cfheader statuscode="301" statustext="Moved permanently">
            <cfset strNewURL = "http://www.domain.com" & cgi.path_info>
            <cfheader name="Location" value="#strNewURL#">
        </cfif>    
    </cffunction>
    <cffunction name="onRequestStart" returnType="boolean" output="true"> 
        <cfargument name="thePage" type="string" required="true">
        <cfif cgi.SERVER_NAME neq 'www.domain.com'>
            <cfheader statuscode="301" statustext="Moved permanently">
            <cfset strNewURL = "http://www.domain.com" & cgi.path_info>
            <cfheader name="Location" value="#strNewURL#">
        </cfif>    
        <!--- This is to expire session so we can run the code again immediately (from rickosborne.org)--->
        <cfset ServerName=LCase(CGI.SERVER_NAME)>
        <cfset structClear(Session)>
        <cfloop condition="listLen(ServerName,'.') gte 2">
            <cfloop list="CFID,CFTOKEN,CFMAGIC,SESSIONID,JSESSIONID" index="CookieName">
                <cfcookie expires="NOW" name="#CookieName#" domain=".#ServerName#">
                <cfcookie expires="NOW" name="#CookieName#" domain="#ServerName#">
                <cfcookie expires="NOW" name="#CookieName#">
            </cfloop>
            <cfset ServerName=listRest(ServerName,".")>
        </cfloop>
        <cfreturn true>
    </cffunction>

    1.  The reason we put it at the beginning of onSessionStart is because onSessionStart has a number of instantiations (components and session variables).  So I thought if I just put the code only in onRequestStart, we would be 'wasting' those instantiations (ie. someone goes to domain.com, goes thorough all of onSessionStart function only to be thrown to www.domain.com with its own onSessionStart).
    All the more reason to get this sorted out before CF gets involved, I'd say.  It takes about 30sec to sort this out on IIS.
      But I am curious to know why the code is not working as I expected.  Is it the way onSessionStart work or the way cfheader work?
    I had a closer look at your code, and a bell started ringing.  I have some vague recollection that I found that when one uses <cfheader> to add the same header value multiple times, CF compiles it into one name/value pair, as a comma-delimited list.  I did raise this on some forum somewhere, but I cannot find it with Google.  You can probably test this by checking what's in the headers with an HTTP sniffer.
    I suspect what's happening is that for a given request, all of onApplicationStart(), onSessionStart() and onRequestStart() (if applicable) will be processed, so you're actually adding the header twice, because both onSessionStart() and onRequestStart() are running.  You might be able to mitigate this by:
    a) using <cflocation> instead of two <cfheader> lines.  I mean... why aren't you use using <cflocation> anyhow?
    b) sticking a <cfabort> after the <cfheader> tags, in both cases.
    But, really... use the web server to do a job that is actually intended for the web server to be doing.  This is a square peg / round hole situation you're trying to get working here.
    Adam

  • Report - Style Problem

    Hello Guys,
    First of all, am in the process of learning cold-fusion coding.
    I have a doubt in reporting part of coldfusion code.
    I need to make a report style such as below
    A
    B
    C
    Pass
    x
    B
    x
    Fail
    A
    x
    C
    Pass
    A
    x
    x
    Pass
    Presently am able to get display data table like below:
    A
    B
    C
    Pass
    B
    Fail
    A
    C
    Pass
    A
    Pass
    here A,B,C are feed group;
    My coding specific to looping is below:
    <cfoutput query="PromotionInfo" group= RID> <tr>
    <cfoutput group="feed_group">
                   <cfif IsSimpleValue(Feed_Group) >
                              <td  nowrap><a href="#PromotionInfo.Report#" target="_blank">#PromotionInfo.feed_group#</a></td>
                        <cfelse>
                              <td><strong>N/A</strong></td>
                    </cfif>    
      </cfoutput>
    I tried for looping, still no sucess so far..
    Note: Problem here in looping is When I tried cfif/Cfloop condition's for every column-wise data,
    cfoutput for  PromotionInfo.feed_group gives ABC (joined values) not separately ie. for each cycle of loop the data queried are shown in one single row. Am not able to split it since they are not having any delimiters.
    Am not sure I gave the right picture of my problem, still expecting someone can help me..
    Thanks
    Keeran

    hi,
    i've tried to correct your code:
    -> v_year, v_low and v_high was not filled
    ...SELECTION-SCREEN : END OF BLOCK b_fa.
    PARAMETERS p_year LIKE anlc-gjahr DEFAULT sy-datum(4).
    *PARAMETERS : budat LIKE anek-budat.
    SET PF-STATUS '100'.
    v_year = p_year.
    v_year = v_year - 1.
    CONCATENATE v_year '0401' INTO v_low.
    CLEAR v_year.
    v_year = p_year.
    CONCATENATE v_year '0331' INTO v_high.
    SELECT bukrs anln1 anln2 aktiv txt50 zugdt menge meins anlkl
    FROM anla
    pls reward useful answers
    thx.
    Andreas

  • Trouble with MSSQL query

    Hello All,
    I have an unusual situation where I am trying to query the
    database (MSSQL) using an IN statement and the PK list has
    approximately 10,000 records in it. SQL throws an error "The query
    processor ran out of stack space during query optimization" which
    relates to a limitation in MSSQL Server: (
    http://support.microsoft.com/kb/288095)
    Microsoft's suggestion is to create a temporary table and
    then JOIN the two tables to get the results you are looking for.
    However, in my particular situation, I don't know how to create a
    temporary table from just list data.
    Here is an example of the coldFusion template:
    Step 1: Get a list of IDs that this user is allowed to see
    Query a bunch of records and sub records and generate a list
    variable (#RecordsToGet#)
    Note, this query loops several times because of parent/child
    relationships in the table. After each loop, the list is appended
    to.
    Example:
    <cfset currentparent = 0>
    <CFLOOP condition="ContinueLoop IS 'yes'">
    <cfset LoopCount = LoopCount + 1>
    <cfquery datasource="#datasource#" name="getMyStuff">
    Select ID, Parent
    FROM myTable
    WHERE Parent = #currentparent#
    AND Criteria = '#bla#'
    </cfquery>
    <!-- assign the new parent to a value list and append the
    master list -->
    <cfset CurrentParent = ValueList(getMyStuff.ID)>
    <cfset RecordsToGet =
    ListAppend(RecordsToGet,CurrentParent)>
    <cfset loopcount = loopcount + 1>
    (continue loop until there are no more records (i.e. you
    have reached the bottom of the tree)
    </cfloop>
    Step 2: Get the record details for the matching records in
    the (#RecordsToGet#) list.
    <cfquery datasource=#datasource# name="getTheRecords">
    SELECT ID, Name, Description, Image, Etc...
    FROM MyTable
    WHERE ID IN (#RecordsToGet#) <-- the problem lies here
    AND Name = '#MoreFilterCriteria1#'
    AND IMAGE = '#MoreFilterCriteria2#'
    </cfquery>
    I have been able to fix the problem (temporarally) by
    checking if #RecordsToGet# is has more than 1000 list elements, and
    if so, get ALL of the records in the table and then use a QofQ to
    filter out the records.
    So the 2nd query above would become:
    <cfquery datasource=#datasource# name="getTheRecords">
    SELECT ID, Name, Description, Image, Etc...
    FROM MyTable
    WHERE ID <cfif ListLen(RecordsToGet) GT 1000>IN
    (#RecordsToGet#) <cfelse>1=1</cfif>
    AND Name = '#MoreFilterCriteria1#'
    AND IMAGE = '#MoreFilterCriteria2#'
    </cfquery>
    <cfif ListLen(RecordsToGet) GT 1000>
    <cfquery dbtype="query" name="getTheRecords">
    SELECT * FROM getTheRecords
    WHERE ID IN (#RecordsToGet#)
    </cfquery>
    </cfif>
    Although this has temporarally fixed the problem, the
    performance of these queries is VERY slow.
    Does anyone have any suggestions or tips?
    Thanks so much.

    I think I'll need to read a bit more about advancd SQL
    statements like the one you posted above in order to understand it
    better. I'm still not sure how that query gets all of the values
    and assigns it to a temporary table. On a side note, Do you know if
    MS Access databases can accept WHILE EXISTS statements as well?
    If I wanted to use your method on the initial cfquery how
    would I write it out?
    The table structure looks something like this:
    ID, Name, Parent
    (where Parent is 0 if it is the top level, or the number
    value of the ID if it is a child of that ID)
    currently my query looks like:
    <CFLOOP condition="ContinueLoop IS 'yes'">
    <cfset LoopCount = LoopCount + 1>
    <cfquery datasource="#datasource#" name="getMyStuff">
    Select ID, Parent
    FROM myTable
    WHERE Parent = #currentparent#
    AND Criteria = '#bla#'
    </cfquery>
    <!-- assign the new parent to a value list and append the
    master list -->
    <cfset CurrentParent = ValueList(getMyStuff.ID)>
    <cfset RecordsToGet =
    ListAppend(RecordsToGet,CurrentParent)>
    <cfset loopcount = loopcount + 1>
    (continue loop until there are no more records (i.e. you have
    reached the bottom of the tree)
    </cfloop>

Maybe you are looking for

  • Function in where clause

    Hi All, Can anyone know how to use the user defined function in the where clause of the SQL statement. Thanks in Advance, Madhu N.

  • Smb.conf?

    Hi, After a completely flawless upgrade to Leopard on my Mac Pro, a so-so upgrade leading to a wipe and clean install on my Powerbook, I am now trying to get my mac mini updated to Leopard. The mini acts as a mini home server for music and acts as an

  • How do i put a "draft" watermark across the page?

    how do i put a "draft" watermark across the page?

  • Sudden authorization / deauthorization issues

    I await the lavish apology due to me and countless others for the fact that something - almost certainly the recent "Security Update" - has caused iTunes to have some kind of hemorrhage. It says my computer is not authorized to play all the music I h

  • Convert Javascript to Applescript

    Hi, I need to convert javascript to Apple script. Please help!!! try { app.activeDocument.layers.getByName( '.ARD' ).remove(); } catch (e) {}; MOhan