I need to concatenate the result of a subquery in a file based model (i.e. with ms access) and following the suggestions I found here, I could define a function to use in the query.
I try that in the SQL scratch pad but nothing happens...
Function Coalsce(strSQL As String, strDelim, ParamArray NameList() As Variant)
Dim db As Database
Dim rs As DAO.Recordset
Dim strList As String
Set db = CurrentDb
If strSQL <> "" Then
Set rs = db.OpenRecordset(strSQL)
Do While Not rs.EOF
strList = strList & strDelim & rs.Fields(0)
rs.MoveNext
Loop
strList = Mid(strList, Len(strDelim))
Else
strList = Join(NameList, strDelim)
End If
Coalsce = strList
End Function
select switch(Coalsce(SELECT DISTINCT ', ' + obj_phase2.name as [text()]
FROM ((((t_object obj_ds2
INNER JOIN t_connector co2
ON (obj_ds2.object_id = co2.start_object_id))
INNER JOIN t_object obj_adu2
ON (co2.end_object_id = obj_adu2.object_id
AND obj_adu2.Stereotype='EUM_ADU'))
LEFT JOIN t_object obj_prx2
ON (obj_prx2.Classifier_guid = co2.ea_guid))
LEFT JOIN t_connector pc2
ON (obj_prx2.Object_ID = pc2.Start_Object_ID AND pc2.Stereotype = 'trace'))
LEFT JOIN t_object obj_phase2
ON (pc2.End_Object_ID = obj_phase2.object_id)
WHERE obj_ds2.Stereotype = 'EUM_Data-Stream' AND obj_ds2.Object_ID = 13919)='', '',
1=1, 'teste') as [test]
from t_object
Is this possible?