Thursday, September 16, 2010

A Nice & Meaningful Message.....


















Don't ask for a lighter load, but pray god for a stronger back.




Delicious add to del.icio.us saved by 0 users

Inside the Wave...















Delicious add to del.icio.us saved by 0 users

Monday, September 13, 2010

Wonderful Definitions



School 

A place where Parents pay and children play 
     
Life Insurance 

A contract that keeps you poor all your life
so that you can die Rich.
 
Nurse: 

A person who wakes you up to give you sleeping pills.

Marriage 

It's an agreement in which a man loses his bachelor degree and a woman gains her masters.. 
 
Divorce 

Future tense of Marriage.
 
Tears 

The hydraulic force by which masculine willpower is defeated by feminine waterpower. 
 
Lecture
An art of transferring information from the notes of the Lecturer to the notes of  the students without passing through "the minds of either" 
 
Conference 

The confusion of one man multiplied by the number present. 
 
Compromise 

The art of dividing a cake in such a way that everybody believes he got the biggest piece 
 
Dictionary 

A place where success comes before work 
 
Conference Room 

A place where everybody talks, nobody listens and everybody disagrees later on 
 
Father 

A banker provided by nature 
 
Criminal 

A person no different from the rest 
...except that he/she got caught 
 
Boss 

Someone who is early when you are late and  late when you are early
 
Politician 

One who shakes your hand before elections and
your Confidence after 
 
DOCTOR 

A person who holds your ills by pills, and kills you by bills. 
 
Classic 

Books, which people praise, but do not read. 
 
Smile 

A curve that can set a lot of things straight. 
 
Office 

A place where you can relax after your strenuous home life. 
 
Yawn 

The only time some married men ever get to open their mouth. 
 
Etc. 

A sign to make others believe that you know more than you actually do. 
 
Committee 

Individuals who can do nothing individually and sit to decide that nothing can be done together. 
 
Experience 

The name men give to their mistakes. 
 
Atom Bomb 

An invention to end all inventions. 
 
Philosopher 

A fool who torments himself during life, to be wise  






Delicious add to del.icio.us saved by 0 users

Saturday, August 28, 2010

CHECK CONSTRAINTS ON SYSDATE IN ORACLE


RESTRICTIONS ON CHECK CONSTRAINTS

I.We cannot specify a check constraint for a view. However, you can define the view using the WITH CHECK    OPTION clause, which is equivalent to specifying a check constraint for the view.
II.The condition of a check constraint can refer to any column in the table, but it cannot refer to columns of other        tables.
III.Conditions of check constraints cannot contain the following constructs:


  1. Subqueries and scalar subquery expressions
  2. Calls to the functions that are not deterministic (CURRENT_DATECURRENT_TIMESTAMPDBTIMEZONELOCALTIMESTAMP SESSIONTIMEZONE,   SYSDATESYSTIMESTAMPUID,  USER, and USERENV)
  3. Calls to user-defined functions
  4. Dereferencing of REF columns (for example, using the DEREF function)
  5. Nested table columns or attributes
  6. The pseudocolumns CURRVALNEXTVALLEVEL, or ROWNUM
  7. Date constants that are not fully specified
So from the above detail its quite clear that we can not write any comparison with SYSDATE in check constrains..

Now imagine a situation that we are having one table and in that table we want some validation. The requirement is that we are taking Date Of Birth from the user and we want that only that user's details can reside inside our table who is older then 18 years else his insert should not take place.

So for this validation we have to write one trigger to take care of this situation.




/*This trigger will fire on every insert on table name TABLE_NAME and check that the date inserted in DOB_COLUMN_NAME column is greater than the difference of SYSDATE and inserted value by 18 and accordingly either it will allow the data to go inside the table or abort the transaction. :NEW and :OLD are co-relation identifiers used to check for the value inserted, updated or deleted. It will work only in triggers*/


CREATE OR REPLACE TRIGGER PROJECT_NAME_AGE_CHECK_TRIGGER
 AFTER INSERT AFTER UPDATE ON TABLE_NAME
 FOR EACH ROW
 DECLARE
 V_AGECHECK EXCEPTION;
 BEGIN
 IF MONTHS_BETWEEN(SYSDATE,:NEW.DOB_COLUMN_NAME)/12 < 18 THEN
 RAISE V_AGECHECK;
 END IF;
 EXCEPTION
 WHEN V_AGECHECK THEN
 RAISE_APPLICATION_ERROR(-20001,'YOU ARE MINOR') ;
 END;







Delicious add to del.icio.us saved by 0 users

A Glass Jar And Two Cups Of Tea



 Glass Jar And Two Cups Of Tea

A life reforming Story


A time comes in life when we desire to do everything very fast ,to get everything as soon as possible, and then twenty-four hours a day seems less to have that, at that time we should remember this life reforming story, "A glass jar and two cups of tea".
A professor of philosophy came in the classroom and told the students that he is going to teach an important lesson of life. 
He brought along a big glass jar and kept it on the table and then he began putting table tennis balls in the jar until the jar was full enough, not to take any more balls.
He asked the students, “Is the jar completely filled?”
Students shouted, “Yes.”
Then Professor started putting small stone fillings in the jar. He shook the jar and a good amount of stone filling were adjusted in the jar.
The Professor asked again, “Is the jar completely filled now?”
Students shouted once again, ”Yes.”
 Then the Professor started pouring sand slowly in that jar.
Sand made its way into the jar where it was possible.
 Now students laughed at their innocence.
 Professor asked again “Now this jar is completely filled, isn’t it?”
