Showing posts with label PLSQL. Show all posts
Showing posts with label PLSQL. Show all posts

Tuesday, 17 November 2020

OOP Concepts in PLSQL with Record type

 CREATE OR REPLACE TYPE HTML_OBJ_Record is object  (Body_String Clob)



CREATE OR REPLACE TYPE HTML_OBJ AS OBJECT (

   HTML_Record  HTML_OBJ_Record,

   MEMBER PROCEDURE init( SELF IN OUT NOCOPY HTML_OBJ)

  )



CREATE OR REPLACE TYPE BODY HTML_OBJ AS

  

  MEMBER PROCEDURE init (SELF IN OUT NOCOPY HTML_OBJ) IS

  BEGIN

         SELF.HTML_Record:=new HTML_OBJ_Record(null);

         SELF.HTML_Record.body_string:='Hello';

  END;



END;




declare

html HTML_OBJ;

begin

    html := new HTML_OBJ(null);

    DBMS_OUTPUT.put_line('=> '||html.HTML_Record.body_string);

    html.init();

    DBMS_OUTPUT.put_line('=> '||html.HTML_Record.body_string);  

  end;

  


Wednesday, 29 April 2020

FND_PROFILE AND FND_GLOBAL


FND_PROFILE values: 

fnd_profile.value('PROFILEOPTION');
fnd_profile.value'MFG_ORGANIZATION_ID');
fnd_profile.value('ORG_ID');
fnd_profile.value('LOGIN_ID');
fnd_profile.value('USER_ID');
fnd_profile.value('USERNAME');
fnd_profile.value('CONCURRENT_REQUEST_ID');
fnd_profile.value('GL_SET_OF_BKS_ID');
fnd_profile.value('SO_ORGANIZATION_ID');
fnd_profile.value('APPL_SHRT_NAME');
fnd_profile.value('RESP_NAME');
fnd_profile.value('RESP_ID');

FND_GLOBAL values: 

FND_GLOBAL.USER_ID;
FND_GLOBAL.APPS_INTIALIZE;
FND_GLOBAL.LOGIN_ID;
FND_GLOBAL.CONC_LOGIN_ID;
FND_GLOBAL.PROG_APPL_ID;
FND_GLOBAL.CONC_PROGRAM_ID;
FND_GLOBAL.CONC_REQUEST_ID;

Monday, 20 April 2020

How to get next value of Sequence dynamically in Oracle

we can execute sequence and get its value using Execute Immediate.
here is the Example Code;

CREATE SEQUENCE mySEQ START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 1000000 NOCYCLE NOCACHE ORDER

declare
  SequenceValue number;
begin
    EXECUTE IMMEDIATE 'select mySEQ.nextval  from dual' INTO SequenceValue;
    ---Now you can Use SequenceValue anywhere
end;
/

drop sequence mySEQ 

/

Saturday, 18 April 2020

Rownum in SQL

The Oracle/PLSQL ROWNUM function returns a number that represents the order that a row is selected by Oracle from a table or joined tables.

Example

select * from all_objects where rownum < 2

Tuesday, 31 March 2020

Oracle DDL with EXECUTE IMMEDIATE -- Drop Multiple Object at once


If You want to Drop Multiple Object at once use this script. Please using
This script check cursor query and take update of your database


/* Formatted on 3/31/2020 1:40:01 am (QP5 v5.139.911.3011) */
DECLARE
   CURSOR OBJECTLIST
   IS
      SELECT    'Drop '
             || OBJECT_TYPE
             || '  '
             || OWNER
             || '.'
             || OBJECT_NAME
             || ''
                DROPCOMMAND
        FROM ALL_OBJECTS
       WHERE OWNER = 'APPS' AND OBJECT_NAME LIKE 'EBA%';
BEGIN
   FOR LDX IN OBJECTLIST
   LOOP
      DBMS_OUTPUT.PUT_LINE (TO_CHAR (LDX.DROPCOMMAND));

      BEGIN
         EXECUTE IMMEDIATE LDX.DROPCOMMAND;

         DBMS_OUTPUT.PUT_LINE ('Object has been dropped.');
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.
            PUT_LINE (
                  SQLERRM
               || ' While performing this Command,'
               || TO_CHAR (LDX.DROPCOMMAND));
      END;
   END LOOP;
END;


select 'Drop '||OBJECT_TYPE||'  '||OWNER||'.'||OBJECT_NAME||';'
from all_objects
where owner='APPS'
AND OBJECT_NAME LIKE 'EBA%'

Thursday, 19 March 2020

Java File.deleteOnExit() method

  1. import java.io.File;  
  2. import java.io.IOException;  
  3. public class DeleteOnExitExample  
  4. {  
  5. public static void main(String[] args)  
  6. {  
  7. File temp;  
  8. try  
  9. {  
  10. temp = File.createTempFile("abc"".temp");     //creating a .temp file  
  11. System.out.println("Temp file created at location: " + temp.getAbsolutePath());      
  12. temp.deleteOnExit();                     //delete file on runtime exit  
  13. System.out.println("Temp file exists : " + temp.exists());  
  14. }   
  15. catch (IOException e)  
  16. {  
  17. e.printStackTrace();  
  18. }  
  19. }  
  20. }  

Saturday, 14 March 2020

How to access APEX application from other Computer

If you want to access/operate Apex application from other computer then Case 1 applicable Otherwise if you want locally then Case 2 applicable.
Case 1. URL : http://ComputerName:Port/apex
or http://IPaddress:Port/apex
Case 2. URL : http://localhost:/apex
For Case 1 if you are not able to access the application then have to enable network access true.
To do so, you have to log on as SYS with SYSDBA privilege and execute the following command.
execute dbms_xdb.setListenerLocalAccess(l_access => FALSE);
Just copy the above command and paste into your SQL Editor and execute. After scuccessfull execution of the above command, if the remote computer name is ABC and apex access port 8080 then your url will be as bellow-
http://abc:8080/apex
If the remote computer IP is 119.18.144.201 and apex access port 8080 then your url will be as bellow-
http://119.18.144.201:8080/apex

Thursday, 2 January 2020

index Table Type in PLSQL


DECLARE

  TYPE TABLENAMETYPE IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;

  L_TABLENAMETYPE TABLENAMETYPE;

BEGIN

  --YOU CAN USE THIS L_TABLENAMETYPE TYPE HERE

  L_TABLENAMETYPE(1) := 'AB';

  L_TABLENAMETYPE(2) := 'ABC';

  L_TABLENAMETYPE(3) := 'ABD';

  L_TABLENAMETYPE(4) := 'ABE';

  FOR LDX IN 1 .. L_TABLENAMETYPE.COUNT
 
   LOOP
 
    DBMS_OUTPUT.PUT_LINE(L_TABLENAMETYPE(LDX));
 
  END LOOP;

  ---DELETE ALL VALUES

  L_TABLENAMETYPE.DELETE;

END;

--RESULT

AB

ABC

ABD

ABE

---USE TABLE TYPE WITH BULK COLLECT INTO

DECLARE

CURSOR C IS

  SELECT * FROM EMP;

TYPE ANY_TABLE_TYPE IS TABLE OF EMP%ROWTYPE INDEX BY BINARY_INTEGER;

EMP_REC ANY_TABLE_TYPE;

BEGIN

  OPEN C;

  FETCH C BULK COLLECT
 
    INTO EMP_REC;

  CLOSE C;

  FORALL I IN EMP_REC.FIRST .. EMP_REC.LAST
 
    UPDATE EMP
   
       SET COMM = EMP_REC(I).SAL * 10 / 100
   
     WHERE EMPNO = EMP_REC(I).EMPNO;

  COMMIT;

END;




Perform Dynamic DLL in Oracle


EXECUTE IMMEDIATE statement can be used to execute dynamic SQL statements.

Syntax: EXECUTE IMMEDIATE 'User_Code';

--
-- Create/Drop Table using this PLSQL Script or Procedure
-- DLL Script
-- by mfaisal 02-Jan-2020

Declare
---Create
begin
  execute immediate 'CREATE TABLE X_DDL_ON_APPS (APPS_ID NUMBER)';
end;


Declare
--Drop with Oracle EBS Package
begin
  system.ad_apps_private.do_apps_ddl(schema_name => 'APPS',
                                     ddl_text => 'DROP TABLE X_DDL_ON_APPS ');
end;


Thursday, 26 December 2019

Backup of all Oracle Database objects on Server with Procedure



----Backup With Procedure

---Create Directory
CREATE OR REPLACE DIRECTORY PS_DIR AS '/u01/oracle/PROD/fs2/EBSapps/appl/au/12.0.0/forms/BackUp';


---Create Procedure
  
   CREATE OR REPLACE PROCEDURE    EXPORT_DDL
AS
    V_DDL_CLOB  CLOB;
    VPATH VARCHAR2(255);
BEGIN
    FOR C IN (SELECT OBJECT_NAME, OBJECT_TYPE
             FROM USER_OBJECTS
             WHERE OBJECT_TYPE IN ('TABLE','VIEW','FUNCTION','PROCEDURE','PACKAGE','PACKAGE_BODY')
             and OBJECT_NAME like '%TGC%')
    LOOP
        V_DDL_CLOB := DBMS_METADATA.GET_DDL(C.OBJECT_TYPE, C.OBJECT_NAME);
        DBMS_XSLPROCESSOR.CLOB2FILE(V_DDL_CLOB, 'PS_DIR', C.OBJECT_TYPE || '_' || C.OBJECT_NAME||'.SQL');
    END LOOP;
END;



--- Call procedure

Exec EXPORT_DDL;

OADBTransactionImpl in Oracle Application Framework (OAF)

OADBTransactionImpl is a class in Oracle Application Framework (OAF), which is a framework for building Oracle E-Business Suite applications...