I have two tables:
FirstTable:
code store sent
1000002 Store1 0
1000002 Store2 0
1000002 Store3 0
SecondTable:
code stores
1000002 Store1,Store3
What I want to do is to update FirstTable.sent for an specific code, only for the records present in SecondTable.stores
I have a procedure that takes a string and a separator and builds a resultset from the string. For example if I make the following call:
call sp_csv_as_resultset("A,B,C,D", ",");
I get the following output as a result set:
A
B
C
D
I made that procedure while working in the next update statement, which aims to achieve what I need:
update FirstTable ft
inner join et_sap_magento_store_ids_removals_IF st
on ft.code = st.code
set ft.sent = 1
and ft.sent = 0
and ft.store in (sp_csv_as_resultset(st.stores, ','));
But as you know, you cannot call a stored procedure within a select.
I think a function does not cover my needs either because it cannot return a table or a resultset. Is there a way to do what I need without a design change?