Wednesday 25 September 2013

String Comparison in WHERE clause

1) An easier solution is to use INSTR:

Assume  :P5_USER_ID_LIST = ' ,45,4932,20,19,'
SELECT * FROM users u 
WHERE instr(',' || :P5_USER_ID_LIST ||',' ,',' || u.user_id|| ',', 1) !=0;

Tricks:
',' || :P5_USER_ID_LIST ||',' to make your string ,45,4932,20,19,
',' || u.user_id|| ',' to have i.e. ,32, and avoid to select the 32 being in ,4932, 

Using string_to_table function in WHERE clause

1) Put the IDs into an Apex collection in a PL/SQL process:
    Assume :P5_USER_ID_LIST =  '45,4932,20,19'
declare
    array apex_application_global.vc_arr2;
begin
    array := apex_util.string_to_table (:P5_USER_ID_LIST, ',');
    apex_collection.create_or_truncate_collection ('P5_ID_COLL');
    apex_collection.add_members ('P5_ID_COLL', array);
end;

2) Then change your query to:

SELECT * FROM users u WHERE u.user_id IN 
(SELECT c001 FROM apex_collections
 WHERE collection_name = 'P5_ID_COLL')

As simple as that...

Refer to current column value in oracle apex report.

Do you know? we can refer to current column value in oracle apex report->column attributes section.
For example there is a column of which we would like to display as a dropdown whose list of values is a SQL query containing a where clause on another column value.

Then you will need to follow these steps :

1. You will need to add htmldb_util.savekey_num(q.id) Filter as the first column in your select statement (for example: q.id column name)

2. In the reports attribute of the report, uncheck the display checkbox so this column is not displayed.

3. Change the desired column attribute to be of type select list based on LOV

4. In your LOV add the where clause restriction where q.id = htmldb_util.keyval_num
(this will then restrict the LOV to the question id of the row the LOV is displayed)

5. Done....
Hope this helps to every one....

Universal Theme - Side Navigation Menu Child Entry Icon Alignment

Hi, There is an issue with the Side Navigation Menu Child Entry Icon Alignment in Universal theme if you are using APEX 5.1 or prior vers...