On the button, ASCII_CHAR(10) works as expected.
While I have your attention, please could you advise if there is a neater way of compressing the multiple IIF statements please? Perhaps a different notation to IIF? The full query I am using is:
SELECT
IIF
(
"TblEvent"."Sample ID" IS NOT NULL, 'Sample ID ' || "TblEvent"."Sample ID" || ', ' , ''
)
||
IIF
(
"TblEvent"."PHE notify" = 'PHE Consent NOT given', 'Consent not given for ID release to PHE.',
IIF
(
"TblEvent"."PHE notify" = 'PHE ID sent via RFID', 'PHE ID sent via RFID.',
IIF
(
"TblEvent"."PHE notify" = 'Convalescent PCR','Convalescent PCR ID not needed.',
IIF
(
"TblEvent"."PHE notify" = 'Not resident in England', 'No need to notify PHE because not resident in England.',
(
IIF
(
"TblEvent"."Case name" IS NOT NULL, "TblEvent"."Case name" || ', ', 'Name withheld, '
)
||
IIF
(
"TblEvent"."Case DoB" IS NOT NULL, LPAD(EXTRACT(DAY FROM "TblEvent"."Case DoB"), 2, '0') || '/' || LPAD(EXTRACT(MONTH FROM "TblEvent"."Case DoB"), 2, '0')|| '/' || LPAD(EXTRACT(YEAR FROM "TblEvent"."Case DoB"), 2, '0') || ', ', 'DoB withheld, '
)
||
IIF
(
"TblEvent"."Case Tel" IS NOT NULL, "TblEvent"."Case Tel" || ', ', 'Tel No withheld, '
)
||
IIF
(
"TblEvent"."Add1" IS NOT NULL, "TblEvent"."Add1" || ', ', 'Address withheld, '
)
||
IIF
(
"TblEvent"."Postcode" IS NOT NULL, "TblEvent"."Postcode" || '. ', 'Postcode withheld. '
)
)
||
IIF
(
"TblEvent"."PHE notify" = 'PHE Consent given', '(Consent to release ID to PHE given)', ''
)
)
)
)
)
||
ASCII_CHAR(10)
||
IIF
(
"TblEvent"."Details" IS NOT NULL, 'Details: ' || "TblEvent"."Details", ''
)
||
ASCII_CHAR(10)
||
IIF
(
"TblEvent"."Vaccine status" IS NOT NULL,
IIF
(
"TblEvent"."Vaccine status" = 0, 'Unvaccinated',
IIF
(
"TblEvent"."Vaccine status" = 1, 'Single vacc < 2w ago',
IIF
(
"TblEvent"."Vaccine status" = 2, 'Single vacc > 2w ago',
IIF
(
"TblEvent"."Vaccine status" = 3, 'Double vacc < 2w ago',
IIF
(
"TblEvent"."Vaccine status" = 4, 'Double vacc > 2w ago',
IIF
(
"TblEvent"."Vaccine status" = 5, 'Double vacc + booster',
IIF
(
"TblEvent"."Vaccine status" = 6, 'Vacc status unknown'|| ASCII_CHAR( 10 ), ''
)
)
||
IIF
(
"TblEvent"."Advice" IS NOT NULL, 'Advice: ' || "TblEvent"."Advice", ''
)
AS "Export"
FROM "TblEvent"
WHERE "event_ID" = :ID_value
I haven’t quite got the following to work yet because I can’t work out how to end the nested IIF statements in the following part:
IIF
(
"TblEvent"."Vaccine status" IS NOT NULL,
IIF
(
"TblEvent"."Vaccine status" = 0, 'Unvaccinated',
IIF
(
"TblEvent"."Vaccine status" = 1, 'Single vacc < 2w ago',
IIF
(
"TblEvent"."Vaccine status" = 2, 'Single vacc > 2w ago',
IIF
(
"TblEvent"."Vaccine status" = 3, 'Double vacc < 2w ago',
IIF
(
"TblEvent"."Vaccine status" = 4, 'Double vacc > 2w ago',
IIF
(
"TblEvent"."Vaccine status" = 5, 'Double vacc + booster',
IIF
(
"TblEvent"."Vaccine status" = 6, 'Vacc status unknown'|| ASCII_CHAR( 10 ), ''
)
)