Posts

Showing posts from 2015

Merge In ORACLE

Image
Merge is a combination of insertion and updation.We normally do updation when ever a match is found and do insertion when not found.Merge statement allow both in a single statement. 4 Things we need to find before start doing merge 1) To which table data should merge 2)What is the matching criteria 3)What should do when a match found 4)What should do when no match found Suppose we have a table called Employee_2.We need to fill this table with the data from table Employee .As Employee_2 table has some data we have to check whether same employee name eist in Employee_2 table as that in Employee table.If a match in Employee name found update the Employee_2 table with the data in Employee table for that row otherwise insert the entire row into Employee_2 table. Below shows the Employee_2 table with initial data. Below is the Employee table from which we are going to migrate We are going to migrate now.As of now we need records which has Dept_Id in 1 or 2.If there is a...

Find out Vowels in a String in Oracle

We can find out the number of Vowels in a string by using normal string functions in Oracle. Suppose  India Is My Country  is the string . SELECT length( 'India Is My Country' )- length( REPLACE (translate( ' India Is My Country ' , 'aeiouAEIOU' , '          ' ), ' ' )) FROM dual. The logic behind is just subtract the length of non-vowel characters from length of whole string. Translate command will translate the occurrence of vowels into space. Now the string does not contain any vowels. Now remove all spaces from the string .Now you have a string which does not have vowels or space. Remove length of this string from total length. This is the number of vowels in the given string