Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop in a trigger to get easily all changed fields [CORE2147] #2578

Open
firebird-automations opened this issue Oct 25, 2008 · 3 comments
Open

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Valdir Marcos (valdir_marcos)

Is duplicated by CORE4924

Votes: 5

Today, in Firebird 2.1.1, is still too hard to code audition logs and/or replication...

It would help a lot if it were possible in a trigger to do something like:
-----------------------
Declare Variable i integer;
begin
for i = 1 to Fields.Length do
begin
if Fields[i].New <> Fields[i].Old then
insert into Log_Table(TableName, UserName, IP_Number, Program_Name, Action, Details)
Values ('Table_X', 'User_X', 'IP_X', 'Programa_X', 'Insert or Update or Update/Insert or Delete', 'Changed from ' || Fields[i].Old || ' to ' || Fields[i].New);
end;
end;
-----------------------

It would help a lot if Firebird could provide the variables "Fields" and "Action" (indicating Insert or Update or Update/Insert or Delete for those generic triggers) .

Thanks,

Valdir

@firebird-automations
Copy link
Collaborator Author

Commented by: @cincuranet

You can check updating, deleting, inserting variables to see what action(s) is being performed. For fields look at CORE2131 .

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

I need to point out that it is possible to create a logging/replication trigger using a database procedure which would analyze the table metadata and then create the trigger body and then execute the DML. We do this in our own application today.

While I agree that a mechanism to loop through the table fields, without having to know the fieldnames has some benefits, but a complete solution would require supporting runtime functions which would: return the base datatype for a field, the precision of the field in order for true data logging to occur.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Link: This issue is duplicated by CORE4924 [ CORE4924 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant