Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello...
I am a Delphi Developer.
i have a query for master / detail table, which is for Audit record. now i want to generate a report for Audit Trail using this query with the help of Grid in delphi. Is there any properties in grid that i can use for the same. i am using dev express components.
Thanks a lot for any help...

my sql is

SQL
declare @col varchar(max)
declare @col1 varchar(max)
declare @convert varchar(max)

select @col = STUFF((select distinct '],[' + Audit_field_name  from tblAuditTrail
                WHERE  AUDIT_ACTION_TYPE = 'iNSERT' --AND AUDIT_ACTION_TIME = ''
                AND AUDIT_USER_ID = '1' AND AUDIT_TBL_NAME = 'PUR_ORD'
                for xml path ('')), 1,2, '') + ']'

select @col1 = STUFF((select distinct '],[' + Audit_field_name  from tblAuditTrail
                WHERE  AUDIT_ACTION_TYPE = 'iNSERT' --AND AUDIT_ACTION_TIME = ''
                AND AUDIT_USER_ID = '1' AND AUDIT_TBL_NAME = 'PUR_ORD_items'
                for xml path ('')), 1,2, '') + ']'

--select @col
set @convert = 'select * from
(select AUDIT_TBLDETAIL_PKID,audit_new_value,audit_field_name from tblaudittrail
         where AUDIT_TBLDETAIL_PKID > 0 and AUDIT_TBLMASTER_PKID = 0) as tblaudittrail
    pivot(max(audit_new_value) for audit_field_name
    in (' + @col + ')) as pivottable

    union all

    select * from
(select AUDIT_TBLDETAIL_PKID,audit_new_value,audit_field_name from tblaudittrail
         where AUDIT_TBL_NAME LIKE ''PUR_ORD_items'') as tblaudittrail
    pivot(max(audit_new_value) for audit_field_name
    in (' + @col + ')) as pivottable'

     execute(@convert)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900