Is it possible, using SQL, to output multiple separately defined local variables into one column as separate rows? Eg.
DECLARE var1 INT = 4
DECLARE var2 INT = 5
DECLARE var3 INT = 6
And then select the variables in some manner like
SELECT (var1, var2, var3) AS UserIDs,
('u1', 'u2', 'u3') AS Names
Which would produce the following table:
UserIDs | Names
4 | u1
5 | u2
6 | u3
Pack the values into one string with comma separated. Set the string as parameter and pass it into the SQL statement. Unpack the values and insert the values into a table, Where customerid in (select id from #temp)
To assign a value to a variable, use the SET statement. This is the preferred method of assigning a value to a variable. A variable can also have a value assigned by being referenced in the select list of a SELECT statement.
You can't declare variables in a view.
This cumulative limit is 11 times the per-namespace limit. For example, if the per-namespace limit for SOQL queries is 100, a single transaction can perform up to 1,100 SOQL queries. In this case, the cumulative limit is 11 times the per-namespace limit of 100.
Use Table valued constructor
SELECT *
FROM (VALUES (@var1,'u1'),
(@var2,'u2'),
(@var3,'u3')) tc (UserIDs, Names)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With