Students said,” Yes, Now it is full.”
Then professor took two cup of tea and poured into the jar.The tea made its place in the jar and was soaked by the sand.
Now Professor started explaining everything in a serious voice.
Consider this glass jar as your life. The most important things are table tennis balls i.e. God, family, kids, friends, Health and hobbies.
Small stone fillings symbolises your job, car, house etc.
 Sand means some more small useless things like estrangement, misunderstandings, quarrels etc.
Now if you fill the glass jar with sand first then there will be no space left for balls and stone fillings. Or if you put stone fillings first then there will be no room for table tennis ball, but still that could hold sands.
Same philosophy applies to life.
If you are going behind those little things and destroying you energy on them then you will not have much time to spend on the necessary and important things.
What is important for the happiness of soul? First decide that. Play with your children, put water in the garden, and go for morning walk with wife.Throw out all useless stuff from home; go for medical check-up regularly.Worry about table tennis balls first, that is most important. First decide what is important? Rest all is send only.
Students were listening attentively.
 Suddenly a student asked, “Sir, but you have not told anything about those two cups of tea." What is that meant for?
Professor smiled and said,” I was expecting this question for a long time.”
The answer is, “no matter how busy, complete and satisfied your life seems, but there must be place for sharing two cups of tea with your special friend.
So consider this story seriously and try to implement it in your life to make your life happy and peaceful.



Delicious add to del.icio.us saved by 0 users

Friday, August 20, 2010

Armstrong number also called Narcissistic numbers.





Definition: 

 Armstrong numbers are the sum of their own digits to the power of the number of digits.

In other words

An Armstrong number is an n-digit base b number such that the sum of its (base b) digits raised to the power n is the number itself.

And according to wikipedia 

In recreational number theory, a narcissistic number (also known as a pluperfect digital invariant (PPDI), an Armstrong number or a plus perfect number) is a number that is the sum of its own digits each raised to the power of the number of digits. This definition depends on the base b of the number system used, e.g. b = 10 for the decimal system or b = 2 for the binary system or 

For Example:
There are just four numbers, after unity, which are the sums of the cubes of their digits:


153 = 13 + 53 + 33
370 = 33 + 73 + 03
371 = 33 + 73 + 13
407 = 43 + 03 + 73.

1.Program to check for Armstrong Number

#include

//Prototype of all the function being used in the program

int number_of_digits(int give_number);
int check_armstrong(int given_number,int number_of_digits);
int power(int temp_var,int number_of_digits);

//Main function starts

int main()
{
int give_number,no_of_digits,flag;
printf("\nEnter the number you want to check for Armstrong\n");
scanf("%d",&give_number);
no_of_digits=number_of_digits(give_number);
flag=check_armstrong(give_number,no_of_digits);
flag?printf("\n%d is Armstron\n",give_number):printf("\n%d is not Armstrong number\n",give_number);
return 0;
}

//Function to check how many degits are there in the given number

int number_of_digits(int given_number)
{
int count=0,temp;
while(given_number>0)
{
temp=given_number%10;
given_number=given_number/10;
count++;
}
return count;
}

//Function to check that the number is Armstrong or not

int check_armstrong(int given_number,int number_of_digits)
{
int temp_var,clone_number,regenerate_number=0;
clone_number = given_number;
while(clone_number>0)
{
temp_var=clone_number%10;
regenerate_number=regenerate_number + power(temp_var,number_of_digits);
clone_number=clone_number/10;
}
if(regenerate_number==given_number)
return 1;
else
return 0;
}

//Function the calculate the power same as pow() function

int power(int temp_var,int number_of_digits)
{
int cal_power=1,i;
for(i=0;i
cal_power=cal_power*temp_var;
return cal_power;
}

2.Program to find Armstrong Number in a given range 

#include

//Prototype of all the function being used in the program

int number_of_digits(long int give_number);
int check_armstrong(long int given_number,long int number_of_digits);
int power(long int temp_var,long int number_of_digits);

//Main function starts

int main()
{
long int give_number,no_of_digits,flag;
printf("\n Enter the number you want to check\n");
for(give_number=1;give_number<9999999;give_number++)
{
no_of_digits=number_of_digits(give_number);
flag=check_armstrong(give_number,no_of_digits);
flag?printf("\nNumber %ld is Armstron\n",give_number):printf("");
return 0;
}
}

//Function to check how many degits are there in the given number

int number_of_digits(long int given_number)
{
long int count=0,temp;
while(given_number>0)
{
temp=given_number%10;
given_number=given_number/10;
count++;
}
return count;
}

//Function to check that the number is Armstrong or not

int check_armstrong(long int given_number,long int number_of_digits)
{
long int temp_var,clone_number,regenerate_number=0;
clone_number = given_number;
while(clone_number>0)
{
temp_var=clone_number%10;
regenerate_number=regenerate_number + power(temp_var,number_of_digits);
clone_number=clone_number/10;
}
if(regenerate_number==given_number)
return 1;
else
return 0;
}

//Function the calculate the power same as pow() function

int power(long int temp_var,long int number_of_digits)
{
long int cal_power=1,i;
for(i=0;i
cal_power=cal_power*temp_var;
return cal_power;
}

Note: On compiling if you get any error than check it may that html has converted the lass than and greater than symbol as its own tags and also please do proper formatting.  This program  has been compiled and checked on GCC.








Delicious add to del.icio.us saved by 0 users

 

Never feel bad if u loose some thing or do not get expected because "There is always a better option"