Doug,

I've run into one problem migrating the Reactor blog to Oracle. Oracle doesn't 
have an "autonumber" or "identity" equivalent.  So the function, 
"Convention.lastInseredIdSyntax", doesn't work.  Oracle has sequences which can 
be used as a work-around. The code below is a modified version of the create 
function in EntryDAO in the blog app (the modified lines are marked w/ an "x"). 
This seems to require always creating a custom create function -- that seems 
very much against the reactor spirit. I thought about changing the XSL DAO 
template.

Any suggestions?  

Thanks,

Beth

        <cffunction name="create" access="public" hint="I create a Entry 
object." output="false" returntype="void">
                <cfargument name="to" hint="I am the transfer object for Entry" 
required="yes" type="reactor.project.ReactorBlog.To.EntryTo" />
                <cfset var Convention = getConventions() />
                <cfset var qCreate = 0 />
x               <cfset var qUniqueSeq = 0 />


                <cftransaction>
x                       <cfquery name="qUniqueSeq" 
datasource="#_getConfig().getDsn()#" username="#_getConfig().getUsername()#" 
password="#_getConfig().getPassword()#">
x                          select unique_seq.nextval nextSequenceValue
x                          from dual
x                       </cfquery>
         
                        <cfquery name="qCreate" 
datasource="#_getConfig().getDsn()#" username="#_getConfig().getUsername()#" 
password="#_getConfig().getPassword()#">
                                INSERT INTO 
#Convention.FormatObjectName(getObjectMetadata(), '')#
                                (

                                                        
#Convention.formatFieldName('ENTRYID', 'Entry')#
                                                        ,...

                                ) VALUES (

                                                        <cfqueryparam 
cfsqltype="cf_sql_numeric"

                                                                scale="22"

x                                                       
value="#qUniqueSeq.nextSequenceValue#"
                                                         />...

                                )


                                <cfif ListFindNoCase("mssql", 
_getConfig().getType())>
                                        
#Convention.lastInseredIdSyntax(getObjectMetadata())#
                                </cfif>
                        </cfquery>

x                       <cfif NOT ListFindNoCase("mssql,oracle", 
_getConfig().getType())>
                                <cfquery name="qCreate" 
datasource="#_getConfig().getDsn()#" username="#_getConfig().getUsername()#" 
password="#_getConfig().getPassword()#">
                                        
#Convention.lastInseredIdSyntax(getObjectMetadata())#
                                </cfquery>
                        </cfif>
                </cftransaction>


        </cffunction>




-- Reactor for ColdFusion Mailing List -- reactor@doughughes.net
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/

<<winmail.dat>>

Reply via email to