Sunday, January 8, 2012

Oracle : Date to Second Function

Below is sample for oracle function Date to second.


CREATE OR REPLACE FUNCTION TGATE_NI.DATE2TS (m_date_real IN DATE)
RETURN NUMBER IS
                m_unix_start_date_real                              DATE;
                m_days_difference                                     NUMBER;
                timeoutput                                                  NUMBER;
BEGIN
                m_unix_start_date_real := TO_DATE('19700101 0000', 'YYYYMMDD HH24MI');
               m_days_difference := (m_date_real - m_unix_start_date_real);
                timeoutput := (m_days_difference * 86400) - 28800;
                return timeoutput;
END;
/

Wednesday, January 4, 2012

MYSQL : Find duplicate

Just my reference..


select orderid, count(orderid) as totalorder
from order_list
group by orderid
order by totalorder desc;


will listed orderid and total duplicate.

JAVA : I/O Create file

Just a sample code for I/O...



import java.io.File;
import java.io.IOException;
public class CreateFile {
public static void main(String[] args)
{
try{
File file = new File("MyFile.txt"); if (file.createNewFile())
{
System.out.println("Sucess");
}
else
{
System.out.println("Already exist..");
}
}
catch (IOException e)
{
}
}
}

JAVA : OOP - Interface

Below example for Interface programming.


interface calc {
public int calc(int a, int b);
}
public class MyInterface implements calc{
public int calc(int a,int b )
{
return a + b; }
public static void main(String[] args)
{
MyInterface testInterface = new MyInterface();
int total;
total = testInterface.calc(1,7);
System.out.println("Total:" + total);
}
}


Interface only declare the method only. not include with the method body.

Java : OOP - Pass object to Method

Example for Pass object to Method.


class Kira {
void print(String str) {
System.out.println("In Kira :" + str);
}
}
public class test {
public static void main(String[] args) {
//System.out.println("testing 1 2 3....");
Kira kira = new Kira();
kira.print("Testing Kira");
}
}


Save file as test.java. Compile and run.....