BAQ ~List~ handling

Are there any BAQ tricks to return a tilde delimited list column?

For example, I believe this is valid SQL (being SaaS I cannot test) that should return tilde delimited column of VendorNums.

BAQ complains ‘possible sql injection’ probably because SELECT and or FOR XML are not supported in calculated columns.

SELECT 
	[VendPart].[Company] as [VendPart_Company], 
	[VendPart].[PartNum] as [VendPart_PartNum], 
	(STUFF  
    (  
        (  
        SELECT DISTINCT '~'+ CAST(V.VendorNum AS VARCHAR(MAX))  
        FROM Erp.VendPart as [V], Erp.Part as [P]
        WHERE V.PartNum = P.PartNum AND P.PartNum = VendPart.PartNum
        FOR XML PATH('')  
        ),1,1,''  
    )) as [Calculated_VenNums] 

FROM Erp.VendPart as [VendPart]
GROUP BY	
    [VendPart].[Company], 
	[VendPart].[PartNum]

Is there another way to return list columns in BAQ?

PS - I believe I’ve seen mentioned on here that SQL List functions exist in the database. If so, are these accessible in a BAQ?

PSS - Sooo wish I had a copy of the db schema.

Search for string_agg should be what you need

4 Likes

Thanks.
To self: It’s been there since 2017, Josh
tune in come on GIF by Discovery Europe

3 Likes

I think there is a stored procedure for use too.

@Banderson ?

Yeah, to join fields, string_agg() is the way to go. XML path is the old hack and it disallowed in newer versions of Epicor.

@klincecum I think you’re thinking of splitting delimited strings, and that’s Ice.Entry().

2 Likes

Can we use ERP.ListEntry() T-SQL function in BAQ?

Here’s where I saw it mentioned:

PS - any on-prem’rs wanna share a db create script or .dacpac of 2025.1 db?

1 Like

You should be able to. The scalar function is there. I’ve never use it myself.

2 Likes

Thanks. Now to guess at it’s signature cuz I’m Saas-blind
season 1 friends GIF

image

Looks like it’s the same is Ice.Entry()
image

2 Likes

Thanks. I thought maybe you were referring to c# w Ice.Entry().

Any idea whether @idx is zero or 1 based? Guessing 1-based.

0 based.

1 Like

I thought there was one for the other way.

That’s string_agg().

What am I missing here?

here’s the list of scalar functions. (the blurred out one is one we added)

1 Like

stop making me jealous @Banderson and send .dacpac. :wink:

and Kevin:

/jk/jk

Conan Obrien I Dont Know What That Is GIF by Team Coco

might need some help do to that.

looks like theres not a entriesToList() that explodes delim string to rows. That’d be cool.

Yeah, I don’t see anything like that, and I’m pretty sure it would break the BAQ engine. Adding in columns dynamically isn’t something historically that’s been a capability.

1 Like

Probably won’t work, but a .dacpac is a file made by SQLPackage utility (built-into SSMS, SSDT, ADS, & MSSQL VSCode Extension) which can be used to create an empty database. Basically it’s the publish output of a VS Database Project.

It’d be swell if Epicor made, say EDU db backup available for SaaS customers to install on-prem. Some of us are at home in T-SQL (even if we forget the newish features like STRING_AGG [:rolls-eyes-at-self])

1 Like

Maybe nothing, I just swear I read something about it.

I”ve been wrong before, I’m sure it can happen again.

1 Like

Hi Josh,
If I understand correctly what you are trying to achieve, there is actually a SQL function to extract one value in an Epicor ~-separated List.
This is PARSENAME(). It uses dot as default separator but you can easily replace the ~ symbol by dots before running PARSENAME(). So you will be able to easily extract one value (or more) in an Epicor list like this.
Sorry I’m French so if this isn’t clear, please let me know.
I often use this kind of syntaxes for BI analysis on Epicor with a third-party tool, it works like a charm.

Regards,
William

2 Likes