1. Home
  2. Docs
  3. Models
  4. Pre select hook

Pre select hook

With a pre select hook you can run code before the select block. For example you can run UPDATE or even TRUNCATE statements. For WITH statements, there is a specific hook.

Update destination table #

{{ block "PRE_SELECT_HOOKS" . }}
UPDATE {{ .This }}
SET blub=14
WHERE "date2" BETWEEN '{{ .StartDate }}' and '{{ .EndDate }}'
{{end}}

Empty the whole destination table #

{{ block "PRE_SELECT_HOOKS" . }}
  TRUNCATE {{ .This }}
{{end}}