Writes into a CLOB : CLOB « PL SQL Data Types « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
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
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 Tutorial » PL SQL Data Types » CLOB 
21. 42. 4. Writes into a CLOB
SQL> CREATE TABLE facebook (
  2     name VARCHAR2(80),
  3     photo BLOB,
  4     directions CLOB,
  5     description NCLOB,
  6     web_page BFILE);

Table created.

SQL>
SQL> CREATE DIRECTORY bfile_data AS 'c:\xxx';

Directory created.

SQL>
SQL> DECLARE
  2     directions CLOB;
  3     amount BINARY_INTEGER;
  4     offset INTEGER;
  5     first_direction VARCHAR2(100);
  6     more_directions VARCHAR2(500);
  7  BEGIN
  8
  9     DELETE FROM facebook WHERE name='Falls';
 10
 11     INSERT INTO facebook(name,directions)VALUES ('Falls',EMPTY_CLOB());
 12
 13     SELECT directions INTO directions FROM facebook WHERE name='Falls';
 14
 15     DBMS_LOB.OPEN(directions, DBMS_LOB.LOB_READWRITE);
 16
 17     first_direction := 'across the Bridge.';
 18     amount := LENGTH(first_direction);
 19     offset := 1;
 20     DBMS_LOB.WRITE(directions, amount, offset, first_direction);
 21
 22     more_directions := ' right.';
 23     DBMS_LOB.WRITEAPPEND(directions,LENGTH(more_directions), more_directions);
 24
 25     more_directions := ' more.';
 26     DBMS_LOB.WRITEAPPEND(directions,LENGTH(more_directions), more_directions);
 27
 28     DBMS_LOB.CLOSE(directions);
 29  END;
 30  /

PL/SQL procedure successfully completed.

SQL>
SQL> SET LONG 2000
SQL> COLUMN directions WORD_WRAPPED FORMAT A70
SQL>
SQL> SELECT directions FROM facebook WHERE name='Falls';

DIRECTIONS
----------------------------------------------------------------------
across the Bridge. right. more.

SQL>
SQL>
SQL>
SQL> drop table facebook;

Table dropped.

SQL> drop directory bfile_data;

Directory dropped.

SQL>
21. 42. CLOB
21. 42. 1. Clob type column and clob type variable
21. 42. 2. Insert into returning into clob
21. 42. 3. Save data to clob type column
21. 42. 4. Writes into a CLOB
21. 42. 5. Demonstrations of SQL functions being applied to CLOB values
21. 42. 6. Retrieve the LOB locator created by the previous INSERT statement
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.