Is there a limitation with numerical queries / operators that we can write inside cftransaction?

Today, correcting errors in some existing code, I found a strange error.

Too big branch offset too short

After searching, I found that this is due to Java byte code conversion. Here are the links I found:

In my case, cftransaction contains about 870 statements and works fine. But I need to add 2 more requests to this transaction. Now I get this error when I add even one line of code inside cftransaction. Currently, I cannot migrate any of the existing cfquery from cftransaction.

Here is the general structure of the code:

<cftransaction action="begin"> <cfif URL.action eq 'add'> Around 200 lines of queries/statements <cfelseif URL.action eq 'edit'> Around 200 lines of queries/statements </cfif> <cfif URL.action eq 'add' or URL.action 'edit'> Around 450 lines of queries/statements </cfif> </cftransaction> 

Is there any workaround?

+7
coldfusion coldfusion-9 cfquery
source share
1 answer

The branch deviation should correspond to the size of the module / function. It can also be called due to the large conditional code block cfif/cfelse or cfswitch .

Technically, I'm not sure if there is any cap on no. queries that you can put in the cftransaciton block. It has nothing to do with code migration from CF8 to CF9, but the length of the code is inside conditional blocks.

I would like to break the function and try to put each of the large conditional blocks in a separate function inside cfc:

  <cffunction name="myFunc1"> <cftransaction action="begin"> <cfif URL.action eq 'add'> <!--- function call with your xxx lines of queries/statements ---> <cfinvoke component="MyCfc" method="firstQueryBlock" result="result1"> <cfelseif URL.action eq 'edit'> <!--- second function call with your yyy lines of queries/statements ---> <cfinvoke component="MyCfc" method="secondQueryBlock" result="result2"> </cfif> <cfif URL.action eq 'add' or URL.action 'edit'> <!--- third function call with your zzz lines of queries/statements ---> <cfinvoke component="MyCfc" method="thirdQueryBlock" result="result3"> </cfif> </cftransaction> </cffunction> 
+2
source share

All Articles