Skip to main content

Posts

Showing posts from January, 2011

Chloe in Richmond

How does one get the time difference between two date columns?

Oracle allows two date values to be subtracted from each other returning a numeric value indicating the number of days between the two dates (may be a fraction). This example will show how to relate it back to a time value. Let's investigate some solutions. Test data: SQL> CREATE TABLE dates (date1 DATE, date2 DATE); Table created. SQL> SQL> INSERT INTO dates VALUES (SYSDATE, SYSDATE-1); 1 row created. SQL> INSERT INTO dates VALUES (SYSDATE, SYSDATE-1/24); 1 row created. SQL> INSERT INTO dates VALUES (SYSDATE, SYSDATE-1/60/24); 1 row created. SQL> SELECT (date1 - date2) FROM dates; DATE1-DATE2 ----------- 1 .041666667 .000694444 Solution 1 SQL> SELECT floor(((date1-date2)*24*60*60)/3600) 2 || ' HOURS ' || 3 floor((((date1-date2)*24*60*60) - 4 floor(((date1-date2)*24*60*60)/3600)*3600)/60) 5 || ' MINUTES ' || 6 round((((date1-date2)*24*60*60) - 7 floor(((date1-date2)*24*60*60…

The tricky about using MOd function in oracle/PLSQl

In Oracle/PLSQL, the mod function returns the remainder of m divided by n.
like Mod(m,n) , e..g mod(2,3) =2. 


the trick is, if some of the variable value is null ,the mod(m,n) will give null as  the result.


Let's say m is: 65536+variableA , and if m is null, we just return a null as the result.
We don't need to do like : NVL2( m, mod(m,n), null), just use mod(m,n) as well, it will give the same result

How to get the text of a selection in Html

It is a very common requirement to get the text of a selected box, but,unfortunately,one you submit an action, you can only get the value of a select box.Below is the way to solve this problem(just hint)<html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <script> function ss(){ var obj = document.getElementById("sa"); //selectid var index =obj.selectedIndex; alert(obj.options[index].text); } </script> TODO write content <select name="sa" id="sa" onChange="ss(this.selectedIndex)"> <option value="A">aardvark</option> <option value="B">BBC</option> </select> </body> </html>

Stretch a row if data overflows in jasper reports

It is very common that some columns of the report need to stretch to show all the content in that column. But  if you just specify the property " stretch with overflow' to that column(we called text field in jasper report world) , it will just stretch that column and won't change other columns, so the row could be ridiculous. Haven't find the solution from internet yet. So I just review the properties in iReport one by one and find two useful properties(the bold highlighted in example below) which resolve the problems.   example:
<band height="20" splitType="Stretch"> <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="192" y="0" width="183" height="20"/> <box leftPadding="2"> <pen lineWidth="0.25"/> …

TIOBE Software: Tiobe Index

Glad to know Java is still NO l language used in this world.



Position
Jan 2011Position
Jan 2010Delta in PositionProgramming LanguageRatings
Jan 2011Delta
Jan 2010Status11Java17.773%+0.29%A22

Running A COMMAND in the background

In my super task management tool, I need to open NETBEAN with very short comand like './r net '.
so I added this code:
 /bin/sh "/home/sxu/netbeans-6.9.1/bin/netbeans"

What happened? it open Netbean, but in the shell, it never stop util I close netbeans or press Ctrl+C.
As I really need to run it in the background, need to find a solution. Easy, here it is:

  /bin/sh "/home/sxu/netbeans-6.9.1/bin/netbeans" &

JasperReports - Configuration Reference