• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Named and anonymous CFC arguments may not be mixed. Error parsing Bind

Contributor ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

I've been working on transforming an old CF9 form into a CF 2016 version and have everything working except . . .

I have a form that folks can select various search criteria off a record (i.e. userid, sequenceNumber, PayCode, PaymentDate, ABSdollar, MinDollar, MaxDollar, etc).

As the values get selected the arguments get built (some are just the value, and some are phrases - i.e. "AND abs(payment_amount) = #client.gdabsamount#") and then these values get sent serializeJSON before they go to the CFC where executed.

This is where the value gets set:

<CFIF LTRIM(RTRIM(client.gdabsamount)) is "">

   <cfset client.gdabsamount = "">

<cfelse>

<cfset client.gdabsamount = "AND abs(payment_amount) = #client.gdabsamount# ">

</cfif>

<cfset AP = serializeJSON(#client.gdabsamount#)>

<cfgrid format="html" name="grid" pagesize=18 sort="yes" selectMode="row" selectColor="##e6e6ff" height="500" width="1400"                    

                  bind="cfc:alltran.getData({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},#PT#,#AU#,#SEQ#,#MN#,#MX#,#AP#,'No',#CO1#,#CO2#,#PC#,#UMND#,#UMXD#)" >

In the CFC -

        <cfargument name="gdabsamount">

        <cfquery name="GetControl" datasource ="#application.DataSource#" username ="#application.dbuser#" password ="#application.dbpw#" timeout="60" maxRows="10000">

            SELECT sequence_number, date_inserted, sbcuid, CONVERT(VARCHAR(10), payment_date, 101) payment_date, smp_name, smp_code, payment_amount, srp_name, srp_code, payment_type, 

            addenda_text1, processed_date, payment_desc, smp_gl, smp_ic, smp_rc, smp_tcc, srp_gl, srp_ic, srp_rc, srp_tcc, payment_notes, opt_smp_gl, opt_smp_rc, opt_smp_tcc, opt_srp_gl,               

            opt_srp_rc, opt_srp_tcc, mark_deleted

            FROM int_trans

            WHERE #ARGUMENTS.gdpaymenttype# sbcuid like '#ARGUMENTS.gdallusers#' 

            #ARGUMENTS.gdseqnum# #ARGUMENTS.gdminpayamount# #ARGUMENTS.gdmaxpayamount#

            and mark_deleted like '#ARGUMENTS.gdshowdeleted#'

            #preservesinglequotes(ARGUMENTS.gdcompany_name1)#

            #preservesinglequotes(ARGUMENTS.gdcompany_name2)#

         #preservesinglequotes(ARGUMENTS.gcpaycode)#

   and cast(payment_amount as money) >= cast ((#ARGUMENTS.gdabsamount#) as money)

            and cast(payment_date as smalldatetime) #condition#  cast (#CreateODBCDate(arguments.gcmaxdate)# as smalldatetime)

            and cast(payment_date as smalldatetime) >= cast (#CreateODBCDate(arguments.gcmindate)# as smalldatetime)

            ORDER BY #arguments.gridsortcolumn# #arguments.gridsortdirection#      

        </cfquery>

We are using a SQL Server 2008 R2 database, so we had to cast the values for the dates.

We have the query and cfc working except for when we select something for the dollar amounts.  When we include anything with the dollar amount we get:

   

      Named and anonymous CFC arguments may not be mixed.
       Error parsing bind cfc:alltran.getData({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},"
      ","PRCTG",""," "," ","AND abs(payment_amount) = 22.34 ",'No'," and
      smp_code like 'PRCTG'"," and srp_code like 'PRCTG'"," and payment_type
      like 'PRCTG'",'01/01/2000','12/30/2050')

We've searched google for anything about the error and come up with blank.

Any help would be greatly appreciated.

Libby H.
   

Views

265

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

LATEST

The error itself is pretty straightforward. When you call a function, you can either use anonymous arguments or named arguments. Let's say you have a function like this:

<cffunction name="add" return="numeric">

     <cfargument name="var1" type="numeric">

     <cfargument name="var2" type="numeric">

     <cfreturn var1 + var2>

</cffunction>

You could call it either of these ways:

add(5, 3)

or

add(var1=5, var2=3)

So, without going through all of the code you posted - I am too lazy to do that anymore I guess - I'm guessing that CF is getting confused about your name-value pairs. My lazy solution would be to rewrite the CFC so that you simply pass in literal values and let the CFC figure out what to do with them. In other words, if client.gdabsamount is a nonzero value, just pass in whatever it is, and have your CFC do the necessary string concatenation within a conditional block.

Dave Watts, Fig Leaf Software

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation