DBMS_LOB package. : Clob « Data Type « Oracle PL / SQL

Oracle PL / SQL
1. Aggregate Functions
2. Analytical Functions
3. Char Functions
4. Constraints
5. Conversion Functions
6. Cursor
7. Data Type
8. Date Timezone
9. Hierarchical Query
10. Index
11. Insert Delete Update
12. Large Objects
13. Numeric Math Functions
14. Object Oriented Database
15. PL SQL
16. Regular Expressions
17. Report Column Page
18. Result Set
19. Select Query
20. Sequence
21. SQL Plus
22. Stored Procedure Function
23. Subquery
24. System Packages
25. System Tables Views
26. Table
27. Table Joins
28. Trigger
29. User Previliege
30. View
31. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL / SQL » Data Type » Clob 
DBMS_LOB package.
  
SQL>
SQL>
SQL> CREATE OR REPLACE PROCEDURE ReverseLOB(
  2    p_InputLocator IN CLOB,
  3    p_OutputLocator IN OUT CLOB,
  4    p_ChunkSize IN NUMBERAS
  5
  6    v_InputOffset      BINARY_INTEGER;
  7    v_OutputOffset     BINARY_INTEGER;
  8    v_LOBLength        BINARY_INTEGER;
  9    v_CurrentChunkSize BINARY_INTEGER;
 10    e_TrimLength       EXCEPTION;
 11    PRAGMA EXCEPTION_INIT(e_TrimLength, -22926);
 12
 13  BEGIN
 14    v_LOBLength := DBMS_LOB.GETLENGTH(p_InputLocator);
 15
 16    BEGIN
 17      DBMS_LOB.TRIM(p_OutputLocator, v_LOBLength);
 18    EXCEPTION
 19      WHEN e_TrimLength THEN
 20        NULL;
 21    END;
 22
 23    v_InputOffset := 1;
 24    v_OutputOffset := v_LOBLength + 1;
 25
 26    LOOP
 27      EXIT WHEN v_InputOffset > v_LOBLength;
 28
 29      IF (v_LOBLength - v_InputOffset + 1> p_ChunkSize THEN
 30        v_CurrentChunkSize := p_ChunkSize;
 31      ELSE
 32        v_CurrentChunkSize := v_LOBLength - v_InputOffset + 1;
 33      END IF;
 34
 35      v_OutputOffset := v_OutputOffset - v_CurrentChunkSize;
 36
 37      DBMS_LOB.COPY(p_OutputLocator,
 38                    p_InputLocator,
 39                    v_CurrentChunkSize,
 40                    v_OutputOffset,
 41                    v_InputOffset);
 42
 43      v_InputOffset := v_InputOffset + v_CurrentChunkSize;
 44    END LOOP;
 45  END ReverseLOB;
 46  /

Procedure created.

SQL>
SQL>
SQL> CREATE TABLE lobdemo (
  2    key NUMBER,
  3    clob_col CLOB,
  4    blob_col BLOB);

Table created.

SQL>
SQL> INSERT INTO lobdemo (key, clob_col)
  2    VALUES (1'abcdefghijklmnopqrstuvwxyz');

row created.

SQL> INSERT INTO lobdemo (key, clob_col)
  2    VALUES (2, EMPTY_CLOB());

row created.

SQL> INSERT INTO lobdemo (key, clob_col)
  2    VALUES (3, EMPTY_CLOB());

row created.

SQL> INSERT INTO lobdemo (key, clob_col)
  2    VALUES (4, EMPTY_CLOB());

row created.

SQL> INSERT INTO lobdemo (key, clob_col)
  2    VALUES (5, EMPTY_CLOB());

row created.

SQL> INSERT INTO lobdemo (key, clob_col)
  2    VALUES (6, EMPTY_CLOB());

row created.

SQL> COMMIT;

Commit complete.

SQL>
SQL> SELECT key, clob_col
  2    FROM lobdemo
  3    WHERE key BETWEEN AND 6
  4    ORDER BY key;

       KEY
----------
CLOB_COL
--------------------------------------------------------------------------------
         1
abcdefghijklmnopqrstuvwxyz

         2


         3



       KEY
----------
CLOB_COL
--------------------------------------------------------------------------------
         4


         5


         6



rows selected.

SQL>
SQL> DECLARE
  2    v_Source CLOB;
  3    v_Destination CLOB;
  4    v_Key NUMBER;
  5    CURSOR c_Destinations IS
  6      SELECT key, clob_col
  7      FROM lobdemo
  8      WHERE key BETWEEN and 6
  9      FOR UPDATE;
 10  BEGIN
 11    SELECT clob_col
 12      INTO v_Source
 13      FROM lobdemo
 14      WHERE key = 1;
 15
 16    OPEN c_Destinations;
 17    LOOP
 18      FETCH c_Destinations INTO v_Key, v_Destination;
 19      EXIT WHEN c_Destinations%NOTFOUND;
 20
 21      IF (v_Key = 2THEN
 22        ReverseLOB(v_Source, v_Destination, 4);
 23      ELSIF (v_Key = 3THEN
 24        ReverseLOB(v_Source, v_Destination, 2);
 25      ELSIF (v_Key = 4THEN
 26        ReverseLOB(v_Source, v_Destination, 1);
 27      ELSIF (v_Key = 5THEN
 28        ReverseLOB(v_Source, v_Destination, 10);
 29      ELSIF (v_Key = 6THEN
 30        ReverseLOB(v_Source, v_Destination, 30);
 31      END IF;
 32    END LOOP;
 33    CLOSE c_Destinations;
 34    COMMIT;
 35  END;
 36  /

PL/SQL procedure successfully completed.

SQL>
SQL> SELECT key, clob_col
  2    FROM lobdemo
  3    WHERE key BETWEEN AND 6
  4    ORDER BY key;

       KEY
----------
CLOB_COL
--------------------------------------------------------------------------------
         1
abcdefghijklmnopqrstuvwxyz

         2
yzuvwxqrstmnopijklefghabcd

         3
yzwxuvstqropmnklijghefcdab


       KEY
----------
CLOB_COL
--------------------------------------------------------------------------------
         4
zyxwvutsrqponmlkjihgfedcba

         5
uvwxyzklmnopqrstabcdefghij

         6
abcdefghijklmnopqrstuvwxyz


rows selected.

SQL>
SQL> DROP TABLE lobdemo;

Table dropped.

SQL>
SQL>

   
  
Related examples in the same category
1. clob data type
2. Use clob type in PL/SQL
3. Use dbms_lob.erase to remove value from clob type value
4. Use dbms_lob.fileopen to open bfile
5. Creating an Internal LOB Table
6. Copying Internal LOBs
7. Appending and Writing to LOBs
8. Print out the length of the CLOBs previously INSERTed
9. Compare clob data
10. Compare two clobs
11. Append data to clob
12. Assign string value to clob type variable
13. Clob type column
14. Copy clob data
15. In() function with clob data
16. Initialize clob
17. Read clob type data, DBMS_LOB.READ
18. Use between ... and with clob data
19. Use clob to store xml data
20. clob type data as string
21. erase clob data
22. use like operator with clob type data
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.