def makeUpdateProcBody( table ): instanceName = table.makeName( Format.ada, Qualification.unqualified, ItemType.instanceName ) template = Template( file=templatesPath()+"update.func.tmpl" ) template.procedureHeader = makeUpdateProcHeader( table, CONNECTION_STRING, ' is' ) #template.pkCriteria = makeCriterionList( table, 'pk_c', 'primaryKeyOnly', True ) #template.inputCriteria = makeCriterionList( table, 'values_c', 'allButPrimaryKey', True ) template.insertStrings = makeAliasedStrings( instanceName, table.variables ) template.allParams = makeParamsBindings( instanceName, makeVariablesInUpdateOrder( table.variables )) return str(template)
def makeSaveProcBody( table ): instanceName = table.makeName( Format.ada, Qualification.unqualified, ItemType.instanceName ) outputRecord = table.makeName( Format.ada, Qualification.full, ItemType.table ) template = Template( file=templatesPath()+"save.func.tmpl" ) template.procedureHeader = makeSaveProcHeader( table, CONNECTION_STRING, ' is' ) template.allCriteria = makeCriterionList( table, 'c', 'all', True ) primaryKey = makePrimaryKeySubmitFields( table ) # template.tmpVariable = instanceName + "_tmp" pkFields = table.getPrimaryKeyVariables() template.insertStrings = makeAliasedStrings( instanceName, table.variables ) template.existsCheck = 'Exists( ' + primaryKey + ' ) then' template.updateCall = 'Update( '+ instanceName + ', local_connection )' # template.tmpVariableWithAssignment = instanceName + "_tmp : " + outputRecord; template.has_pk = table.hasPrimaryKey() # template.retrieveByPK = instanceName + '_tmp := retrieve_By_PK( ' + primaryKey + ' )' template.allParams = makeParamsBindings( instanceName, table.variables ) s = str(template) return s