Oracle PL/SQL/Data Type/nclob
Версия от 13:45, 26 мая 2010; (обсуждение)
Implicit conversion between CLOB and NCLOB object
SQL> CREATE TABLE nmyTable (
2 id INTEGER PRIMARY KEY,
3 nclobData NCLOB
4 );
Table created.
SQL> CREATE TABLE myTable (
2 id INTEGER PRIMARY KEY,
3 clobData CLOB
4 );
Table created.
SQL>
SQL> CREATE OR REPLACE TRIGGER before_myTable_update
2 BEFORE UPDATE
3 ON myTable
4 FOR EACH ROW
5 BEGIN
6 DBMS_OUTPUT.PUT_LINE("myTable changed");
7 DBMS_OUTPUT.PUT_LINE("Length = " || DBMS_LOB.GETLENGTH(:new.clobData));
8 END before_myTable_update;
9 /
Trigger created.
SQL>
SQL> drop table myTable;
Table dropped.
SQL> drop table nmyTable;
Table dropped.
nclobData type
SQL> CREATE TABLE nmyTable (
2 id INTEGER PRIMARY KEY,
3 nclobData NCLOB
4 );
Table created.
SQL> CREATE TABLE myTable (
2 id INTEGER PRIMARY KEY,
3 clobData CLOB
4 );
Table created.
SQL>
SQL> CREATE OR REPLACE PROCEDURE nclob_example
2 AS
3 clobVariable CLOB := "It is the east and Juliet is the sun";
4 nclobVariable NCLOB;
5 BEGIN
6 INSERT INTO nmyTable (id, nclobData) VALUES (1, clobVariable);
7
8 SELECT nclobData INTO clobVariable FROM nmyTable WHERE id = 1;
9
10 DBMS_OUTPUT.PUT_LINE("clobVariable = " || clobVariable);
11 END nclob_example;
12 /
Procedure created.
SQL>
SQL> drop table myTable;
Table dropped.
SQL> drop table nmyTable;
Table dropped.