OracleArea51 Blog
Serving Oraclelites Globally ...
Recently I came across a scenario where I have to validate the key flexfield segments passed and derive the id for it.Below generic routine helped me to achieve that.
http://oraclearea51.com/code/code-snippets/plsql/convert-key-flexfield-to-id-in-oracle-apps_11.html
This is an eBook from Chola Global Authored by Sudhakar Mani and Aarthi Sudhakar.This book guides the readers to build a Master Detail Page which Mimics the Standard Oracle Forms. Free support for the readers is available at OracleArea51 Forums. Contact admin@cholagls.com for any queries
This is an eBook from Chola Global Authored by Sudhakar Mani and Aarthi Sudhakar.This book guides the readers to perform a VO Extension on Supplier Page. Free support for the readers is available at OracleArea51 Forums. Contact admin@cholagls.com for any queries.
| Create Department table script |
1
2
3
4
5
6
|
CREATE TABLE "DEPT"
( "DEPTNO" NUMBER(2,0),
"DNAME" VARCHAR2(14 BYTE),
"LOC" VARCHAR2(13 BYTE),
PRIMARY KEY ("DEPTNO")
)
|
| Create Employee Table Script |
1
2
3
4
5
6
7
8
9
10
11
|
CREATE TABLE "EMP"
( "EMPNO" NUMBER(4,0) NOT NULL ENABLE,
"ENAME" VARCHAR2(10 BYTE),
"JOB" VARCHAR2(9 BYTE),
"MGR" NUMBER(4,0),
"HIREDATE" DATE,
"SAL" NUMBER(7,2),
"COMM" NUMBER(7,2),
"DEPTNO" NUMBER(2,0),
PRIMARY KEY ("EMPNO")
)
|
| Create Code |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
public void createEmployee()
{
OAViewObject vo = (OAViewObject)getEmployeeFullVO1();
// Per the coding standards, this is the proper way to initialize a
// VO that is used for both inserts and queries. See View Objects
// in Detail in the Developer's Guide for additional information.
if (!vo.isPreparedForExecution())
{
vo.executeQuery();
}
Row row = vo.createRow();
vo.insertRow(row);
// Required per OA Framework Model Coding Standard M69
row.setNewRowState(Row.STATUS_INITIALIZED);
}
|
| Cancel Button Code |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
if (pageContext.getParameter("Cancel") != null)
{
am.invokeMethod("rollbackEmployee");
// Indicate that the Create transaction is complete.
TransactionUnitHelper.endTransactionUnit(pageContext, "empCreateTxn");
pageContext.forwardImmediately("OA.jsp?page=/oracle/apps/fnd/framework /toolbox/labsolutions/webui/EmpSearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
true, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
|
| How to search a view object row set for a single selected object so that the entity object can be deleted. |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
public void delete(String poHeaderId)
{
// First, we need to find the selected purchase order in our VO.
// When we find it, we call remove( ) on the row which in turn
// calls remove on the associated PurchaseOrderHeaderEOImpl object.
int poToDelete = Integer.parseInt(poHeaderId);
OAViewObject vo = getPoSimpleSummaryVO();
PoSimpleSummaryVORowImpl row = null;
// This tells us the number of rows that have been fetched in the
// row set, and will not pull additional rows in like some of the
// other "get count" methods.
int fetchedRowCount = vo.getFetchedRowCount();
// We use a separate iterator -- even though we could step through the
// rows without it -- because we don't want to affect row currency.
// Note that there are also convenience methods for finding matching rows
// in a view object (see javadoc).
RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter");
if (fetchedRowCount > 0)
{
deleteIter.setRangeStart(0);
deleteIter.setRangeSize(fetchedRowCount);
for (int i = 0; i < fetchedRowCount; i++)
{
row = (PoSimpleSummaryVORowImpl)deleteIter.getRowAtRangeIndex(i);
// For performance reasons, we generate ViewRowImpls for all
// View Objects. When we need to obtain an attribute value,
// we use the named accessors instead of a generic String lookup.
// Number primaryKey = (Number)row.getAttribute("HeaderId");
Number primaryKey = row.getHeaderId();
if (primaryKey.compareTo(poToDelete) == 0)
{
row.remove();
getTransaction().commit();
break; // only one possible selected row in this case
}
}
}
deleteIter.closeRowSetIterator();
}
|
| Generic Routine |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
public static void copyRows(ViewObjectImpl sourceVO, ViewObjectImpl destVO) { if (sourceVO == null || destVO == null) { return; } AttributeDef[] attrDefs = sourceVO.getAttributeDefs(); int attrCount = (attrDefs == null)? 0 : attrDefs.length; if (attrCount == 0) { return; } // Create a row set iterator on the source view object to use for copy operation. RowSetIterator copyIter = sourceVO.findRowSetIterator("poCopyIter"); if (copyIter == null) { copyIter = sourceVO.createRowSetIterator("poCopyIter"); } // Indicates whether a copied row has been inserted into the destination // view object or not boolean rowInserted = false; while (copyIter.hasNext()) { Row sourceRow = copyIter.next(); if (rowInserted) { destVO.next(); } Row destRow = destVO.createRow(); for (int i = 0; i < attrCount; i++) { byte attrKind = attrDefs[i].getAttributeKind(); if (!(attrKind == AttributeDef.ATTR_ASSOCIATED_ROW || attrKind == AttributeDef.ATTR_ASSOCIATED_ROWITERATOR || attrKind == AttributeDef.ATTR_DYNAMIC)) { String attrName = attrDefs[i].getName(); if (destVO.lookupAttributeDef(attrName) != null) { Object attrVal = sourceRow.getAttribute(attrName); if (attrVal != null) { destRow.setAttribute(attrName, attrVal); } } } } // Insert the copied row into the destination view object. destVO.insertRow(destRow); rowInserted = true; } copyIter.closeRowSetIterator(); destVO.reset(); }
|
1 2 3 4 5 6 7 8 9 10 11 12
|
SELECT 'ALTER SYSTEM KILL SESSION ''' || SID || ',' || SERIAL# || ''';' KILL_SQL , MACHINE , ORACLE_USERNAME , OS_USER_NAME , LOCKED_MODE , OBJECT_NAME , OBJECT_TYPE FROM V$LOCKED_OBJECT A , DBA_OBJECTS B , V$SESSION C WHERE A.OBJECT_ID = B.OBJECT_ID AND A.SESSION_ID = C.SID
|