Development notes, tips and tricks for Oracle's HTML DB

Tuesday, July 13, 2004

Change color of report cell based on cell value

This is from the following post: http://forums.oracle.com/forums/thread.jsp?forum=137&thread=230789&message=651450&q=666f726d61742063656c6c#651450


select serial,
'<div style="width:100%;height:100%;background:'||
case when purchase_price > 5000 then 'red' else 'green' end
|| '">'||purchase_price||'</div>' purchase_price,
brand
from hardware

Monday, July 12, 2004

Create users programmatically

See: Htmldb forum


In a nutshell:
select :WORKSPACE_ID from dual;

...in the SQL Workshop's SQL Command Processor to determine your workspaces workspace_id (also known as a security_group_id internally). assuming that query came back with a value of 12345, you could then run a block like...


BEGIN
wwv_flow_api.set_security_group_id(p_security_group_id=>12345);

wwv_flow_fnd_user_api.create_fnd_user(
p_user_name => 'regular_user',
p_email_address => 'myemail@mydomain.com',
p_web_password => 'regular1') ;

wwv_flow_fnd_user_api.create_fnd_user(
p_user_name => 'developer_user',
p_email_address => 'myemail@mydo.com',
p_web_password => 'dev1',
p_developer_privs => 'ADMIN') ;

end;
/

Highlight rows in report based on column values.

You will have to create a report template for this one.
Let's say you have a report based on "SELECT * FROM emp" and you want to highlight the rows where the salary is greater than 2000.
Create a report template (i usually just copy an existing one and modify it.)
For Row Template 1, specify the look for your highlighted row: <td bgcolor="yellow" #ALIGNMENT#><b>#COLUMN_VALUE#</b></td>
Here i made the background yellow and also made the text bold.
In Row Template 1 Expression enter the PL/SQL expression that determines the condition for using row template 1:
#SAL# > 2000
(Note that column substitution variables are enclosed by '#' -- see side bar on the right side of report template wizard.)
Now, in Row Template 2 specify the look for your un-highlighted rows (i just left out the bgcolor and bold tags):
<td #ALIGNMENT#>#COLUMN_VALUE#</td>
Now enter the condition for displaying the second template:
#SAL# <= 2000.

In your report page, navigate to the Report Attributes tab and select your newly created report template in the 'Layout and Pagination' section.

That's it.

Wednesday, July 07, 2004

Dynamically highlight rows in report.

To dynamically highlight rows in a htmldb report you need to use javascript. I found a nice script to do this at www.dhtmlshock.com (thanks Shivaji.)



1.
Create or alter a report template. In the 'Before Each Row' section paste:

<tr onMouseOver="cOn(this);" onMouseOut="cOut(this);">

In the 'After Each Row' section paste:

</tr>

2.
In the report page definition click on the page attributes and navigate to the HTML Header section. Paste the following script into this section:

-----------------------------------

<script language="JavaScript1.2">

/*
To comply with copyright please download the script from here: www.dhtmlshock.com
*/

</script>

-----------------------------------

3.
In the report region navigate to the 'Layout and Pagination' section and select the report template you altered above.

4.
Now the report row will get highlighted when you mouse over. If you want to change colors, edit the color attributes in the javascript.