Monday, 26 August 2013

Retrieve dynamicaly the columns of a records

Retrieve dynamicaly the columns of a records

my sql statement is built dynamicaly. I have something like
strSql := 'select name, tel, adress, activity_id as filtre_1, country_id
as filtre_2, ... from ... where ...'
I can have 1 to n filter, and filter_1 can be activity_id as country_id,
the order in not important.
How can I retrieve the values of filter_1, filter_2 as I don't know how
many the request send back?
Normaly to retrieve the values, I do :
FOR rowResult IN EXECUTE strSql LOOP name := rowResult.name tel :=
rowResult.tel adress := rowResult.adress filtre_1 := rowResult.filtre_1
filtre_2 := rowResult.filtre_2 END LOOP;
As this cannot be done, I like to do something like
FOR rowResult IN EXECUTE strSql LOOP name := rowResult.name tel :=
rowResult.tel adress := rowResult.adress filtre_1 := rowResult("filtre_1")
filtre_2 := rowResult("filtre_2") END LOOP;
but rowResult(stringfield) do not exist.
Is somebody have an idea?
Thanks

No comments:

Post a Comment