Skip to content

Conversation

@monishdeb
Copy link
Member

No description provided.


$variables = ["
DECLARE calculated_contact_id integer;
SET calculated_contact_id := (SELECT contact_id FROM civicrm_contribution WHERE id = NEW.contribution_id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monishdeb aren't SQL variables normally set to start with an @

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 actually there are two types of variable declaration, the one which starts with @ is a user-defined loosely typed variable (by loosely means can be directly assigned with a value without declaring the type) and can be re-used in other Triggers/Procedure in a session and without @ is a local variable which is a valid in particular trigger and need to mention their type. For more detail please check here.

In this case as there are three CREATE/UPDATE/DELETE event trigger, so I thought its better to have a there respective local variable.

@seamuslee001
Copy link
Member

This seems ok but I need to r-run it if possible on test sites before being comfortable with it, I suspect it won't help that much but at least we are getting rid of one sub query

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants