Search This Blog

Thursday, 10 October 2013

Procedurs to Upload and Download files into Oracle Database

1. Create Table into database

CREATE TABLE MY_BLOBS
(
  ID        VARCHAR2(255 BYTE),
  BLOB_COL  BLOB
)
;

2. Upload Procudure

CREATE OR REPLACE PROCEDURE upload_file (file_name IN VARCHAR2)
AS
   src_loc    BFILE := BFILENAME ('EXT_DIR', file_name);
   dest_loc   BLOB;
  
   lv_id varchar2(50);
  
BEGIN

    select substr(file_name,1,instr(file_name,'.')-1)
        into lv_id
    from dual;


   INSERT INTO my_blobs
        VALUES (lv_id, EMPTY_BLOB ())
     RETURNING blob_col
          INTO dest_loc;

   DBMS_LOB.OPEN (src_loc, DBMS_LOB.lob_readonly);
   DBMS_LOB.OPEN (dest_loc, DBMS_LOB.lob_readwrite);
   DBMS_LOB.loadfromfile (dest_lob      => dest_loc,
                          src_lob       => src_loc,
                          amount        => DBMS_LOB.getlength (src_loc)
                         );
   DBMS_LOB.CLOSE (dest_loc);
   DBMS_LOB.CLOSE (src_loc);
   COMMIT;
END;
/


3. Download Procedure

CREATE OR REPLACE PROCEDURE download_file (file_name IN VARCHAR2)
AS

  l_file       UTL_FILE.file_type;
   l_buffer     RAW (32767);
   l_amount     BINARY_INTEGER     := 32767;
   l_pos        INTEGER            := 1;
   l_blob       BLOB;
   l_blob_len   INTEGER;
BEGIN
-- Get LOB locator
   SELECT BLOB_COL
     INTO l_blob
     FROM my_blobs
    WHERE ID = file_name;

   l_blob_len := DBMS_LOB.getlength (l_blob);
-- Open the destination file.
   l_file := UTL_FILE.fopen ('EXT_DIR', file_name, 'WB', 32767);

-- Read chunks of the BLOB and write them to the file
-- until complete.
   WHILE l_pos < l_blob_len
   LOOP
      DBMS_LOB.READ (l_blob, l_amount, l_pos, l_buffer);
      UTL_FILE.put_raw (l_file, l_buffer, TRUE);
      l_pos := l_pos + l_amount;
   END LOOP;

-- Close the file.
   UTL_FILE.fclose (l_file);
EXCEPTION
   WHEN OTHERS
   THEN
-- Close the file if something goes wrong.
      IF UTL_FILE.is_open (l_file)
      THEN
         UTL_FILE.fclose (l_file);
      END IF;

      RAISE;
END;
/

Thursday, 5 September 2013

Calculate time of the day & Shift in a day !!

SELECT TRUNC(SYSDATE) + 7 / 24
FROM DUAL;

-----------------------------------------------------------------------

SELECT SH.SHIFT_NAME, SH.START_TIME, SH.END_TIME
FROM SHIFTS SH
 WHERE (TO_DATE(TO_CHAR(ISSUE_TIME, 'hh:mi:ss am'), 'hh:mi:ss am') +
             (CASE WHEN TO_DATE(SH.END_TIME, 'hh:mi:ss am') <
               TO_DATE(SH.START_TIME, 'hh:mi:ss am')
                 THEN(CASE WHEN
                                      TO_DATE(TO_CHAR(ISSUE_TIME, 'hh:mi:ss am'), 'hh:mi:ss am') BETWEEN
                                      TO_DATE('00:00:00', 'hh24:mi:ss') AND
                                      TO_DATE('06:59:59 am', 'hh:mi:ss am') THEN 1 ELSE 0 END) ELSE 0 END)) BETWEEN
                               TO_DATE(SH.START_TIME, 'hh:mi:ss am') AND
                               (CASE WHEN TO_DATE(SH.END_TIME, 'hh:mi:ss am') <
                                TO_DATE(SH.START_TIME, 'hh:mi:ss am') THEN
                                TO_DATE(SH.END_TIME, 'hh:mi:ss am') + 1 ELSE
                                TO_DATE(SH.END_TIME, 'hh:mi:ss am') END)
                           AND SH.HIDE_FLAG = 'N'

Thursday, 29 August 2013

List of Tables for Oracle Forms Personalization

FND_FORM_CUSTOM_RULES
FND_FORM_CUSTOM_SCOPES
FND_FORM_CUSTOM_ACTIONS
FND_FORM_CUSTOM_PARAMS
FND_FORM_CUSTOM_PROP_VALUES
FND_FORM_CUSTOM_PROP_LIST

Saturday, 17 August 2013

Find all current Oracle Application user logged in

/**********************************************************
 *PURPOSE: To list all users currently logged in Oracle Apps *
 **********************************************************/

SELECT DISTINCT ic.disabled_flag,
  fu.user_name User_Name,
  fr.RESPONSIBILITY_KEY Responsibility,
  fu.user_id,
  fu.description,
  fu.employee_id,
  ic.responsibility_application_id,
  ic.responsibility_id,
  ic.org_id,
  ic.function_type,
  ic.counter,
  ic.first_connect,
  ic.last_connect,
  ic.nls_territory,
  ic.time_out,
  fr.menu_id,
  fr.responsibility_key
FROM fnd_user fu,
  fnd_responsibility fr,
  icx_sessions ic
WHERE fu.user_id          = ic.user_id
AND fr.responsibility_id  = ic.responsibility_id
AND ic.disabled_flag      ='N'
and IC.RESPONSIBILITY_ID is not null
AND ic.last_connect       > sysdate - (ic.time_out/60)/96

Friday, 16 August 2013

Application Form Existance into Hierarchy (Menu Hierarchy)

SELECT   'PR', prompt, menu.menu_id, menu.description, responsibility_name,
         rsp.description application, user_name, full_name full_name
    FROM fnd_menu_entries_vl menu,
         apps.fnd_responsibility_vl rsp,
         fnd_user_resp_groups_direct ursp,
         (SELECT fu.user_id, fu.user_name, full_name full_name, pp.person_id
            FROM apps.fnd_user fu, apps.per_people_f pp
           WHERE pp.person_id = fu.employee_id
             AND NVL (fu.end_date, SYSDATE + 1) >= TRUNC (SYSDATE)) person
   WHERE rsp.menu_id = menu.menu_id
     AND ursp.responsibility_id = rsp.responsibility_id
     AND person.user_id = ursp.user_id
     AND NVL (ursp.end_date, SYSDATE + 1) >= TRUNC (SYSDATE)
     AND (   menu.menu_id IN (
                SELECT menu.menu_id
                  FROM fnd_menu_entries_vl menu
                 WHERE sub_menu_id IN (SELECT menu.menu_id
                                         --, menu.description,SUB_MENU_ID
                                       FROM   fnd_menu_entries_vl menu
                                        WHERE function_id IN (:P_function_id))
                UNION ALL
                SELECT menu.menu_id
                  FROM fnd_menu_entries_vl menu
                 WHERE sub_menu_id IN (
                          SELECT menu.menu_id
                            FROM fnd_menu_entries_vl menu
                           WHERE sub_menu_id IN (
                                                 SELECT menu.menu_id
                                                   --, menu.description,SUB_MENU_ID
                                                 FROM   fnd_menu_entries_vl menu
                                                  WHERE function_id IN (:P_function_id)))
                UNION ALL
                SELECT menu.menu_id
                  FROM fnd_menu_entries_vl menu
                 WHERE sub_menu_id IN (
                          SELECT menu.menu_id
                            FROM fnd_menu_entries_vl menu
                           WHERE sub_menu_id IN (
                                    SELECT menu.menu_id
                                      FROM fnd_menu_entries_vl menu
                                     WHERE sub_menu_id IN (
                                                 SELECT menu.menu_id
                                                   --, menu.description,SUB_MENU_ID
                                                 FROM   fnd_menu_entries_vl menu
                                                  WHERE function_id IN (:P_function_id))))
                UNION ALL
                SELECT menu.menu_id
                  FROM fnd_menu_entries_vl menu
                 WHERE sub_menu_id IN (
                          SELECT menu.menu_id
                            FROM fnd_menu_entries_vl menu
                           WHERE sub_menu_id IN (
                                    SELECT menu.menu_id
                                      FROM fnd_menu_entries_vl menu
                                     WHERE sub_menu_id IN (
                                              SELECT menu.menu_id
                                                FROM fnd_menu_entries_vl menu
                                               WHERE sub_menu_id IN (
                                                        SELECT menu.menu_id
                                                          --, menu.description,SUB_MENU_ID
                                                        FROM   fnd_menu_entries_vl menu
                                                         WHERE function_id IN
                                                                       (:P_function_id)))))
                UNION ALL
                SELECT menu.menu_id
                  FROM fnd_menu_entries_vl menu
                 WHERE sub_menu_id IN (
                          SELECT menu.menu_id
                            FROM fnd_menu_entries_vl menu
                           WHERE sub_menu_id IN (
                                    SELECT menu.menu_id
                                      FROM fnd_menu_entries_vl menu
                                     WHERE sub_menu_id IN (
                                              SELECT menu.menu_id
                                                FROM fnd_menu_entries_vl menu
                                               WHERE sub_menu_id IN (
                                                        SELECT menu.menu_id
                                                          FROM fnd_menu_entries_vl menu
                                                         WHERE sub_menu_id IN (
                                                                  SELECT menu.menu_id
                                                                    --, menu.description,SUB_MENU_ID
                                                                  FROM   fnd_menu_entries_vl menu
                                                                   WHERE function_id IN
                                                                            (:P_function_id))))))
                UNION ALL
                SELECT menu.menu_id
                  FROM fnd_menu_entries_vl menu
                 WHERE sub_menu_id IN (
                          SELECT menu.menu_id
                            FROM fnd_menu_entries_vl menu
                           WHERE sub_menu_id IN (
                                    SELECT menu.menu_id
                                      FROM fnd_menu_entries_vl menu
                                     WHERE sub_menu_id IN (
                                              SELECT menu.menu_id
                                                FROM fnd_menu_entries_vl menu
                                               WHERE sub_menu_id IN (
                                                        SELECT menu.menu_id
                                                          FROM fnd_menu_entries_vl menu
                                                         WHERE sub_menu_id IN (
                                                                  SELECT menu.menu_id
                                                                    FROM fnd_menu_entries_vl menu
                                                                   WHERE sub_menu_id IN (
                                                                            SELECT menu.menu_id
                                                                              --, menu.description,SUB_MENU_ID
                                                                            FROM   fnd_menu_entries_vl menu
                                                                             WHERE function_id IN
                                                                                      (:P_function_id))))))))
          OR menu.function_id IN (:P_function_id)
         )
