You are not logged in.
Hi,
I have a parameter datasource and would like to do a foreach expression on the return value of a parameter.
I am referring to the jsp-2_1-fr-spec.pdf for jsp-000245 where it's given as syntax <c:forEach></c>
It did not work for me just dropping that in, although that was expected.
my faulty code:
with combined_data as (
select $P!{key1} from dual
)
/*</rs:cte>*/
select (/*<c:forEach value="#{key1}"></c>*/) from combined_data
note that $P!{key1} is returning a list of strings ala 'string1', 'string2'
------------
so here's what i did that got me to this point in the first place.
Parameter window
DATASOURCE 2
I decided to concatenate 2 required columns into one and return that because the parameter will only return the first column values
Main window
DATASOURCE 1
Back to the main query: I do `select $P!{values} from dual` which results in string literal column names. i try to unpivot the data, turns out unpivot can't work with stirng literal names. I thought the expression language had foreach but I couldn't figure out how to use it, and there are too many files that have that exact string
~~what I do now is turn it into XMLTable, now that I learned about that function~~
Actually, I cannot load that XML for some reason in computed column. I am guessing, because maybe the variable only exports java.lang.String datatype. I will make a separate topic for that.
It would be nice to know if forEach is supported.
Last edited by zitot (2024-11-02 03:54:43)
Offline
Hello,
foreach expressions are not supported in queries. Functions that go beyond plain-sql are best avoided.
Although if it is a db-specific feature it might be best to create a procedure on the db itself and using
the query to call said procedure.
Kind regards,
Adrian
Offline