Cfelseif with cfscript

Hi all,
I want to add to this code with an elseif
Will it work to put in before the else in the udf.cfm code
below the following? TIA:
elseif (referer contains 'yahoo.com')
StartPos=ReFindNoCase('q=.',referer);
if (StartPos GT 0) {
EndString=mid(referer,StartPos+2,Len(referer));
Keywords=ReReplaceNoCase(EndString,'&.*','','ALL');
Keywords=URLDecode(Keywords);
return Keywords;
udf.cfm
<cfscript>function getGoogleKeywords(referer) {
var Keywords='';
var StartPos=0;
var EndString='';
if (referer contains 'google.com') {
StartPos=ReFindNoCase('q=.',referer);
if (StartPos GT 0) {
EndString=mid(referer,StartPos+2,Len(referer));
Keywords=ReReplaceNoCase(EndString,'&.*','','ALL');
Keywords=URLDecode(Keywords);
return Keywords;
else {
return '';
}</cfscript>

quote:
Originally posted by:
cf_dev2
> Will it work to put in before the else
Did you try it? An if / elseif / else works the same as a
cfif/cfelseif/cfelse.
Really?
I always use two words, "else if"
Guess there's always more than one way that works.

Similar Messages

  • CFLAYOUT TAB - CFLAYOUTAREA with CFSCRIPT

    The first and last TABS have the appropriate TEXT displaying.
    The three tabs in between show the TAB but the TEXT is gone. Very
    strange. Has anyone tried this and found a work around. We have not
    been able to find any technical reference regarding use of CFSCRIPT
    inside the CFLAYOUTAREA tag.

    SOLVED -
    IE for some reason must find a STYLE definition -
    style="width:100%"
    Adding it renders all the TABS with TEXT as you would expect.
    For some reason Mozilla and Opera are more forgiving and do
    not require the style definition.

  • Making secure cookies with cfscript

    With the ability to make components in CF9, I thought we would get the ability to make cookies via cfscript.  Am I missing something or is this still not available?

    Haha.  I do have a tendency to over complicate things. This is only half the story though, the importance of setting the "secure" flag is not for the server, but for the client browser.
    You can set a cookie in SSL and have it not be secure.  It doesn't "secure" the cookie by default.  As soon as the page is rendered unencrypted the client will share that cookie information with the server.  A secure cookie will not be shared by the client unless the connection is secure (and domain/path is matched). 
    Hence, simply setting a cookie under SSL does not suffice as a secure scenario.   Read more here : http://resources.enablesecurity.com/resources/Surf%20Jacking.pdf Particularly page 3. PCI security compliance companies will say during an audit that all cookies must be marked as "secure" in addition to the use of SSL.
    What is frustrating about Coldfusion is that by default the JSESSIONID does not mark as "secure" even when using SSL.  So either you manually do this upon request (which can be problematic as it is publishing the unsecure cookie first) or modify the jrun-web.xml in WEB-INF with the following:
    <session-config>
          <cookie-config>
        <cookie-secure>true</cookie-secure>
      </cookie-config>
    </session-config>
    Returning to my original rant, I'm hoping Adobe (great job on CF9 btw!!) will eventually have all of the tags available via cfscript. 

  • Please help with cfscript error!

    When I run my app, I got this error:
    sdfst_catcherror is recording this error: Context validation
    error for tag cfscript.; The start tag must have a matching end
    tag. An explicit end tag can be provided by adding
    </cfscript>. If the body of the tag is empty you can use the
    shortcut <cfscript .../>.
    The CFML compiler was processing:
    a cfscript tag beginning on line 45, column 4.
    a cfscript tag beginning on line 45, column 4.
    When I checked my codes, all the
    <cfscript></cfscript> have the pairs. There are only 2
    pairs of <cfscript</cfscript> in this template.
    See my code structure below:
    <!--- the first <cfscript pair> --->
    <cfscript>
    function getTRS(var5)
    some codes here...
    return TRS;
    </cfscript>
    <cffunction name="FrmTxt" returntype="Struct">
    <cfargument name="EmpCodes" required="true"
    type="array">
    <cfargument name="EmpID" required="true"
    type="numeric">
    <cfquery name="GetEmpInfo>
    Select * from......
    </cfquery>
    <cfset varFrms = GetEmpInfo.EmpCodes>
    <cfset A_Key = 1>
    <cfset structFrmTxt = StructNew()>
    <!--- The second pair --->
    <cfscript>
    Some codes here....
    Need to output #TRS# returned by getTRS(var5) set above
    </cfscript>
    <cfreturn structFrmTxt>
    </cffunction>
    From other CF forum I learned that I can't put getTRS(var5)
    within the second <cfscript></cfscript> within
    <CFFUNCTION> pair
    it says "You can't put UDF within UDF or method within
    method". When I did originally, I got this error:
    Unable to complete CFML to Java translation, Error
    information unsupported statement: class
    coldfusion.compiler.ASTfunctionDefinition
    I'm stuck and can't find any resources to solve this problem
    anymore, please help!....

    When I checked my codes, all the
    <cfscript></cfscript> have the pairs.
    This error can often mean that you did not properly end a
    previous code
    block or line. So the closing </cfscript> is being
    considered part of
    that unclosed code. For me, it is often a missing semi-colon
    [;] on the
    last line I wrote, missing a closing curly bracket [}] could
    do it as well.
    Check your code, this is seldom more then missing a bit of
    syntax.

  • Well to run a cfquery I must include a "password" attribute, etc except I have a local server ? yes / no

    I read ALL the textbook
    MACROMEDIA CF, 2002 course.com
    Well to run a <cfquery> I must include a "password" attribute, etc
    except I have a local server ? yes / no
    May use/include a file dbinfo.cfm with all my passwords etc , and use
    these passwords as variables in <cfquery>,...etc ? this is more secure ?
    I must include vars in <cfscript> tag OR many <cfset> tags ?
    If I had
    <cfscript>
    password='gf56SDRPO999';
    </cfscript>
    HOW TO INCLUDE THIS VAR IN  <cfquery password=#password# ...> this is correct ?

    Your question is unclear to me, but if you just want to verify your syntax is legal, then YES.  You can easily set a value in a variable with <cfscript> and then later use that variable in a <cftag...> like you showed.
    But I would argue there is little additional security in using passwords in code like this between setting the password and using it directly in the tag.  There may be reusability and maintainability advantages, but little advantage to security.

  • Parsing CF tags - how to remove whitespace?

    I have an index.cfm in which I include additional CFM pages.
    index.cfm:
    </head>
    <cfinclude template="first.cfm">
    <cfinclude template="second.cfm">
    <cfinclude template="third.cfm">
    <cfinclude template="forth.cfm">
    <body>
    After executing the file:
    </head>
    <body>
    How can I remove these whitespace? For example first.cfm
    contains the following rows:
    <cfif isDefined("cookie.myCookie")>
    <cfif cookie.ZulzBeta neq "1234">
    <cflocation url="
    http://mypage">
    </cfif>
    </cfif>
    <cfif not isDefined("cookie.myCookie")>
    <cflocation url="
    http://mypage">
    </cfif>
    I know that using <cfscript> this problem won't happen
    but there are a lot of things that I'm not able to do with
    <cfscript>. What should I do?

    <cfprocessingdirective suppressWhiteSpace = "Yes">
    <cfinclude template="first.cfm">
    <cfinclude template="second.cfm">
    <cfinclude template="third.cfm">
    <cfinclude template="forth.cfm">
    <cfprocessingdirective suppressWhiteSpace = "No">
    <!--- Code for the rest of the page --->
    </cfprocessingdirective>
    </cfprocessingdirective>

  • Where is the API for PKI authentication library in ColdFusion 9?

    Hello,
    I have to get PKI/certificates working with our ColdFusion application.  We're using CF9, and evidently there were calls added
    to this to help you get the cert, the distinguished name, etc.  So, what I am looking for specifically is where can I read
    the API for this?   I need to know the functions, tags, etc that I will be calling in order to get the info I need from the cert.
    Thanks!

    I was able to find something to try from the forum, although not explained well.  I had to use cfdump to see
    the different methods to use:
    <!---We need to get all of the required fields from the 509 cert and store those in session--->
    <cfset x509 = GetPageContext().getRequest().getAttribute("javax.servlet.request.X509Certificate")>
    <!---Debug prints--->
    <cfdump var=#x509[1].getSubjectDN().getCommonName()#>
    <cfdump var=#x509[1].getIssuerDN().getCommonName()#>
    <cfdump var=#x509[1].getIssuerDN().getOrganization()#>
    <cfdump var=#x509[1].getIssuerDN().getOrganizationalUnit()#>
    I saw some other solutions with cfscript, but that's overkill.  I also find it incredibly STUPID that
    the CGI variables for CERT_SUBJECT, etc, are only available if you use IIS.  Umm, who even
    USES IIS anyway?  People use Apache/Jrun more than anything.  I wasted a lot of time going through
    the CGI and asking questions on other forums about it.
    However, the above method is easy, and works.

  • Need help with cfif, cfelseif

    I am trying to display a slideshow within an include file depending upon what category selection someone makes within a CF page.
    I have tried the following using both URL= and template= with no luck. Any help would be appreciated.
    <cfif TxtProductMenuSelected eq "NewProducts">
    <cfinclude URL="IncludeFiles/ContractHome-include.cfm">
    <cfelseif TxtProductMenuSelected eq "Chandeliers">
    <cfinclude URL="IncludeFiles/ProdHome-include.cfm">
    <cfelseif TxtProductMenuSelected eq "LargeFixtures">
    <cfinclude URL="IncludeFiles/test-include.cfm">
    <cfelse>
    I don't have a clue! Seriously.
    </cfif>

    btvbillb wrote:
    I have posted all the code below. Basically, it's a page that displays thumbnail images and a Flash slideshow depending upon which category is selected. I have commented out the Flash sildeshow and created include files for the code to a javascript slideshow instead. I was using TxtProductMenuSelected as the criteria for displaying the appropriate include file. Hope this all makes sense.
    http://www.cylonweb.com/test/test.cfm
    Your code is behaving as expected. The last line to update the value of the variable TxtProductMenuSelected before the if-else block is:
    <cfset TxtProductMenuSelected = "">
    That is why the comparisons with "NewProducts", etc. return false.

  • Performance issue: looping over queries with a query results set

    I have code that works, but I think I should be able to run the code faster. I could try a stored procedure but there are so many variables to set. I tried with wrapping cftransation around the code, but it didn't make a noticeable difference. I need to go through the data singularly to fill my query object.
    Here's an ABBREVIATED sample of the code:
    <cfset tot_AllActiveListing = QueryNew(
    "AnnounceNum, JP_PDLoc, JP_JS_Title, JP_JS_KWID, JP_JS, JP_Open, JP_Close, JP_CloseType, JP_CloseName, JP_PosNeed, JP_DirectHire, JP_Desc, JP_Draft, JP_Archived, JP_State, JP_AreaID, JP_AreaName, JP_AreaAlias, JP_Fac_SU, JP_Fac_Facility, JP_FAC_ID, JP_Grade1, JP_Grade2, JP_Grade3, JP_Grade4, JP_Grade5, JP_Posted, JP_TypeHire, JP_HRemail",
    "VARCHAR,VARCHAR,VARCHAR,INTEGER,INTEGER,TIMESTAMP,TIMESTAMP,INTEGER,VARCHAR,INTEGER,BIT,V ARCHAR,BIT,BIT,VARCHAR,INTEGER,VARCHAR,VARCHAR,VARCHAR,VARCHAR,INTEGER,VARCHAR,VARCHAR,VAR CHAR,VARCHAR,VARCHAR,TIMESTAMP,INTEGER,VARCHAR")
    />
    <cfquery name="getAllActiveListing" datasource="#request.at_datasource#">
        SELECT j.JOB_AnnounceNum, j.JOB_PDLoc, j.fk_JS_code, j.Job_JPOpen, j.Job_JPClose, j.fk_CloseType, j.JOB_JPPosNeed, j.JOB_DirectHire, j.JOB_JPDesc, j.Job_JPDraft, j.JOB_JPArchived, j.JOB_State,
        j.fk_FACID, j.Posted, j.JOB_IHSvITU, f.Fac_Area, f.Fac_ServiceUnit, f.fac_Facility, f.Fac_Addr1, f.Fac_Addr2, f.Fac_City, f.Fac_State, f.Fac_Zip
        from JOB_JP j INNER JOIN #generaldb#IHSFacility f
        ON j.fk_FACID  = f.Fac_ID
        WHERE
                JOB_JPDraft = 0
                and (Job_JPClose = #Now()# or Job_JPClose > #Now()# or fk_CloseType = 2 or fk_CloseType = 3)
                and (JOB_JPArchived = 0 or JOB_JPArchived IS NULL)
                 <cfif IsDefined("qAltPostID") and qAltPostID.recordcount gt "0">
                and JOB_AnnounceNum IN (<cfqueryparam list="yes" cfsqltype="CF_SQL_varchar" value="#ValueList(qAltPostID.fk_Job_AnnounceNum)#">)
                <cfelseif option is "JPPostListing" and StructKeyExists(session,"IHSUID")>
                and  j.WhoCreated = #session.IHSUID#
                 </cfif>
                 Order by j.Job_JPOpen desc
        </cfquery>
        <cfloop from="1" to="#session.getAllActiveListing.recordcount#" index="i">       
                <cfquery name="getAllActiveListingGrade" datasource="#request.at_datasource#">
                    SELECT fk_Job_AnnounceNum, Grade
                    from Job_JP_Grade
                    Where Job_JP_Grade.fk_Job_AnnounceNum = '#session.getAllActiveListing.Job_AnnounceNum[i]#'
                </cfquery>    
                <cfif IsDefined("session.getAllActiveListing") and session.getAllActiveListing.recordcount neq "0">       
                    <cfquery name="getAllActiveListingIHSArea" datasource="#at_datasource#">
                    SELECT JOBIHSArea_ID, JOBIHSArea_Name, JOBIHSArea_Alias
                    from JOB_IHSArea_LKUP
                    where JOBIHSArea_Alias = '#session.getAllActiveListing.Fac_Area[i]#'
                    </cfquery>
                </cfif>       
                <cfset session.getAllActiveListingGrade = getAllActiveListingGrade />
                <cfquery name="getAllActiveListingCloseName" datasource="#at_datasource#">
                SELECT JOB_CloseName
                from JOB_CloseType_LKUP
                where JOB_CloseType_LKUP.JOB_CloseType = #session.getAllActiveListing.fk_CloseType[i]#
                </cfquery>
                    <cfscript>                                       
                       newRow=QueryAddRow(tot_AllActiveListing);
                        QuerySetCell(tot_AllActiveListing, "AnnounceNum", "#session.getAllActiveListing.Job_AnnounceNum[i]#");
                        QuerySetCell(tot_AllActiveListing, "JP_PDLoc", "#session.getAllActiveListing.JOB_PDLoc[i]#");
                        QuerySetCell(tot_AllActiveListing, "JP_Draft", "#session.getAllActiveListing.Job_JPDraft[i]#");
                        QuerySetCell(tot_AllActiveListing, "JP_Archived", "#session.getAllActiveListing.Job_JParchived[i]#");
                        QuerySetCell(tot_AllActiveListing, "JP_Posted", "#session.getAllActiveListing.Posted[i]#");
                        QuerySetCell(tot_AllActiveListing, "JP_PosNeed", "#session.getAllActiveListing.JOB_JPPosNeed[i]#");
                        QuerySetCell(tot_AllActiveListing, "JP_DirectHire", "#session.getAllActiveListing.JOB_DirectHire[i]#");
                     </cfscript>       
            </cfloop>
    Any ideas will be greatly appreciated. If stored procedures are the best way to handle this and will run appreciably faster, I'll try it.
    Thanks.
    JoyRose

    Thanks for your reply.
    So now here is the entire code written with LEFT JOIN:
    <cfquery name="getAllActiveListing" datasource="#request.at_datasource#">
        SELECT j.JOB_AnnounceNum, j.JOB_PDLoc, j.fk_JS_code, j.Job_JPOpen, j.Job_JPClose, j.fk_CloseType, j.JOB_JPPosNeed, j.JOB_DirectHire, j.JOB_JPDesc, j.Job_JPDraft, j.JOB_JPArchived, j.JOB_State,
        j.fk_FACID, j.Posted, j.JOB_IHSvITU, f.Fac_Area, f.Fac_ServiceUnit, f.fac_Facility, f.Fac_Addr1, f.Fac_Addr2, f.Fac_City, f.Fac_State, f.Fac_Zip, g.Grade, a.JOBIHSArea_ID, a.JOBIHSArea_Name, a.JOBIHSArea_Alias, c.JOB_CloseName, s.Title, p.HRContact, p.HRContactType, e.Email, k.fk_KWID, k.fk_AnnounceNum, w.JOB_KWName, w.JOB_KWID
        from JOB_JP j INNER JOIN #generaldb#IHSFacility f
        ON j.fk_FACID  = f.Fac_ID
        LEFT OUTER JOIN JOB_JP_Grade g
        ON j.JOB_AnnounceNum = g.fk_Job_AnnounceNum
        LEFT OUTER JOIN JOB_IHSArea_LKUP a
        ON j.Fac_Area = a.JOBIHSArea_Alias
        LEFT OUTER JOIN JOB_CloseType_LKUP c
        ON j.fk_CloseType = c.JOB_CloseType
        LEFT OUTER JOIN JOB_Series_LKUP s
        ON j.fk_js_code = s.fk_js_code
        LEFT OUTER JOIN JOB_JPContacts p
        ON j.JOB_AnnounceNum = p.fk_Job_AnnounceNum
        LEFT OUTER JOIN #globalds#Email e
        ON p.HRContact = e.table_ID
        LEFT OUTER JOIN JOB_JPKW k
        ON j.JOB_AnnounceNum = k.fk_AnnounceNum
        LEFT OUTER JOIN JOB_KW_LKUP w
        ON k.fk_KWID = w.JOB_KWID 
        WHERE
                JOB_JPDraft = 0
                and (Job_JPClose = #Now()# or Job_JPClose > #Now()# or fk_CloseType = 2 or fk_CloseType = 3)
                and (JOB_JPArchived = 0 or JOB_JPArchived IS NULL)
                 <cfif IsDefined("qAltPostID") and qAltPostID.recordcount gt "0">
                and JOB_AnnounceNum IN (<cfqueryparam list="yes" cfsqltype="CF_SQL_varchar" value="#ValueList(qAltPostID.fk_Job_AnnounceNum)#">)
                <cfelseif option is "JPPostListing" and StructKeyExists(session,"IHSUID")>
                and  j.WhoCreated = #session.IHSUID#
                 </cfif>
                 Order by j.Job_JPOpen desc
        </cfquery>
    I'm concerned about the queries below that I converted to the LEFT JOIN code above..
    <cfquery name="getAllActiveListingHRContact" datasource="#at_datasource#">
                SELECT HRContact, HRContactType
                from JOB_JPContacts
                where fk_Job_AnnounceNum = '#session.getAllActiveListing.JOB_AnnounceNum[i]#'
                </cfquery>
                <cfif CompareNoCase(getAllActiveListingHRContact.HRContactType,"HRContactID") is 0>       
                    <cfquery name="getAllActiveListingHREmail" datasource="#globalds#">
                    SELECT Email
                    from Email
                    where Table_ID = #getAllActiveListingHRContact.HRContact#
                    </cfquery>
                    <cfset session.getAllActiveListingHREmail = getAllActiveListingHREmail />
                </cfif>
                <cfquery name="getAllActiveListingMasterKey" datasource="#at_datasource#">
                SELECT fk_KWID, fk_AnnounceNum, JOB_KWName, JOB_KWID
                from JOB_JPKW, JOB_KW_LKUP
                where JOB_JPKW.fk_AnnounceNum = '#session.getAllActiveListing.JOB_AnnounceNum[i]#'
                and JOB_KW_LKUP.JOB_KWID = JOB_JPKW.fk_KWID
                </cfquery>
    I appreciate your help with this.

  • Help with multiple variable

    I'm trying to write a query which pulls shipment information
    from an access database. Then it grabs the weight of each shipments
    and multiplies it by the corresponding rate depending on its weight
    class.
    I'm using the CFIF, CFELSEIF and CFSET tags to try to
    accopmlisht this, making it look something like this
    <CFIF "Shipments.weight" LT 500 >
    <cfset Shipments.rate = 7.5 >
    <CFELSEIF "Shipments.weight" GT 499 LT 1000 >
    <cfset Shipments.rate = 7 >
    <CFELSEIF "Shipments.weight" GT 999 LT 2000 >
    <cfset Shipments.rate = 6.5 >
    <CFELSEIF "Shipments.weight" GT 1999 LT 5000 >
    <cfset Shipments.rate = 5 >
    <CFELSEIF "Shipments.weight" GT 4999 >
    <cfset Shipments.rate = 3.65 >
    </CFIF>
    then in the Output tag I use this CFSCRIPT
    <cfscript>
    WriteOutput(#ACC_Report.weight#/100*#Shipments.rate#);
    </cfscript>
    It runs fine but it only seems to grab either the first or
    the second set rate variables and multiplies all the weights in the
    output query by it, inetead of logically choosing its weight class.
    Any help, perhaps I'm using the wrong logic.
    Thanks in advance

    "There's no such thing as "greater-than-ness" on string data"
    Adam, everything you said is basically true and relevant to
    the original
    poster's issue. But this line is wrong is it not? Isn't
    comparing one
    string to another and determining which is greater or lesser
    the essence
    of sorting a set of strings into an alphabetical order?
    Now, I am not sure I can remember the last time I had to
    write my own
    sort routine. But I am pretty sure when I did for sorting
    string data,
    I communally compared one to another to see which was greater
    and|or
    lesser then the other.
    To reiterate in the original post, the person is comparing
    the string
    constants "Shipments.weight" to the numbers do to the
    improper quotes,
    not the value in the Shipments.weight variable.
    Also, if one cares, the logic could be greatly simplified
    with some
    basic boolean logic. The lower range comparisons are
    unnecessary.
    <CFIF Shipments.weight LT 500 >
    <!--- weight is less then 500 --->
    <cfset Shipments.rate = 7.5 >
    <CFELSEIF Shipments.weight LT 1000 >
    <!--- weight is greater then equal to 500 it was not
    caught in first
    branch, but it is also less then 1000 --->
    <cfset Shipments.rate = 7 >
    <CFELSEIF Shipments.weight LT 2000 >
    <!--- weight is greater then equal to 1000 it was not
    caught in any
    previous branch, but it is also less then 2000--->
    <cfset Shipments.rate = 6.5 >
    <CFELSEIF Shipments.weight LT 5000 >
    <!--- weight is greater then equal to 2000 it was not
    caught in any
    previous branch, but it is also less then 5000--->
    <cfset Shipments.rate = 5 >
    <CFELSE>
    <!--- weight is greater then equal to 5000 it was not
    caught in any
    previous branch--->
    <cfset Shipments.rate = 3.65 >
    </CFIF>

  • Problem using DECODE() function with a Query of Queries

    I
    posted
    on my blog about an issue I was having trying to use the PL/SQL
    DECODE() function with a Coldfusion Query of Queries. This function
    works fine when you query a database for information. However, when
    you query another query, it seems that CF doesn't recognize it. I
    got errors stating that it found a left parenthesis where it
    expected a FROM key word. Here is a simplified version of what I am
    trying to do:
    quote:
    <!--- Simulated query; similar to what I was calling from
    my database --->
    <cfscript>
    qOriginal = queryNew("Name,Email,CountryCode",
    "VarChar,VarChar,VarChar");
    newRow = queryAddRow(qOriginal, 5);
    querySetCell(qOriginal, "Name", "Joe", 1);
    querySetCell(qOriginal, "Email", "[email protected]", 1);
    querySetCell(qOriginal, "CountryCode", "AMER", 1);
    querySetCell(qOriginal, "Name", "Sally", 2);
    querySetCell(qOriginal, "Email", "[email protected]", 2);
    querySetCell(qOriginal, "CountryCode", "AMER", 2);
    querySetCell(qOriginal, "Name", "Bob", 3);
    querySetCell(qOriginal, "Email", "[email protected]", 3);
    querySetCell(qOriginal, "CountryCode", "ASIA", 3);
    querySetCell(qOriginal, "Name", "Mary", 4);
    querySetCell(qOriginal, "Email", "[email protected]", 4);
    querySetCell(qOriginal, "CountryCode", "EURO", 4);
    querySetCell(qOriginal, "Name", "John", 5);
    querySetCell(qOriginal, "Email", "[email protected]", 5);
    querySetCell(qOriginal, "CountryCode", "EURO", 5);
    </cfscript>
    <cfquery name="qCountries" dbtype="query">
    SELECT DISTINCT(CountryCode) AS CountryCode,
    DECODE(states, "AMER", "North America &amp; Canada",
    "EURO", "Europe &amp; Africa", "ASIA", "Japan &amp;
    Asia","") CountryName
    FROM qOriginal
    ORDER BY CountryCode
    </cfquery>
    <cfdump var="#qCountries#">
    <!--- ========== END OF CODE ========== --->
    So running this returned the following error:
    Query Of Queries syntax error.
    Encountered "(. Incorrect Select Statement, Expecting a
    'FROM', but encountered '(' instead, A select statement should have
    a 'FROM' construct.
    Does anybody know why this doesn't work? Is it just not
    supported? Please note that I have also tried to use the CASE()
    function instead of DECODE() and that resulted in basically the
    same error. For now I an looping over my distinct query with a
    switch statement and manually loading a new query with the data how
    I want it. But it would be a lot cleaner and less code to have the
    DECODE() to work. Thx!

    DECODE() is an Oracle function, not generic SQL. Q-of-Q is a
    very limited subset of SQL and lacks many functions and clauses
    available in standard SQL, especially what you may be used to using
    in your particular RDBMS.
    See
    Query
    of Queries user guide
    Phil

  • Problem with application-variables - CFLOCK?

    Hi,
    i have a problem with my application. It is a multi-user
    application with 100 parallel-users and CFMX 7.
    The problem wich occures is with application variables. These
    are mainly structs wich get filled onApplicationStart(). The
    problem is, that the variables suddenly disappear, they are empty.
    I have read about CFLock and found out, that it is necesseary
    to use cflock. And i found out, that onApplicationStart does
    correct locking automatically. That is where i do not understand
    the problem. The variables get intialized correctly and in further
    they only get read-access. Why can they be corrupted?
    My other question about that is, wheather i need cflock for
    all Read-Access to Application and Session-Variables, even if there
    happens no writing to the variables?
    Best Regards,
    Andreas

    > ?The element of position 2, of dimension 2, of an array
    object used as part of
    > an expression, cannot be found.?
    > The array is in this case the struct.
    Well, OK, that could be a problem. Arrays are not structs:
    they are two
    different things, are not interchangeable, and have
    completely different
    sets of functions to utilise them. You cannot treat a struct
    as an array.
    If CF is claiming your "struct" is an array, then it actually
    *is* an
    array, not a struct.
    What's the line of code which is generating that error?
    I suppose one could get this error if you have an array of
    structs thus:
    myArray
    .key1
    myArray.key2
    (etc)
    and you're trying to reference it with a numeric key rather
    than by key
    name, eg:
    myArray
    [n]
    When n is an integer value, rather than a string (which
    corresponds to the
    name of the key).
    > > Have you trapped the error, done a <cfdump>
    of the application scope and
    > > checked to see if it's the whole lot going awry, or
    just some values?
    > I have not used cfdump for it, because the server had to
    be immediately
    > restarted for our customers. But i think, that it is
    not completely empty,
    > because the index runs to pos2 of dimenstion2.
    So does this not happen in your dev / testing environment?
    > Will
    > onApplicationStart() be called before? Or only if
    onRequestStart() returns true?
    I would ***-u-me that the application one would be called
    before the
    request one. It's pretty easy for you to test this though, I
    should think?
    (Sorry: for reasons beyond the scope of this conversation,
    we're still
    forced to use Application.cfm in our software, so I've only a
    passing
    knowledge of how Application.cfc works).
    > Here is the code from onRequestStart()
    > <cffunction name="onRequestStart"
    returntype="boolean">
    > <cfargument name="Requestedpage" required="yes" />
    > <cfscript>
    > var lFile = "/cargorent/Login.cfm";
    > var iPosn = ListFindNoCase( lFile,
    Arguments.Requestedpage );
    > if( iPosn gt 0 )
    > return true;
    >
    > if( NOT IsDefined( "session.user.Loginname" ) or
    session.user.Loginname eq
    > "" )
    > {
    > WriteOutput( "<p><p> The current user is no
    longer valid, please log in
    > again.</p></p>" & chr(10) & chr(13)
    > WriteOutput( "<script
    language=""javascript"">parent.location = ""
    http://"
    > & CGI.HTTP_HOST &
    "/Login/Login.cfm"";</script>" );
    > return false;
    > }
    >
    > return true;
    > </cfscript>
    > </cffunction>
    One thing I will say here is that I really think you should
    be separating
    your processing from your display. A function should do
    processing. it
    should pass that processing back to a CFM template which
    should handle
    whatever needs to be displayed on the browser. Although
    that's nowt to do
    with your current issue.
    Adam

  • Value from CFC using cfscript

    I've got a function in a CFC that inserts a parent value into
    an Oracle table (see below). I want to extend the function to
    return the new parent ID so that I can use it to insert the child
    values. I'm using <cfscript> to execute the function which
    works fine with the data insert, but I can't quite work out how to
    output the new parent ID value in <cfscript>. Any help
    appreciated.
    Thanks in advance
    Roy.
    <cffunction name="insertApp" hint="Insert Applications"
    returntype="query">
    <cftry>
    <!--- Insert Values --->
    <cfquery name="qryAppInsert" username='#this.uid#'
    password='#this.pwd#' datasource='#this.source#'>
    INSERT INTO
    impsapp.tblAPPLICATIONS
    VALUES
    (#this.ID#, '#this.dType#',
    TO_DATE('#this.cDate#','dd-mon-yyyy'))
    </cfquery>
    <!--- Select current Value form DUAL --->
    <cfquery name="qryNewSeq" username='#this.uid#'
    password='#this.pwd#' datasource='#this.source#'>
    SELECT impsapp.Test_SEQ.currval x FROM dual
    </cfquery>
    <cfcatch type="any">
    <cfreturn "Error in Function insertApp">
    </cfcatch>
    </cftry>
    <!--- Return Query --->
    <cfreturn qryNewSeq>
    </cffunction>
    <cfscript>
    // create componet object
    comTest = createObject("component", "cfc.Test");
    // Set the properties from Form
    comTest.uid = '#myUser#';
    comTest.pwd = '#myPasswd#';
    comTest.source = '#myDS#';
    comTest.holder= #Form.eID#;
    comTest.appType = '#Form.pType#';
    comTest.recDate = '#DateFormat("#Form.dateReq#",
    "dd/mmm/yyyy")#';
    //Call insert finction
    apply_Card.insertApplications();
    //I need to be able to output and use the value x from the
    qryNewSeq above
    </cfscript>

    YourQuery = comTest.insertApp();
    Your function might be too complicated. If this.id is the
    same as test_seq.currval, why bother with the second query?

  • Problem with return a ColdFusion query object from a Java class

    Hi!
    I need to return a ColdFusion query object from a Java class
    using a JDBC result set ( java.sql.ResultSet);
    I have tried to pass my JDBC result set in to the constructor
    of the coldfusion.sql.QueryTable class with this code:
    ColdFusion code
    <cfset pra = createObject("java","QueryUtil").init()>
    <cfset newQuery = CreateObject("java",
    "coldfusion.sql.QueryTable")>
    <cfset newQuery.init( pra.getColdFusionQuery () ) >
    My java class execute a query to db and return QueryTable
    Java code (QueryUtil.java)
    import coldfusion.sql.QueryTable; // (CFusion.jar for class
    QueryTable)
    import com.allaire.cfx //(cfx.jar for class Query used from
    QueryTable)
    public class QueryUtil
    public static coldfusion.sql.QueryTable
    getColdFusionQuery(java.sql.ResultSet rs)
    return new coldfusion.sql.QueryTable(rs);
    but when i run cfm page and coldfusion server tries to
    execute : "<cfset pra =
    createObject("java","QueryUtil").init()>" this error appears:
    Object Instantiation Exception.
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.
    If i try to execute QueryUtil.java with Eclipse all it works.
    Also I have tried to return java.sql.ResultSet directly to
    coldfusion.sql.QueryTable.init () with failure.
    Do you know some other solution?

    ok
    i print all my code
    pratica.java execute a query to db and return a querytable
    java class
    import java.util.*;
    import java.sql.*;
    import coldfusion.sql.*;
    public class Pratica {
    private HashMap my;
    private String URI,LOGIN,PWD,DRIVER;
    private Connection conn=null;
    //funzione init
    //riceve due strutture converite in hashmap
    // globals
    // dbprop
    public Pratica(HashMap globals,HashMap dbprop) {
    my = new HashMap();
    my.put("GLOBALS",globals);
    my.put("DBPROP",dbprop);
    URI = "jdbc:sqlserver://it-bra-s0016;databaseName=nmobl";
    LOGIN = "usr_dev";
    PWD = "developer";
    DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    try{
    // Carico il driver JDBC per la connessione con il database
    MySQL
    Class.forName(DRIVER);
    /* Connessione alla base di dati */
    conn=DriverManager.getConnection(URI,LOGIN,PWD);
    if(conn!=null) System.out.println("Connection Successful!");
    } catch (ClassNotFoundException e) {
    // Could not find the database driver
    System.out.print("\ndriver non trovato "+e.getMessage());
    System.out.flush();
    catch (SQLException e) {
    // Could not connect to the database
    System.out.print("\nConnessione fallita "+e.getMessage());
    System.out.flush();
    //funzione search
    //riceve un hash map con i filtri di ricerca
    public QueryTable search(/*HashMap arg*/) {
    ResultSet rs=null;
    Statement stmt=null;
    QueryTable ret=null;
    String query="SELECT * FROM TAN100pratiche";
    try{
    stmt = conn.createStatement();// Creo lo Statement per
    l'esecuzione della query
    rs=stmt.executeQuery(query);
    // while (rs.next()) {
    // System.out.println(rs.getString("descrizione"));
    catch (Exception e) {
    e.printStackTrace();
    try {
    ret = Pratica.RsToQueryTable(rs);
    } catch (SQLException e) {
    e.printStackTrace();
    this.close();
    return(ret);
    // ret=this.RsToQuery(rs);
    // this.close(); //chiude le connessioni,recordset e
    statament
    //retstruct CF vede HashMap come struct
    //METODO DI TEST
    public HashMap retstruct(){
    return(my);
    //conversione resultset to querytable
    private static QueryTable RsToQueryTable(ResultSet rs)
    throws SQLException{
    return new QueryTable(rs);
    //chiura resultset statament e connessione
    private void close(){
    try{
    conn.close();
    conn=null;
    catch (Exception e) {
    e.printStackTrace();
    coldfusion code
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN">
    <html>
    <head>
    <title>Test JDBC CFML Using CFScript</title>
    </head>
    <body>
    <cftry>
    <cfset glb_map =
    createObject("java","java.util.HashMap")>
    <cfset dbprop_map =
    createObject("java","java.util.HashMap")>
    <cfset glb_map.init(glb)> <!---are passed from
    another page--->
    <cfset dbprop_map.init(glb["DBPROP"])>
    <cfset pra =
    createObject("java","Pratica").init(glb_map,dbprop_map)>
    <cfset ourQuery
    =createObject("java","coldfusion.sql.QueryTable").init(pra.search())>
    <cfcatch>
    <h2>Error - info below</h2>
    <cfdump var="#cfcatch#"><cfabort>
    </cfcatch>
    </cftry>
    <h2>Success - statement dumped below</h2>
    <cfdump var="#ourQuery#">
    </body>
    </html>
    error at line <cfset pra =
    createObject("java","Pratica").init(glb_map,dbprop_map)>
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.
    -----------------------------------------------------------------------

  • Non latin character sets and accented latin character with refind

    I need to use refind to deal with strings containing accented
    characters like žittâ lísu, but it doesn't seem to
    find them. Also when using it with cyrillic characters , it won't
    find individual characters, but if I test for [\w] it'll work.
    I found a livedocs that says cf uses the Java unicode
    standard for characters. Is it possible to use refind with non
    latin characters or accented characters or do I have to write my
    own Java?

    ogre11 wrote:
    > I need to use refind to deal with strings containing
    accented characters like
    > ?itt? l?su, but it doesn't seem to find them. Also when
    using it with cyrillic
    > characters , it won't find individual characters, but if
    I test for [\w] it'll
    > work.
    works fine for me using unicode data:
    <cfprocessingdirective pageencoding="utf-8">
    <cfscript>
    t="Tá mé in ann gloine a ithe;
    Nà chuireann sé isteach nó amach
    orm";
    s="á";
    writeoutput("search:=#t#<br>for:=#s#<br>found
    at:=#reFind(s,t,1,false)#");
    </cfscript>
    what's the encoding for your data?

Maybe you are looking for