Question

I think I've gotten the most simplest scenario built. I just want to pass it by everyone for a sanity check. Here's the idea:

GetErrorCodes.cfm does the following:

<cfscript>
response = new ErrorCodes().WhereXXX(); // ACF or Railo, doesn't matter
</cfscript>

ErrorCodes.cfc:

function WhereXXX() {
return new sproc().exec('app.GetErrorCodes'); // All my functions will do this instead of executing the sproc themselves.
}

sproc.cfc:

component {
function exec(procedure) {
    local.result = {};
    if (server.ColdFusion.productname == 'Railo') {
        return new Railo().exec(arguments.procedure); // Has to be outside of sproc.cfc because ColdFusion throws a syntax error otherwise.
    }
    local.svc = new storedProc();
    local.svc.setProcedure(arguments.procedure);
    local.svc.addProcResult(name='qry'); 
    try {
        local.obj = local.svc.execute();
        local.result.Prefix = local.obj.getPrefix();
        local.result.qry = local.obj.getProcResultSets().qry;
    } catch(any Exception) {
        request.msg = Exception.Detail;
    }
    return local.result;
}

Railo.cfc:

    component {
        function exec(procedure) {
local.result = {};
            try {
                storedproc procedure=arguments.procedure result="local.result.Prefix" returncode="yes" {
                    procresult name="local.result.qry";
                }
            } catch(any Exception) {
                request.msg = Exception.Message;
            }
            return local.result;
        }
        }

So I've been working on this all day, but tell me, is this a sane way to keep the source code the same if it's to be run on either a ColdFusion server or a Railo server?

Was it helpful?

Solution

Um... just use <cfstoredproc> instead of trying to use two different CFScript approaches that are mutually exclusive to each other of the CFML platforms.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top