Buenas tardes Estimado Adolfo, todo bien?
Asegurate de inicializar el valor !"OTHER" en el proc. K2BAuditModelDBMS ya que allì por defecto se setean valores a la variable &AuditModelDBMS para los datastore soportados por default.
Quizá no tenes seteada esa variable en ese valor y por eso no ingresa a la sección donde se genera el código de los triggers.
Cualquier consulta, a las órdenes.
Saludos.
Buenas tardes, tenemos un dkt para creación de triggers en AS400. El mismo estoy adjuntando.
El problema es que al dar "Reorganize" a través de la opción de Menú "K2BAudit".., en el output de Genexus me sale como que hizo todo bien (Mensaje "Reorganization Success"), pero al ingresar a la AS400 y visualizar los triggers del archivo para el cual quiero auditar, veo que sólo me genero un trigger, el correspondiente al insert y no los triggers para el delete y el update.
Alguna sugerencia del porque podría suceder eso?
Envío también abajo el código generado en Genexus en el procedimiento Audit<NombreArchivo>CreateMetadata.
If &AuditModelDBMS = !"OTHER"
&createInsertTrigger += !"CREATE TRIGGER <AuditDB>/InsertSPMONRELTrigger " + NewLine()
&createInsertTrigger += !"AFTER INSERT ON <AuditDB>/SPMONREL " + NewLine()
&createInsertTrigger += !" REFERENCING NEW AS NAUDIT " + NewLine()
&createInsertTrigger += !"FOR EACH ROW MODE DB2SQL " + NewLine()
&createInsertTrigger += !"BEGIN ATOMIC " + NewLine()
&createInsertTrigger += !" DECLARE K2BAuserName CHARACTER(90); " + NewLine()
&createInsertTrigger += !" DECLARE auditRecordKey VARCHAR(16000); " + NewLine()
&createInsertTrigger += !" DECLARE auditValue VARCHAR(16000); " + NewLine()
&createInsertTrigger += !" set auditRecordKey = CONCAT('<Attributes>','<Attribute><Name>MonRelCod</Name><Value><![CDATA['); " + NewLine()
&createInsertTrigger += !" " + NewLine()
&createInsertTrigger += !" " + NewLine()
&createInsertTrigger += !" set auditRecordKey = CONCAT(auditRecordKey, CHAR(NAUDIT.MonRelCod)); " + NewLine()
&createInsertTrigger += !" set auditRecordKey = CONCAT(auditRecordKey,']]></Value></Attribute>'); " + NewLine()
&createInsertTrigger += !" set auditRecordKey = CONCAT(auditRecordKey,'</Attributes>'); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT('<Attributes>','<Attribute><Name>MonRelCod</Name><Key>True</Key>'); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue,'<New><![CDATA['); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(NAUDIT.MonRelCod), '')); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue, ']]></New>'); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue, '</Attribute>'); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue, '<Attribute><Name>MonRelDsc</Name>'); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue,'<New><![CDATA['); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(NAUDIT.MonRelDsc), '')); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue, ']]></New>'); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue, '</Attribute>'); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue, '<Attribute><Name>MonRelRel</Name>'); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue,'<New><![CDATA['); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(NAUDIT.MonRelRel), '')); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue, ']]></New>'); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue, '</Attribute>'); " + NewLine()
&createInsertTrigger += !"set auditValue = CONCAT(auditValue, '</Attributes>'); " + NewLine()
&createInsertTrigger += !"IF GXUserId is null THEN " + NewLine()
&createInsertTrigger += !" set K2BAuserName = USER; " + NewLine()
&createInsertTrigger += !"ELSE " + NewLine()
&createInsertTrigger += !" set K2BAuserName = GXUserId; " + NewLine()
&createInsertTrigger += !"END IF; " + NewLine()
&createInsertTrigger += !" INSERT INTO <AuditDB>/auditload (ALDateTime, ALApplicationUser, ALOperation, ALEntity, ALTable, ALRecordKey, ALValue, ALDBMSUSER) Values (current timestamp, K2BAuserName, 'INS', 'SPMONREL', 'SPMONREL', auditRecordKey, auditValue, USER); " + NewLine()
&createInsertTrigger += !"END " + NewLine()
&createUpdateTrigger += !"CREATE TRIGGER <AuditDB>/UpdateSPMONRELTrigger " + NewLine()
&createUpdateTrigger += !"AFTER UPDATE ON <AuditDB>/SPMONREL " + NewLine()
&createUpdateTrigger += !" REFERENCING NEW AS NAUDIT OLD AS OAUDIT " + NewLine()
&createUpdateTrigger += !"FOR EACH ROW MODE DB2SQL " + NewLine()
&createUpdateTrigger += !"BEGIN ATOMIC " + NewLine()
&createUpdateTrigger += !" DECLARE K2BAuserName CHARACTER(90); " + NewLine()
&createUpdateTrigger += !" DECLARE auditRecordKey VARCHAR(16000); " + NewLine()
&createUpdateTrigger += !" DECLARE auditValue VARCHAR(16000); " + NewLine()
&createUpdateTrigger += !" set auditRecordKey = CONCAT('<Attributes>','<Attribute><Name>MonRelCod</Name><Value><![CDATA['); " + NewLine()
&createUpdateTrigger += !" " + NewLine()
&createUpdateTrigger += !" " + NewLine()
&createUpdateTrigger += !" set auditRecordKey = CONCAT(auditRecordKey, CHAR(NAUDIT.MonRelCod)); " + NewLine()
&createUpdateTrigger += !" set auditRecordKey = CONCAT(auditRecordKey,']]></Value></Attribute>'); " + NewLine()
&createUpdateTrigger += !" set auditRecordKey = CONCAT(auditRecordKey,'</Attributes>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT('<Attributes>','<Attribute><Name>MonRelCod</Name><Key>True</Key>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,'<Old><![CDATA['); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(OAUDIT.MonRelCod), '')); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,']]></Old>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,'<New><![CDATA['); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(NAUDIT.MonRelCod), '')); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue, ']]></New>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue, '</Attribute>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue, '<Attribute><Name>MonRelDsc</Name>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,'<Old><![CDATA['); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(OAUDIT.MonRelDsc), '')); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,']]></Old>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,'<New><![CDATA['); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(NAUDIT.MonRelDsc), '')); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue, ']]></New>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue, '</Attribute>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue, '<Attribute><Name>MonRelRel</Name>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,'<Old><![CDATA['); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(OAUDIT.MonRelRel), '')); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,']]></Old>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,'<New><![CDATA['); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(NAUDIT.MonRelRel), '')); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue, ']]></New>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue, '</Attribute>'); " + NewLine()
&createUpdateTrigger += !"set auditValue = CONCAT(auditValue, '</Attributes>'); " + NewLine()
&createUpdateTrigger += !"IF GXUserId is null THEN " + NewLine()
&createUpdateTrigger += !" set K2BAuserName = USER; " + NewLine()
&createUpdateTrigger += !"ELSE " + NewLine()
&createUpdateTrigger += !" set K2BAuserName = GXUserId; " + NewLine()
&createUpdateTrigger += !"END IF; " + NewLine()
&createUpdateTrigger += !" INSERT INTO <AuditDB>/auditload (ALDateTime, ALApplicationUser, ALOperation, ALEntity, ALTable, ALRecordKey, ALValue, ALDBMSUSER) Values (current timestamp, K2BAuserName, 'UPD', 'SPMONREL', 'SPMONREL', auditRecordKey, auditValue, USER); " + NewLine()
&createUpdateTrigger += !"END " + NewLine()
&createDeleteTrigger += !"CREATE TRIGGER <AuditDB>/DeleteSPMONRELTrigger " + NewLine()
&createDeleteTrigger += !"AFTER DELETE ON <AuditDB>/SPMONREL " + NewLine()
&createDeleteTrigger += !" REFERENCING OLD AS OAUDIT " + NewLine()
&createDeleteTrigger += !"FOR EACH ROW MODE DB2SQL " + NewLine()
&createDeleteTrigger += !"BEGIN ATOMIC " + NewLine()
&createDeleteTrigger += !" DECLARE K2BAuserName CHARACTER(90); " + NewLine()
&createDeleteTrigger += !" DECLARE auditRecordKey VARCHAR(16000); " + NewLine()
&createDeleteTrigger += !" DECLARE auditValue VARCHAR(16000); " + NewLine()
&createDeleteTrigger += !" set auditRecordKey = CONCAT('<Attributes>','<Attribute><Name>MonRelCod</Name><Value><![CDATA['); " + NewLine()
&createDeleteTrigger += !" " + NewLine()
&createDeleteTrigger += !" " + NewLine()
&createDeleteTrigger += !" set auditRecordKey = CONCAT(auditRecordKey, CHAR(OAUDIT.MonRelCod)); " + NewLine()
&createDeleteTrigger += !" set auditRecordKey = CONCAT(auditRecordKey,']]></Value></Attribute>'); " + NewLine()
&createDeleteTrigger += !" set auditRecordKey = CONCAT(auditRecordKey,'</Attributes>'); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT('<Attributes>','<Attribute><Name>MonRelCod</Name><Key>True</Key>'); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue,'<Old><![CDATA['); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(OAUDIT.MonRelCod), '')); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue,']]></Old>'); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue, '</Attribute>'); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue, '<Attribute><Name>MonRelDsc</Name>'); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue,'<Old><![CDATA['); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(OAUDIT.MonRelDsc), '')); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue,']]></Old>'); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue, '</Attribute>'); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue, '<Attribute><Name>MonRelRel</Name>'); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue,'<Old><![CDATA['); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue,COALESCE(CHAR(OAUDIT.MonRelRel), '')); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue,']]></Old>'); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue, '</Attribute>'); " + NewLine()
&createDeleteTrigger += !"set auditValue = CONCAT(auditValue, '</Attributes>'); " + NewLine()
&createDeleteTrigger += !"IF GXUserId is null THEN " + NewLine()
&createDeleteTrigger += !" set K2BAuserName = USER; " + NewLine()
&createDeleteTrigger += !"ELSE " + NewLine()
&createDeleteTrigger += !" set K2BAuserName = GXUserId; " + NewLine()
&createDeleteTrigger += !"END IF; " + NewLine()
&createDeleteTrigger += !" INSERT INTO <AuditDB>/auditload (ALDateTime, ALApplicationUser, ALOperation, ALEntity, ALTable, ALRecordKey, ALValue, ALDBMSUSER) Values (current timestamp, K2BAuserName, 'DLT', 'SPMONREL', 'SPMONREL', auditRecordKey, auditValue, USER); " + NewLine()
&createDeleteTrigger += !"END " + NewLine()
EndIf
Saludos y gracias desde ya.
--
--
José Alfredo Bordón Bogado
0 Response to "Re: [k2btools] problema al intentar crear scripts de triggers a partir de dkt en AS400"
Publicar un comentario