FOR cur IN (SELECT process_Id FROM tbl_process) LOOP SELECT (MAX(TO_NUMBER(substr(p.old_id, instr(p.old_id, '_', -1) + 1)))) INTO new_id FROM tbl_process p WHERE process_Id = cur.process_Id; IF new_id IS NULL THEN new_id := cur.process_Id || '_1'; ELSE new_id := new_id + 1; new_id := cur.process_Id || '_' || new_id; END IF; END LOOP;
Author Archives: admin
NULL or BLANK fields check in Oracle
If you want a query which returns rows in column containing NULL or empty space then the using NULL alone in where clause will not return empty space rows. So the query should be altered as below
Actual Query
SELECT COUNT (*) FROM TABLE WHERE COL_NAME IS NULL;
Altered Query
SELECT COUNT (*) FROM TABLE WHERE trim(COL_NAME) IS NULL
(or)
Altered Query
SELECT COUNT (*) FROM TABLE WHERE COL_NAME IS NULL OR LENGTH(TRIM (COL_NAME)) = 0
Grouping and Sub Grouping Summing
Rows as Displayed in Screen
Rows from Database
Rows grouping Logic
List<RowsBean> outputList = RowsToBeDisplayedList; HashMap<String, ArrayList> superGroupPoints = new HashMap<String, ArrayList>(); HashMap<String, EWMDecimal> subGroupTotalPoints = new HashMap<String, Integer>(); String groupName = null; String prevGroupName = null; String superGroupName = null; String prevSuperGroupName = null; List<Map> subGroupPointsList = new ArrayList(); //Compute grouping totals Iterator itr = cicCarryPointsList.iterator(); while(itr.hasNext()) { RowsBean rowBean = (RowsBean) itr.next(); superGroupName = rowBean.getSuperGroupName(); groupName = rowBean.getGroupName(); //Addition of points summed at Group Level if ((prevGroupName != null && !prevGroupName.equals(groupName)) || (prevSuperGroupName != null && !prevSuperGroupName.equals(superGroupName))) { subGroupPointsList.add(subGroupTotalPoints); subGroupTotalPoints = new HashMap<String, Integer>(); } //Rows at GroupLevel with Sub Groups should be added only when Super Group Changes if((prevSuperGroupName != null && !prevSuperGroupName.equals(superGroupName))) { superGroupPoints.put(prevSuperGroupName, (ArrayList) subGroupPointsList); subGroupPointsList = new ArrayList(); } Integer subGroupValPoints = rowBean.getPoints(); //If InvGrp level Map exists if (subGroupTotalPoints.get(groupName) != null) { Integer currSummedPointsAtGrpLevel = subGroupTotalPoints.get(groupName); currSummedPointsAtGrpLevel = currSummedPointsAtGrpLevel.add(subGroupValPoints); subGroupTotalPoints.put(groupName, currSummedPointsAtGrpLevel); } else { subGroupTotalPoints.put(groupName, subGroupValPoints); } //Incase of last element the loop exits without adding last summed element //To prevent that we add it with out current and prev comparison if(!itr.hasNext()) { subGroupPointsList.add(subGroupTotalPoints); superGroupPoints.put(superGroupName, (ArrayList) subGroupPointsList); } prevSuperGroupName = superGroupName; prevGroupName = groupName; }
Retrieval of Rows for Displaying in Screen
String currentSuperGrouping = ""; String prevSuperGrouping = ""; String currGrouping = ""; String prevGrouping = ""; String Value = ""; for (RowsBean rowBean : outputList) { currentSuperGrouping = rowBean.getSuperGroupName(); currGrouping = rowBean.getGroupName(); //Level 1 - New Super Group Creation //New Super Group should be created when ever prevSuperGrouping and currentSuperGrouping are different if (!currentSuperGrouping.equals(prevSuperGrouping)) { . . Super Group Row Creation HTML Code Goes Here . . . } //Level 2 - Group addition under Super Group //New Group should be created when ever SuperGroup or Group Changes if(!currGrouping.equals(prevGrouping) || !currentSuperGrouping.equals(prevSuperGrouping)) { //Taking Group Level Maps List ArrayList GroupLevelMapList = superGroup.get(rowBean.getGroupName()); Iterator itr = GroupLevelMapList.iterator(); //Taking the Summed up value at Group Level from List while (itr.hasNext()) { Map ii = (Map) itr.next(); Points = ii.get(rowBean.getGroupName()); } . . Group Row Creation HTML Code Goes Here . . . } //Level 3 - Sub Group Rows Addition //Rows will be added if(currentSuperGrouping.equals(rowBean.getGroupName) || currentSuperGrouping.equals(rowBean.getSubGroupName)) { . . Sub Group Row Creation HTML Code Goes Here . . . } prevSuperGrouping = currentSuperGrouping; prevGrouping = currGrouping; }
. as the delimiter with String.split() in java
java.lang.String.split splits on regular expressions, and . in a regular expression means “any character”.
This Wont Work
String[] words = line.split(".");
This Works
String[] words = line.split("\\.");
Eclipse ANT Build Error
- Right Click on build.xml
-
Go to “Run As” >> “External Tools Configurations…”
-
It shall open new window
-
Go to JRE tab
-
Select proper JRE if missing (sometimes jre tabs shows error mark on that.)
How to check table used in Package
select distinct ac.name,ac.line from all_source ac where ac.OWNER ='DBOWNERNAME' and lower(ac.TEXT) like '%TABLE_NAME%';
How to compare two columns in Excel
formula to give you a comparison:
=AND(A2:A11=B2:B11)
Enter the formula by pressing Ctrl+Shift+Enter. If done correctly it will appear as the following:
{=AND(A2:A11=B2:B11)}
For a case-sensitive comparison, the equals operator will not work. Instead, the EXACT() function should be used.
{=AND(EXACT(A2:A11,B2:B11))}
VLOOKUP in Excel
VLOOKUP lets you search for specific information in your spreadsheet
Adding the arguments
Now, we’ll add our arguments. The arguments will tell VLOOKUP what to search for and where to search.
The first argument is the name of the item you’re searching for, which in this case is Photo frame. Because the argument is text, we’ll need to put it in double quotes:
=VLOOKUP(“Item 5”
The second argument is the cell range that contains the data. In this example, our data is in A2:B16. As with any function, you’ll need to use a comma to separate each argument:
=VLOOKUP(“Item 5”, A2:B16
Note: It’s important to know that VLOOKUP will always search the first column in this range. In this example, it will search column A for “Item 5”. In some cases, you may need to move the columns around so the first column contains the correct data.
The third argument is the column index number. It’s simpler than it sounds: The first column in the range is 1, the second column is 2, etc. In this case, we are trying to find the price of the item, and the prices are contained in the second column. This means our third argument will be 2:
=VLOOKUP(“Item 5”, A2:B16, 2
The fourth argument tells VLOOKUP whether to look for approximate matches, and it can be either TRUE or FALSE. If it is TRUE, it will look for approximate matches. Generally, this is only useful if the first column has numerical values that have been sorted. Because we’re only looking for exact matches, the fourth argument should be FALSE. This is our last argument, so go ahead and close the parentheses:
=VLOOKUP(“Item 5”, A2:B16, 2, FALSE)
Finding Value of Particular Data
=VLOOKUP("Item 5", A2:B16, 2, FALSE)
Finding Category in Two Columns
=VLOOKUP("Item 4", A2:C16, 3, FALSE)
Finding Matching Data in Two Columns
=VLOOKUP(B2,$A$2:$A$361,1,FALSE)
Filter Tables in System
The Super set column in which the sub set is searched should be added as a second parameter. In our case its B
=VLOOKUP(A2,$B$2:$B$23, 1, FALSE)
Financial Analysis Basis
String Bean in Java
Java Bean Class – EmployeeBean
import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class EmployeeBean { private String Name; private int EmpNo; private int Age; private float Weight; public String getName() { return Name; } public void setName(String name) { Name = name; } public int getEmpNo() { return EmpNo; } public void setEmpNo(int empNo) { EmpNo = empNo; } public int getAge() { return Age; } public void setAge(int age) { Age = age; } public float getWeight() { return Weight; } public void setWeight(float weight) { Weight = weight; } public EmployeeStringBean getStringBean() { EmployeeStringBean objEmpBean = new EmployeeStringBean(); objEmpBean.setName(getName() == null?null:getName().toString()); objEmpBean.setEmpNo(Integer.toString(getEmpNo())); objEmpBean.setAge(Integer.toString(getAge())); objEmpBean.setWeight(getWeight()+""); return objEmpBean; } public static List getStringBeanList(List beanList) { List stringBeanList = new ArrayList(); if (beanList != null) { Iterator itr = beanList.iterator(); while (itr.hasNext()) { EmployeeBean bean = (EmployeeBean) itr.next(); stringBeanList.add(bean.getStringBean()); } } return stringBeanList; } }
String Bean Class – EmployeeStringBean
public class EmployeeStringBean { private String Name; private String EmpNo; private String Age; private String Weight; public String getName() { return Name; } public void setName(String name) { Name = name; } public String getEmpNo() { return EmpNo; } public void setEmpNo(String empNo) { EmpNo = empNo; } public String getAge() { return Age; } public void setAge(String age) { Age = age; } public String getWeight() { return Weight; } public void setWeight(String weight) { Weight = weight; } public EmployeeBean getBean() { EmployeeBean objEmployeeBean = new EmployeeBean(); objEmployeeBean.setName(getName()); objEmployeeBean.setEmpNo(Integer.parseInt(getEmpNo())); objEmployeeBean.setAge(Integer.parseInt(getAge())); objEmployeeBean.setWeight(Float.parseFloat((getWeight()))); return objEmployeeBean; } }