When I create a Select list based on a SQL query it asks for 2 columns. For example I did something like: select itemcode, itemname from items
in a select list called LST_ITEMS. I need to retrieve or get both of the values when I call it with :LST_ITEMS.
Asked
Active
Viewed 3,323 times
1

Alex Sáenz
- 25
- 2
- 4
2 Answers
1
You can write query as:
select itemname display_value,
itemcode || ':' || itemname return_value
from items
After that you will get combined value in :LST_ITEMS
variable. You can parse it in PL/SQL code further. For example:
declare
code number;
name varchar2(100);
begin
code = substr(:LST_ITEMS, 1, instr(:LST_ITEMS, ':') - 1);
name = substr(:LST_ITEMS, instr(:LST_ITEMS, ':') + 1);
end;

Dmitriy
- 5,525
- 12
- 25
- 38
-
Apex considers as display value the first item in your query and return value as the second, so your query should be like this `select itemname display_value, itemcode || ':' || itemname return_value from items ` – Cristian_I Nov 16 '15 at 16:32
-
@Cristian_I Thanks, I often forget about that. – Dmitriy Nov 16 '15 at 16:39
1
You Can Get That Using Javascript Dynamic Action Like so
$s('P1_Display_Val',apex.item("LST_ITEMS").displayValueFor("1"));
This copy the display value of item "LST_ITEMS" (with return value = 1) to item "P1_Display_Val". either 1 was the selected value or not.

Saddam Meshaal
- 532
- 3
- 13
- 30