I'm connecting Salesforce Lightning Connect (OData connector) to Teiid.
Behind Teiid is a stored proc called getCustomers which takes 3 paraneters: @field, @operator, @value. For example, getCustomers('Last_Name', '=', 'Porter'). All calls will be read only.
Salesforce cannot call ActionImports and FunctionImports directly, I need them to be EntitySets. Salesforce will be sending the details in OData as "$filter=Last_Name+eq+'Porter'".
I can use a view to ensure an EntitySet is exposed, and the view can call the stored procedure. My question is how do I detect the WHERE clause ($filter=Last_Name+eq+'Porter') and pass it to the stored procedure?
Since the $filter might be a chain of items, I suspect I'll need Dynamic SQL in a virtual procedure, but still have the issue of passing in the OData properties that hit the view.
<metadata type="DDL"><![CDATA[
CREATE FOREIGN PROCEDURE getCustomers(field varchar, operator varchar, value varchar)
RETURNS TABLE (Id, integer, First_Name varchar, Last_Name varchar)
OPTIONS (UPDATECOUNT 0);]]>
</metadata>
<metadata type="DDL"><![CDATA[
CREATE VIEW SalesforceGetCustomers (Id PRIMARY KEY, First_Name varchar, Last_Name varchar)
AS SELECT * FROM (CALL getCustomers('?????','?????','?????')) t;]]>
</metadata>