Posts

Showing posts from 2010

Attractive Reports from SQLPLUS

Image
Hi Everyone, On last Friday, I finished working on automating the generation and mailing of a report. Got to learn few interesting way of generating reports directly from SQLPLUS without any extra effort and would like to share that with you. SPOOL ON/OFF is a common functionality in SQLPLUS to write the output of query into a file. Following lines will send the output to C:\test.txt file. SQL> SPOOL C:\test.txt SQL> select * from employee; ---- assuming that employee is an existing table. SQL> SPOOL OFF Now, we might be interested in creating output report in excel format. Simplest way will be: SQL> SET COLSEP ‘,’ SQL> SPOOL C:\test.csv    --- filename with “.csv” as extension SQL> select * from employee; ---- assuming that employee is an existing table. SQL> SPOOL OFF Open test.csv in excel and you are there. But, what if we need output in HTML format????? ………………Well, there is a way to do this as well in SQLPLUS. See below: SQL > SET MARKUP HT...

Scheduling E-mailer

Image
While authoring a script recently on Windows XP, which was to be executed by windows scheduler, I used a tool called “Blat” (already in use in one of the application in our group) which helps in sending email. On command line, the syntax would be like the one below:   C:\> blat –to <To Email Adress> -from <From Email Adress> -server <SMTP Server Name> -body “<body text>” –subject “<Subject>”   For further details, refer to http://www.blat.net   On Windows XP, I had to write a ".bat" file and schedule it in Scheduled Tasks option. However, on Windows 7, there are in-built option for scheduling of sending emails.   1. Go to Control Panel -> Scheduled Task -> Create Basic Task 2. Specify the Trigger i.e. when to run the task (Date, time, recurrence etc.) 3. In Action, there are 3 options:          Start a Program    // Will execute any program  ...

Sequence.nextval can really deceive you !!

Yes, they really can. Yesterday, I noticed that one of the sequence number (pol_no_seq) in our IH application was giving different set of results when accessed (pol_no_seq.nextval) from two different machines. When I shared this observation with colleagues, the feedback was something like "It does not make sense" and frankly speaking, even I thought the same :-) But, how could I ignore what I actually saw with my own eyes ? I was really puzzled. Given below is the explanation of what and why it happenned, based on my findings from some forums: Definition of pol_no_seq : CREATED 25-JAN-07 LAST_DDL_TIME 25-JAN-07 SEQUENCE_OWNER INSURANCE SEQUENCE_NAME POL_NO_SEQ MIN_VALUE 1 MAX_VALUE 1000000000000000000000000000 INCREMENT_BY 1 CYCLE_FLAG N ORDER_FLAG N CACHE_SIZE 200 LAST_NUMBER 2802765 Results : Machine A : pol_no_seq.nextval->28000146 Machine A : pol_no_seq.nextval->28000147 Machine B : pol_no_seq.nextval->28000412 Machine ...

Things could be very simple in Java !!!!!

So many times, I have seen that there are many ways of achieving a result in java. Most often, we tend to use clasess/methods provided by JDK which is infact a good practise but sometimes, it is actually quite simpler without using them. Hey, what if we have a task of developing a small java program to list the names of all files in a particular directory. It looks like the simplest way of achieveing this would be : Using File.list() or File.listFiles() after confirming that current file is a directory. However, there could be another simpler way which does not use utility methods of File class: public class dirList { public static void main(String args[]) { for (int i=0; i<args.length;i++) { System.out.println(args[i]); } } } Now, compile and run this program dirList from the particualr directory whose listing is to be done. The argument to be passed is asterisk (*) .. i.e. java dirList * This would give us desired result. Actually, * in...