GROUP BY menu.menu_id,
         menu.description,
         responsibility_name,
         rsp.description,
         user_name,
         full_name,
         prompt

Custom Form Compilation

login SSH by user/Pass e.g developer / 123456

 1. Execute the following file availabe at user home or /d01/oracle (file to set environment variable by Apps DBA)  . APPSPROD_erp-01.env

 2. Move to the full qualified path where file exist which need to be compiled (/d01/oracle/prodappl/gl/11.5.0/forms/US) and execute the given    below command
--> f60gen userid=APPS/APPS module=PAYMENT_ALERT_CONFIG.fmb module_type=form compile_all=Y
    OR
    f60gen module=/d01/oracle/prodappl/gl/11.5.0/forms/US/payment_alert_config.fmb userid=apps/appsoutput_file=/home/developer/payment_alert_config.log

Sunday, 21 April 2013

A New Custom Form in Oracle Apps 11i

Illustrated below solution has described by using the  MS windows environment

  1. Make sure the installation for form developer environment 6i e.g [roote]\orant\BIN  (C:\orant\BIN\ifbld60.EXE)
  2. Copy all the resouce files from AU_TOP (application User TOP) by FTP from ERP installed environment e.g /d01/oracle/prodappl/au/11.5.0/resource to C:\orant\BIN
  3. Copy source template file named (TEMPLATE.fmb, APPSTAND.fmb) by FTP from /d01/oracle/prodappl/au/11.5.0/forms/US into C:\orant\BIN
  4. open MS Window registry by command REGEDIT, find FORMS60_PATH variable under the path HKEY_LOCAL_MACHINE \ SOFTWARE \ ORACLE and add the ;C:\orant\BIN at the end of an existing string
  5.  Run oracle form builder 6i & open file C:\orant\BIN\TEMPLATE.fmb for customization
Custom Form Compilation

How to compile custom Form

Form Registration into Oracle ERP

Supporting Document Link

 1. Do listed below necessary steps to show form into application menu


  • Open Application Developer (Respons.) -->Application --> Forms
  • Define Function for this form Application Developer (Respons.) -->Application --> Function
  • In the end attached with in the menu you want to access screen. 
Useful web link


Friday, 19 April 2013

Find Oracle ERP object name

SELECT NAME, TYPE, REFERENCED_NAME, REFERENCED_TYPE
  FROM USER_DEPENDENCIES
 WHERE NAME = UPPER('ap_invoices')
 --WHERE NAME LIKE UPPER('%AP_INVOICE%')
 AND (TYPE = 'VIEW' OR REFERENCED_TYPE = 'TABLE')

Script to Kill Database Session in oracle



select a.object_id,a.session_id,b.object_name               
from v$locked_object a,dba_objects b                 
where a.object_id = b.object_id;               
               
select sid,serial# from v$session where sid = 99;               
               
alter system kill session '33,9';            

select 'alter system kill session ''' || sid ||','|| serial# ||''''
from v$session where sid in (99)

select 'alter system kill session ''' || sid ||','|| serial# ||''''
from v$session where sid in (99)