$ VAR=/home/me/mydir/file.c $ DIR=$(dirname "${VAR}") $ echo "${DIR}" /home/me/mydir $ basename "${VAR}" file.c
Friday, January 19, 2018
Unix script to extract File Name and Base Path from File Path
Thursday, January 4, 2018
PLSQL Table Type
To avoid SQL Table we can use PLSQL table as given below
DECLARE
TYPE t_record IS TABLE OF VARCHAR (30);
TYPE t_tab IS TABLE OF t_record;
v_tab t_tab := t_tab ( t_record ('1', '2', '3')
, t_record ('A', 'B', 'C')
);
BEGIN
FOR i IN 1 .. v_tab.COUNT
LOOP
DBMS_OUTPUT.put_line (v_tab (i) (1) || v_tab (i) (2) || v_tab (i) (3));
END LOOP;
END;
/
Friday, November 17, 2017
Specified pseudocolumn or operator not allowed here. in package PO_DOCUMENT_CHECKS_PVT
While approving the requisition the follow error may occur.
"Specified pseudocolumn or operator not allowed here. in package PO_DOCUMENT_CHECKS_PVT"
Saturday, June 17, 2017
Monday, February 20, 2017
Script to Add Responsibilities
DECLARE
ln_user_id NUMBER;
ln_resp_id NUMBER;
ln_app_id NUMBER;
CURSOR c1
IS
SELECT responsibility_id,
application_id,
responsibility_name
FROM fnd_responsibility_tl
WHERE responsibility_name IN ( 'Application Developer', 'Functional Administrator','System Administrator')
AND responsibility_name NOT IN
( SELECT DISTINCT rtl.responsibility_name
FROM apps.fnd_compiled_menu_functions cmf,
apps.fnd_form_functions ff,
apps.fnd_form_functions_tl ffl,
apps.fnd_responsibility r,
apps.fnd_responsibility_tl rtl,
apps.fnd_user_resp_groups urg,
apps.fnd_user u
WHERE cmf.function_id = ff.function_id
AND r.menu_id = cmf.menu_id
AND urg.responsibility_id = r.responsibility_id
AND rtl.responsibility_id = r.responsibility_id
AND cmf.grant_flag = 'Y'
AND r.application_id = urg.responsibility_application_id
AND u.user_id = urg.user_id
AND u.user_name = 'KAARTHIB'
AND ff.function_id = ffl.function_id
);
BEGIN
SELECT user_id INTO ln_user_id FROM fnd_user WHERE user_name = 'KAARTHIB';
FOR i IN c1
LOOP
fnd_user_resp_groups_api.insert_assignment (ln_user_id, i.responsibility_id, i.application_id, NULL, SYSDATE, NULL, NULL );
END LOOP;
COMMIT;
END;
/
Script to update Application User Password
DECLARE
v_user_name VARCHAR2(30):=upper('USER');
v_new_password VARCHAR2(30):='PASSWORD';
v_status BOOLEAN;
BEGIN
v_status := fnd_user_pkg.ChangePassword ( username => v_user_name, newpassword => v_new_password );
IF v_status =true THEN
dbms_output.put_line ('The password reset successfully for the User:'||v_user_name);
COMMIT;
ELSE
DBMS_OUTPUT.put_line ('Unable to reset password due to'||SQLCODE||' '||SUBSTR(SQLERRM, 1, 100));
ROLLBACK;
END IF;
END;
/
Friday, February 17, 2017
FRM-10102: Cannot attach PL/SQL library
Assuming you stored all your FMB and PLL files in D:\resource folder (copied from your server).
Add the path D:\resource in the FORMS_PATH registry entry.
Or
Create a Environment variable named FORMS_PATH and add the value D:\resource
You might still face the issue if you didn't download the complete resource folder from your server.
Copying the complete resource folder from server is a time consuming process. Instead copy the required PLL which was shown in the error window. After closing the PLL missing error window, try to manually add any one PLL once you open the form.It will start asking the basic PLL files ( like APPCORE,JL,JA,FNDSQF,etc) . It will be about 30 to 40 files which you need to download and move to the resource folder. After that close the form and reopen it. Now it will open without any error.
Please update your comments if you still face any issues even after performing the above steps.
Wednesday, January 11, 2017
ORA-04091: table XXX is mutating, trigger/function may not see it
Let us take a business scenarios. Assume that there is a table with ID column , Transaction Date , Transaction Type and Transaction Value.
The business need is, if any record inserted into the table with Transaction Type as "Invoice" then it should automatically insert another record with Transaction Type as "Tax" with Transaction value as 10% of the Invoice Transaction Value.
Below is the script initially built for the requirement
DROP TABLE mytransactions;
CREATE TABLE mytransactions
(
id NUMBER,
tdate DATE ,
ttype VARCHAR2(20) ,
tvalue NUMBER
);
DROP TRIGGER mytransactions_ai;
CREATE OR REPLACE TRIGGER mytransactions_ai AFTER
INSERT ON mytransactions FOR EACH row
BEGIN
IF (:new.ttype='Invoice') THEN
INSERT INTO mytransactions VALUES
(:new.id,sysdate,'Tax',:new.tvalue*0.1 );
dbms_output.put_line('Tax Inserted');
END IF;
END;
/
INSERT INTO mytransactions VALUES (1,sysdate,'Invoice',100);
When we try to execute the above insert script, we might end up with the below error.
ORA-04091: table MYTRANSACTIONS is mutating, trigger/function may not see it
ORA-06512: at "MYTRANSACTIONS_AI", line 3
ORA-04088: error during execution of trigger 'MYTRANSACTIONS_AI'
To overcome the mutating error, we should use AUTONOMOUS_TRANSACTION in the trigger.
CREATE OR REPLACE TRIGGER mytransactions_ai AFTER
INSERT ON mytransactions FOR EACH row
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
IF (:new.ttype='Invoice') THEN
INSERT INTO mytransactions VALUES
(:new.id,sysdate,'Tax',:new.tvalue*0.1 );
dbms_output.put_line('Tax Inserted');
COMMIT;
END IF;
END;
/
After modifying the trigger we should able to insert the records successfully.
ID TDATE TTYPE TVALUE
---------- --------- -------------------- ----------
1 11-JAN-17 Invoice 100
1 11-JAN-17 Tax 10
Tuesday, January 10, 2017
Incompatibility Setting for a Concurrent Program
- This can be set at Global or at Domain Level
- When we set it at Global, the program cannot be run parallel at any point of time. It is taken care by the Conflict Manager.
- To set the incompatibility at Domain level, we should understand about conflict domain.
Conflict Domain is nothing but a logic partition of the data available in the database. The data can be partitioned at many level. For example, SOB, OU or INV level.
For example, if the Program needs to be run parallel across the operating unit but sequential within the operating unit then we need to define the Conflict Domain
Steps to define Conflict Domain at Operating Unit level.
1. Create a concurrent program
2. Add parameters
3. Select one parameter as Conflict Domain in the setup (Available in the parameter window itself). The parameter should be defaulted from profile "MO: Operating Unit"
4. Set the incompatibility for the program for itself at Domain level
By following the above setup, we can achieve the requirement.
Tuesday, February 23, 2016
GREATEST
Saturday, April 25, 2015
PL/SQL Collection : Storing TABLE values into a TABLE TYPE
Below are some of the PL/SQL Collections
OBJECT Type
TABLE Type
RECORD Type
Hope you can google about these to get more information.
In this article I like to explain how to retrieve records from a table and store it in a TABLE type.
Create a table emp_tb as given below and insert some values
CREATE TABLE emp_tb ( empid NUMBER , NAME VARCHAR2(20) );
INSERT INTO emp_tb VALUES (10, 'Bala');
INSERT INTO emp_tb VALUES (20, 'Kaarhtik');

Now create a OBJECT type same like the table structure.
CREATE OR REPLACE TYPE emp_type IS OBJECT (
empid NUMBER,
NAME VARCHAR2 (20)
);
Create TABLE type with the object object
CREATE OR REPLACE TYPE emp_tb_type IS TABLE OF emp_type;
Below is a PLSQL block to retrieve the data from emp_tb and store it in the emp_tb_type object.
SET serveroutput on
DECLARE
v_tab emp_tb_type;
v_rec emp_type;
BEGIN
v_tab := emp_tb_type ();
FOR i IN (SELECT * FROM emp_tb)
LOOP
v_tab.EXTEND ();
v_rec := emp_type (i.empid, i.name);
v_tab (v_tab.LAST) := v_rec;
END LOOP;
FOR i IN v_tab.FIRST .. v_tab.LAST
LOOP
DBMS_OUTPUT.put_line (v_tab (i).empid || '-' || v_tab (i).name);
END LOOP;
END;
/
v_tab - is a variable for the TABLE type emp_tb_type
v_rec - is a variable for the OBJECT type emp_type. This variable is create to assign the value in the TABLE type variable v_tab. This is how a record is inserted into the table type object
emp_tb_type() - This is a constructor function which will be created along with the OBJECT type definition. We need to call this to initialize the variable v_tab.
EXTEND() - This is used to create one record index (Last record in the TABLE type variable)
emp_type(i.empid,i.name) - This is how a record is created from a OBJECT type so that we can assign it to its variable v_rec
v_tab(v_tabl.LAST) - This is used to navigate to the end of the TABLE type record so that we can store the new value at the end.
Later of the code is use to retrieve the records from the TABLE type to display.
Below is the sample output.
10-Bala
20-Kaarhtik
Thursday, March 22, 2012
TIMESTAMP - Datatype
The following example queries may explain you about the timestamp data type.
Output : 2012-03-20T02:03:28.000Z
In the above example we already know about the format type YYYY-MM-DD HH:MM:SS .
.FF3 - It limits the fraction part as 3 . we can also use .FXX to get all the fraction part in the timestamp
select to_timestamp('2012-03-20T02:03:28.000Z','YYYY-MM-DD"T"HH24:MI:SS.FF3"Z"') from dual;
The above query is the reverse query.
we have more functions regarding timezone conversion. For more information you can always google it.
Monday, March 19, 2012
Item Catalog Group
One other thing you can think about at that point is Item Catalog Groups. With Item Catalog Groups in Oracle you can catalog your items in groups and add extra information to your items based upon the category the items is related to.
Creating catalog groups and placing items in catalog groups will have several benefits. One of them obviously is that you will be able to group items and search within groups. Other benefits are that you will be able, for example, add more information which is relevant only for the items within this group and you will be able to automatically create aĆ’ item description based upon this. So this will also help you bring uniformity in the way you create your item descriptions.
To be able to do so you first will have to create a Catalog Item group within Oracle Inventory. To do so navigate to "Setup -> Items -> Catalog Groups". Here you will be able to view, edit and create new catalog groups.

