Hi Tom,
This is in continuation of my question on how can I insert streams of characters
coming from HTML form into a oracle database table CLOB column.
Actually I am passing some free flow text (series of characters say something like
what I am writing in this question) from html form. When this column is passed into the
procedure which inserts the record what should be the datatype and how can I insert this
incoming text into a CLOB column.
Regards
Bhavesh If you are calling a stored procedure, VARCHAR2.
tkyte@TKYTE816> create table t ( x int, y clob );
Table created.
tkyte@TKYTE816>
tkyte@TKYTE816> create or replace procedure p( p_x in int, p_new_text in varchar2 )
2 as
3 begin
4 insert into t values ( p_x, p_new_text );
5 end;
6 /
Procedure created.
tkyte@TKYTE816>
tkyte@TKYTE816> exec p(1, rpad('*',32000,'*') );
PL/SQL procedure successfully completed.
tkyte@TKYTE816> exec p(2, 'hello world' );
PL/SQL procedure successfully completed.
tkyte@TKYTE816>
tkyte@TKYTE816> select x, dbms_lob.getlength(y) from t;
X DBMS_LOB.GETLENGTH(Y)
---------- ---------------------
1 32000
2 11
2 rows selected.
followup to the comments below about the 4000 characters...
The difference is I used a BIND VARIABLE in the above example. PLSQL limits my bind
variable to 32k.
In SQL, the limit is 4,000 characters. Using straight SQL like that, without a bind
variable, you'll be limited to 4,000 characters.
See
http://asktom.oracle.com/~tkyte/Misc/LargeStrings.html
for another example of this. Followup to comment below... In Oracle8.0, the behavior of PLSQL is different then in 8.1 (which is what I used in my example. In Oracle8.0, you would code: 1 create or replace procedure p( p_x in int, p_new_text in varchar2 ) 2 as 3 l_clob clob; 4 begin 5 insert into t values ( p_x, empty_clob() ) returning y into l_clob; 6 dbms_lob.write( l_clob, 1, length(p_new_text), p_new_text ); 7* end;
| 1 |