Created
September 22, 2018 21:32
-
-
Save trycf/431b57860ebde4c95abcb3e5b7c5927d to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
// Build a fake query object. | |
HospitalVisits2 = queryNew( | |
"patientID, Reason_For_Visit", | |
"integer, varchar", | |
[ | |
{ patientID: 1, Reason_For_Visit: "Broken leg" } | |
, { patientID: 1, Reason_For_Visit: "Concussion" } | |
, { patientID: 1, Reason_For_Visit: "Severe bleeding" } | |
, { patientID: 1, Reason_For_Visit: "BROKEN LEG" } // Duped value in different case. | |
, { patientID: 1, Reason_For_Visit: "Aches,pain" } // Comma in value | |
, { patientID: 1, Reason_For_Visit: "" } // Empty value | |
] | |
); | |
writeDump(HospitalVisits2); // What's in our query? | |
newReasonList = listChangeDelims( listRemoveDuplicates( valuelist(HospitalVisits2.Reason_For_Visit, "|"),"|",true ),", ","|",false ) ; | |
</cfscript> | |
<br><br> | |
This is our main query: <br> | |
<cfoutput>#newReasonList#</cfoutput> | |
<br><br><br><br> | |
What if we have an empty query? | |
<br> | |
<cfscript> | |
// Build a fake empty query. | |
HospitalVisits_Empty = queryNew( | |
"patientID, Reason_For_Visit", | |
"integer, varchar" | |
); | |
writeDump(HospitalVisits_Empty); // What's in our query? | |
emptyQueryReasonList = listChangeDelims( listRemoveDuplicates( valuelist(HospitalVisits_Empty.Reason_For_Visit, "|"),"|",true ),", ","|",false ) ; | |
</cfscript> | |
This is our empty de-duped list: <cfoutput>#emptyQueryReasonList#</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment