Skip to main content

Print CLOB data using Oracle PL/SQL

Objective:

To print clob data.

Solution:

Step 1: Create plsql procedure to print the clob.

CREATE OR REPLACE PROCEDURE print_clob_to_output (p_clob IN CLOB)
 IS
   l_offset     INT := 1;
 BEGIN
   dbms_output.put_line('Print CLOB');  
    loop
        exit when l_offset > dbms_lob.getlength(p_clob);
        dbms_output.put_line( dbms_lob.substr( p_clob, 255, l_offset ) );
        l_offset := l_offset + 255;
    END LOOP;
 END print_clob_to_output;

 This query will print the complete clob data.

Step 2: Call the procedure.

DECLARE
  l_xml CLOB;
BEGIN
  SELECT dbms_xmlgen.getxml('select * from emp') xml 
    INTO l_xml 
    FROM dual;
  
  print_clob_to_output (l_xml);

END;

Output:





Related Posts:

Comments

Popular posts from this blog

Friendly URL: Redirect to Different Page after Login in Oracle APEX 20.1

Oracle has updated apex.oracle.com to APEX 20.1 which includes among other features the new Friendly URL option. Here i am giving an example to redirect to different page after login in Oracle APEX 20.1 [Friendly URL Enabled] Step 1: Define home page for each user in emp master table as below Step 2: To enable Friendly URL Syntax, follow below steps, 1) On the Workspace home page, click the App Builder icon. 2) Select an application (The Application home page appears). 3) From Application home page, you can access the Definition page in TWO ways: Click the Edit Application Properties button. From Shared Components:              1) Click Shared Components .              2) Under Application Logic, click Application Definition Attributes . The Definition page appears. 4) Under Properties, configure the Friendly URL s attribute: Click Apply Changes to save your ch...

Number of Tables by their Size in Oracle Database

Here I am giving an example to find out number of tables by their size (Bytes, KB, MB, GB and TB) in oracle database. Query 1: [Bytes]  Number of all tables accessible to the  current user  in Oracle database by their size grouped into  predefined intervals . SELECT  size_interval ,         count ( * )   AS  no_of_tables    FROM   ( SELECT   DATA . segment_name table_name ,                CASE                 WHEN   DATA . bytes >  1000000000                 THEN   '1b Bytes and more'                 WHEN   DATA . bytes >  1000000    ...

Generating the report with APEX_DATA_EXPORT

With the APEX_DATA_EXPORT package, you are able to export data from Oracle Application Express in the following file types: PDF, XLSX, HTML, CSV, XML, and JSON. Step 1: Create a table and populate it with some sample records. CREATE TABLE emp   (     empno        NUMBER,     first_name   VARCHAR2(240),     last_name    VARCHAR2(240),     mgr          NUMBER,     deptno       NUMBER,     sal          NUMBER,     created_date TIMESTAMP (6),     comm         NUMBER,     hiredate     DATE,     JOB          VARCHAR2(240),     ename        VARCHAR2(240),     PRIMARY KEY (empno) USING INDEX ENABLE   ); /    INSERT INTO emp (empno, first_name, last_name, mgr,...