As shown in the above screenshot I created a new Catalog Group in Oracle Inventory named "Gear Pumps" which will hold all the items which are gear pumps. Or in other words, in alter stage I will assign the Catalog Group "Gear Pumps" to all the existing items who are gear pumps. If you create a new group, save it and click on the Details button you will be able to set more options.

As you can see in the above screenshot I have set some details for this Item Catalog Group. I have been adding Descriptive Elements. Descriptive Elements are used per Item. In this case I have chosen 4 Descriptive Elements which can be set for all the items which will be placed this Item Catalog Group. The sequence is deliberately defined as 10, 20, 30, 40 because in this case I can easily add a record in the middle without having to change all the sequences of the existing records. This is in general a good idea to do. I also have set for all 4 of the Descriptive Elements that they are required so when a item is added to the group you have to set it. Only for 3 of the 4 I have set that it is a Description Default. When you set a Descriptive Element to Description Default it will be by default used to generate you description.
When you like to add a item to a Item Catalog group you go to the Item Master and query the item, then go to the Tools menu and select Catalog. you will be presented with a screen similar as in the screenshot below.

In this case I have selected the Item Catalog Group I created " gear Pumps" in the top "Catalog Group" field. When you select it you will be presented with a list of all the available and active Item Catalog Groups. After filling all the requierd fields for the Descriptive Elements, in this case all, you can use the Update Description button which will fill the item description with the generated "Item Catalog Description" based upon the catalog name and the descriptive elements in combination with their sequence. This is how you can generate standardized item descriptions. You do however have the possibility to change and edit the description so you will ne bound to the generated description. If you set this up smartly however it can be very beneficial.
Sunday, March 18, 2012
AND - Binary Function - Left to Right execution
AND is a binary function which has two input and one output. The input and output will be either a Boolean TRUE / FALSE.
AND | F | T | ||||||
F | F | F | ||||||
T | F | T |
Above is the Truth table which explains the AND function. So if one of the input is FALSE the AND function will return FALSE no matter about the second input . This is the thing we normally remember about the AND function.
But we also have to remember the execution sequence of it. For example we can take the below cases. We have a AND between two functions which returns a Boolean value.
fun1 - will always insert a data into a table and returns TRUE
fun2 - does nothing and returns FALSE
Case 1 : fun1 AND fun2
Case 2: fun2 AND fun1
In both cases the result will be FALSE. But we have some difference in the execution.
Case 1 : fun1 AND fun2
In this case fun1 will be executed first , a data will be inserted into the table and TRUE will be returned. since the first input is TRUE, the AND will check the next input . In this case it checks the fun2 which returns FALSE. So the result will be FALSE.
Case2: fun2 AND fun1
In this case fun2 will be executed first , it returns FALSE. Since the first input is FALSE, the AND will not check (execute) the next input. Because as per AND logic if one input is FALSE it will always return FALSE , no matter about the second input.
Even thought both cases return FALSE , a data got inserted in Case 1 where as it doesn't happen in Case 2.
The main motive of the above writeup is to explain the execution sequence of a binary function in PL/SQL.
Oracle PL/SQL functions always follows a LEFT to RIGHT execution.
Thursday, January 19, 2012
User Responsibility Issue
Sometimes we might face some issue in User Responsibilities. I want to share the issue which I faced.
A responsibility was assigned to my user and it got end dated in production. So if a clone was made from production the responsibility which was end dated comes as it is with the end date.
I need to use the responsibility in the cloned instance. So I removed the end date for the responsibility and saved it. But it was still unavailable for me to use. Then I started to trace the tables which causing the issue.
FND_USER – The first table to get my user_id for my user.
FND_USER_RESP_GROUPS_DIRECT – Is the table which has the list of responsibility shown in the form (which includes my responsibility which is not available to use)
FND_USER_RESP_GROUPS – which contains the responsibilities for the user available to use it ( this will not have my responsibility which has the issue)
WF_USER_ROLES – This is a part of the above view FND_USER_RESP_GROUPS which tell the active user roles.
WF_LOCAL_USER_ROLES – This is a part of the above view WF_USER_ROLES which has all the roles including the inactive one.
This is where the issue came. WF_LOCAL_USER_ROLES has my responsibility role but it has been end dated (effective_end_date). By updating this to 1/1/9999 (unlimited end date) I was able to rectify my issue.
Hope this is useful.
Friday, December 30, 2011
WF DOCUMENT Manager Error
PO Re-Approval
PO Header Total Amount
Monday, January 3, 2011
Getting More then 9 parameters in a batch file
REM kaarthik.bat - file to test parameters
echo off
echo Program to test parameters
echo Parameter 1 : %1
echo Parameter 2 : %2
echo Parameter 3 : %3
echo Parameter 4 : %4
echo Parameter 5 : %5
echo Parameter 6 : %6
echo Parameter 7 : %7
echo Parameter 8 : %8
echo Parameter 9 : %9
echo Parameter 10 : %10
SHIFT
echo Parameter 10 : %9
Tuesday, November 10, 2009
IS_NUMBER - Equivalent SQL Query
SELECT DECODE (REPLACE (TRANSLATE ('1123', '1234567890', '##########'), '#'),
NULL, 'NUMBER','NON NUMER') RESULT
FROM DUAL;
RESULT
------
NUMBER
1 row selected.
---------------------------------------------------------------------------------
SELECT DECODE (REPLACE (TRANSLATE ('11a23z', '1234567890', '##########'), '#'),
NULL, 'NUMBER','NON NUMER') RESULT
FROM DUAL;
RESULT
---------
NON NUMER
1 row selected.