I'm not sure I have an answer to that one, as you're kind of mixing
different styles.  I think I'd still say that a transaction can only be
controlled from the upper level, outside the function, so you'd need to add
CFTRANSACTION tags around the first CFINVOKE, just like the second set.

Here's another idea:

This is totally shooting from the hip (with code below), but what about
making beginTransaction, rollbackTransaction and commitTransaction functions
in your CFC.  Inside the function body, they'd use a request-scoped flag to
track whether there is a transaction currently open, and would only actually
do anything when the state changed.  Then you would call them from inside
your functions (taking care of case one), and you could also call them from
outside the functions (case two), in which case the inside calls wouldn't do
anything, because there is already a transaction in progress.

function beginTransaction() {
  if (request.transactionNext EQ 0) {
    CFTRANSACTION ACTION="begin"
  }
  request.transactionNext = request.transactionNext + 1;
}

function rollbackTransaction() {
  if (request.transactionNext EQ 0) {
        CFTHROW TYPE="NoValidTransactionException"
  }
  CFTRANSACTION ACTION="rollback"
  request.transactionNext = 0;
}

function commitTransaction() {
  request.transactionNext = request.transactionNext - 1;
  if (request.transactionNext EQ 0) {
    CFTRANSACTION ACTION="commit"
  }
}

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Jay Gibb
> Sent: Tuesday, November 18, 2003 12:34 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] cftransactions in low level modules
>
>
> Hey Barney,
>
> What about if you're not using OO modelling?  This is for a procedural
> system.  A pseudo implementation might be...
>
> <!--- in one place... --->
> <cfinvoke method="myFunction" component="myComponent"
>       returnVariable="result">
>
> <!--- in another place... --->
> <cftransaction>
>       <cfinvoke method="myFunction" component="myComponent"
>               useTransaction="no"
>               returnVariable="result">
>
>       <cfinvoke method="myFunction" component="myComponent"
>               useTransaction="no"
>               returnVariable="result">
>
>       <cfinvoke method="myFunction" component="myComponent"
>               useTransaction="no"
>               returnVariable="result">
> </cftransaction>
>
>  - j.
>

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to