Clob veriable return
oracle 11.2.0
I have a procedure in a package that has an "OUT" variable as a varchar2. For example ...
PROCEDURE myproc(abc IN varchar2, xyz OUT varchar2);
I can pass in a string that is larger than 4000 characters into "abc" and it works fine. I can then store it as a CLOB no problem. When I read that CLOB and put it into "xyz", I can't do it. If I try to put it into xyz using DBMS_LOB.read(myclob, clobsize, 1, xyz), then I get saying that there is a size constraint on xyz. If I create an internal variable called ...
MNO VARCHAR2(32000);
And say DBMS_LOB.read(myclob, clobsize, 1, MNO), then that works fine. When I try to pass it back into xyz, it truncates and only sends back the first 4000 characters. I have tried making it a function, and all kind of variations, but I cannot send back more than 4000 characters. I have also searched the web for an explanation, but nowhere does it say there is a size restriction on either incoming or outgoing variables.
To get around this, I can send back a CLOB and let the calling program do the work, or I can send back 2 smaller variables that are less than 4000 chars each and let the calling program concat them together. I am looking for any solutions to make the original setup work. Do you know of any limitations or something I can try?
You have to look at the caller procedure that calls myproc. What variable do you use in this procedure to retrieve the result of the OUT parameter?
create or replace procedure dropme (xyz out varchar2)
is
begin
xyz := 'Hello world';
end;
declare
abc varchar2(1);
begin
dropme(abc);
end;
Error at line 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "PROD.DROPME", line 4
ORA-06512: at line 4This rang a bell, and apparently I posted this question myself a long time ago B-)
Maximum VARCHAR2 length in stored procedure parameter
Edited by: InoL on Aug 31, 2011 1:31 PM
Similar Messages
-
Java.sql.Types.CLOB not returned
When I run the following on an oracle 8.1.7 server using thin/OCI driver on a table with a CLOB column,
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getColumns( null, null, tableName, "%" );
while (rs.next()){
int colType = (int)rs.getShort(5);
I dont get java.sql.Types.CLOB returned in colType, instead I get java.sql.Types.OTHER.
However, after a query on the same table, the result set metadata.getColumnType() returns java.sql.Types.CLOB.
Any ideas?
Thanks in advanceYou can't do that. You can't do it in SQL either: there's no way to call a stored procedure without providing parameters of a specific type.
There are two things you can do, however: one is to declare the parameter as VARCHAR and hope it's not a BLOB or something that the db will not automatically convert to VARCHAR and the other is to do a SELECT in the procedure you are calling instead of returning the value as an output parameter. The second option is better in that you can then use ResultSet.getObject() from Java and obtain the correct object type, not a String you might need to parse afterwards.
Alin. -
Error While returning CLOB back to Front End Application
Hi All,
I have stored procedure which generate XML CLOB and returns CLOB back to front end application.
But when my CLOB exceeds some limit the front end application is not able get the CLOB.
Following is the error i am getting.
Procedure call to stored procedure
_len number;
l_buf VARCHAR2(32767);
v_ret_clob CLOB:=' ';
begin
Orcl_Proc_Ctrl_4_Xml.EXECUTE_CONTROL(v_clob,v_ret_clob);
l_len := dbms_lob.getlength(v_ret_clob);
dbms_output.put_line('the return size OF CLOB------> '||l_len);
dbms_lob.read(v_ret_clob, l_len, 1, l_buf);
virsa_dbms_output(l_buf,100);
end;
Error Output
the return size OF CLOB------> 113906
BEGIN test_oraact1019; END;
ERROR at line 1:
ORA-21560: argument 2 is null, invalid, or out of range
ORA-06512: at "SYS.DBMS_LOB", line 715
ORA-06512: at "APPS.TEST_ORAACT1019", line 16
ORA-06512: at line 1
I am able to get the Size of CLOB but when i try give back to Front end application it is not properly passing CLOB.
Any help on this.
Thanks in advance
PrashantPlease also post this in the XML DB forum:
XML DB -
My Task is To Parse a XML Document to Return CLOB's
Hi folks
I am writing this mail in the hope of getting a help.Please
give me a shoulder to keep me going.
The task is to parse a XML document for a specific Tag and
read the Tag content in CLOB to return CLOB.
I know that the writetoclob will do the job as
per oracle documentation.
I am giving the code where i got stuck.
Please help me complete my rest of coding.
Thanks
Input variables are
XMLin in CLOB, -- Incoming XML Document Structure
Partype in varchar2, -- Tagname
Result out CLOB -- Return Tag value CLOB data type.
My Code : -
Declare
p xmlparser.parser;
d xmldom.DOMDocument;
e xmldom.DOMElement;
nl xmldom.DOMNodeList;
n xmldom.DOMNode;
tagvalue varchar2(255);
paramsIn Clob;
result CLOB;
BEGIN
--loading SecXML
dbms_lob.createtemporary(paramsIn,true);
dbms_lob.append(paramsIn,XMLin);
--dbms_output.put_line('ParsebyTag ='||Partype);
--defining parser
p := xmlparser.newparser;
xmlparser.parseClob(p,paramsIn);
d := xmlparser.getDocument(p);
--get tagvalue
nl := xmldom.getElementsByTagName(d,partype);
n := xmldom.item(nl,0);
IF xmldom.getlength (nl) > 0
THEN
n := xmldom.item (nl, 0);
=>=>=> => xmldom.writetoclob (n, result); <=<=<=<=<=<=====
END IF;
return; -- from a procedure
The above line marked with a arrow does not work for CLOB Variables.
Please explain with a corrected code to complete this task.
Thanks for reading my request.
Please reply to this message poster as i am frequently
checking this to see a answer.
my email is [email protected]
Balaji.First, you have 2 variables with the same name,
Second, let me show you what is that you need to do:
PROCEDURE WriteDataToClob(XMLin in CLOB, Partype in varchar2, Result out CLOB) IS
Declare
p xmlparser.parser;
d xmldom.DOMDocument;
e xmldom.DOMElement;
nl xmldom.DOMNodeList;
n xmldom.DOMNode;
tagvalue varchar2(255);
TempClob Clob;
BEGIN
--Create a temporary clob
dbms_lob.createtemporary(TempClob,true);
--loading SecXML
--defining parser
p := xmlparser.newparser;
xmlparser.parseClob(p,XMLin);
d := xmlparser.getDocument(p);
--get tagvalue
nl := xmldom.getElementsByTagName(d,partype);
n := xmldom.item(nl,0);
IF xmldom.getlength (nl) > 0 THEN
n := xmldom.item (nl, 0);
xmldom.writetoclob (n, TempClob );
END IF;
Result := TempClob;
dbms_lob.FreeTemporary(TempClob);
END; -
Data of column datatype CLOB is moved to other columns of the same table
Hi all,
I have an issue with the tables having a CLOB datatype field.
When executing a simple query on a table with a column of type CLOB it returns error [POL-2403] value too large for column.
SQL> desc od_stock_nbcst_notes;
Name Null? Type
OD_STOCKID N NUMBER
NBC_SERVICETYPE N VARCHAR(40)
LANGUAGECODE N VARCHAR(8)
AU_USERIDINS Y NUMBER
INSERTDATE Y DATE
AU_USERIDUPD Y NUMBER
MODIFYDATE Y DATE
VERSION Y SMALLINT(4)
DBUSERINS Y VARCHAR(120)
DBUSERUPD Y VARCHAR(120)
TEXT Y CLOB(2000000000)
NBC_PROVIDERCODE N VARCHAR(40)
SQL> select * from od_stock_nbcst_notes;
[POL-2403] value too large for column
Checking deeply, some of the rows have got the data of the CLOB column moved in another column of the table.
When doing select length(nbc_providercode) the length is bigger than the datatype of the field (varchar(40)).
When doing substr(nbc_providercode,1,40) to see the content of the field, a portion of the Clob data is retrieved.
SQL> select max(length(nbc_providercode)) from od_stock_nbcst_notes;
MAX(LENGTH(NBC_PROVIDERCODE))
162
Choosing one random record, this is the stored information.
SQL> select length(nbc_providerCode), text from od_stock_nbcst_notes where length(nbc_providerCode)=52;
LENGTH(NBC_PROVIDERCODE) | TEXT
-------------------------+-----------
52 | poucos me
SQL> select nbc_providerCode from od_stock_nbcst_notes where length(nbc_providerCode)=52;
[POL-2403] value too large for column
SQL> select substr(nbc_providercode,1,40) from od_stock_nbcst_notes where length(nbc_providercode)=52 ;
SUBSTR(NBC_PROVIDERCODE
Aproveite e deixe o seu carro no parque
The content of the field is part of the content of the field text (datatype CLOB, containts an XML)!!!
The right content of the field must be 'MTS' (retrieved from Central DB).
The CLOB is being inserted into the Central DB, not into the Client ODB. Data is synchronized from CDB to ODB and the data is reaching the client in a wrong way.
The issue can be recreated all the time in the same DB, but between different users the "corrupted" records are different.
Any idea?939569 wrote:
Hello,
I am using Oracle 11.2, I would like to use SQL to update one column based on values of other rows at the same table. Here are the details:
create table TB_test (myId number(4), crtTs date, updTs date);
insert into tb_test(1, to_date('20110101', 'yyyymmdd'), null);
insert into tb_test(1, to_date('20110201', 'yyyymmdd'), null);
insert into tb_test(1, to_date('20110301', 'yyyymmdd'), null);
insert into tb_test(2, to_date('20110901', 'yyyymmdd'), null);
insert into tb_test(2, to_date('20110902', 'yyyymmdd'), null);
After running the SQL, I would like have the following result:
1, 20110101, 20110201
1, 20110201, 20110301
1, 20110301, null
2, 20110901, 20110902
2, 20110902, null
Thanks for your suggestion.How do I ask a question on the forums?
SQL and PL/SQL FAQ -
How to formulate SQL that need to use some XML data in a clob?
Hi,
We just created a new 8i table that has some regular fields as well as a clob field that contains XML data. How could I bring back the value of a spcific element in the XML field and compare it against a regular field? For example, I want to make sure the value in field A is not the same as the value of a specific element in field b. Your help is very much appreciated.
select * from X
where X.a <> X.b.elementZDepending on how complex your XML data is, you can write a simple function that does a string search of the CLOB and returns the value of the tag you are looking at. Then you can compare the value of the tag and the value of the the column.
select * from X
where x.a <> getTagValue(X.b,'elementZ')
Check out the DBMS_LOB package. -
How can i insert more clob objects into oracle9i?
my env:
os: windows server 2003 ent sp2
php:=5.2.3
oracle : 9.0.0.8
i look at this article :
http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/fuecks_lobs.html
but ,i want insert two clob into the oracle ....
Inserting a LOB
To INSERT an internal LOB, you first need to initialize the LOB using the respective Oracle EMPTY_BLOB or EMPTY_CLOB functions—you cannot update a LOB that contains a NULL value.
Once initialized, you then bind the column to a PHP OCI-Lob object and update the LOB content via the object's save() method.
The following script provides an example, returning the LOB type from the INSERT query:
<?php
// connect to DB etc...
$sql = "INSERT INTO
mylobs
id,
mylob
VALUES
mylobs_id_seq.NEXTVAL,
--Initialize as an empty CLOB
EMPTY_CLOB()
RETURNING
--Return the LOB locator
mylob INTO :mylob_loc";
$stmt = oci_parse($conn, $sql);
// Creates an "empty" OCI-Lob object to bind to the locator
$myLOB = oci_new_descriptor($conn, OCI_D_LOB);
// Bind the returned Oracle LOB locator to the PHP LOB object
oci_bind_by_name($stmt, ":mylob_loc", $myLOB, -1, OCI_B_CLOB);
// Execute the statement using , OCI_DEFAULT - as a transaction
oci_execute($stmt, OCI_DEFAULT)
or die ("Unable to execute query\n");
// Now save a value to the LOB
if ( !$myLOB->save('INSERT: '.date('H:i:s',time())) ) {
// On error, rollback the transaction
oci_rollback($conn);
} else {
// On success, commit the transaction
oci_commit($conn);
// Free resources
oci_free_statement($stmt);
$myLOB->free();
// disconnect from DB etc.
?>Use something like:
sql = "INSERT INTO mylobs (id, mylob1, mylob2) VALUES
(mylobs_id_seq.NEXTVAL, EMPTY_CLOB(), EMPTY_CLOB()) RETURNING
mylob1, mylob2 INTO :mylob_loc1, :mylob_loc2";
You'll need to allocated two lob descriptors and bind both to the statement.
-- cj -
SQL Developer Vs Aqua Studio Clob Size support
Hi,
I'm trying to run a query against 10g which returns huge volume of data.
In Aqua Studio the clob is returned, but in SQL Developer I didn't get any result. Is there any settings I've to do in SQL Developer to support larger volume.
Your help/pointer is appreciated.
Thanks
SenthilWhen positioned in the result cell, there should be a button (...) to expand the contents. Does that work?
K. -
Clob Handling In WebLogic 6.0 with SP1
In Weblogic V5.10sp8
I have a block of code that looks up a very large clob and appends some
text to the end of it and
writes the new larger clob back to the same row same column.
part of the code looks like this.
char[] buffer = this.getBuffer():
java.sql.ResultSet rs = this.getResultSet();
oracle.sql.CLOB myClob =
(oracle.sql.CLOB)rs.getClob("file_content");
myClob.putChars( myClob.length() + 1, buffer);
We are moving to Weblogic V6.0sp1.
The getClob method on a ResultSet now returns a
weblogic.jdbc.oci.Clob which does not have a putChars method.
The best it has is getCharacterOutputStream() method
that returns a java.io.Writer which only allows me to write to the
beginning of the clob.
Question:
In Weblogic V6 how can I get a reference to a huge Clob in the database,
and just write
a little be of text to the end of it, without moving the whole thing
over the wire, twice.
Thanks.
John Xu.this is a slight correction
and a second plea for help
see comments in line and below
"John Xu" <[email protected]> wrote in message
news:[email protected]...
In Weblogic V5.10sp8
I have a block of code that looks up a very large clob and appends some
text to the end of it and
writes the new larger clob back to the same row same column.
part of the code looks like this.
char[] buffer = this.getBuffer():
java.sql.ResultSet rs = this.getResultSet();
oracle.sql.CLOB myClob =
(oracle.sql.CLOB)rs.getClob("file_content");
myClob.putChars( myClob.length() + 1, buffer);
We are moving to Weblogic V6.0sp1.
The getClob method on a ResultSet now returns a
weblogic.jdbc.oci.Clob which does not have a putChars method.no, getClob does not return a
weblogic.jdbc.oci.Clob
it returns a
weblogic.jdbc.rmi.SerialClob
which is also unable to write to the end of the Clob
The best it has is getCharacterOutputStream() method
that returns a java.io.Writer which only allows me to write to the
beginning of the clob.
Question:
In Weblogic V6 how can I get a reference to a huge Clob in the database,
and just write
a little be of text to the end of it, without moving the whole thing
over the wire, twice.
Thanks.
John Xu.
here is the full method that used to work in Weblogic 5.1 sp8
in Weblogic 6.0 sp1 it now throws a ClassCastException saying
you can't cast weblogic.jdbc.rmi.SerialClob to a oracle.sql.CLOB.
I need access to the putChars method on the oracle.sql.CLOB
to write to the end of the Clob
PLEASE HELP
public void push(int tbfId, char[] buffer) throws RemoteException {
String methodName = "TicketReaderImpl.push";
String sqlFetch = "SELECT file_content FROM ticketbatchfilecontent
WHERE tbf_id = ? FOR UPDATE";
String sqlUpdate = "UPDATE ticketbatchfilecontent SET file_content =
?, update_ts=SYSDATE WHERE tbf_id = ?";
Connection conn = null;
PreparedStatement psFetch = null;
PreparedStatement psUpdate = null;
ResultSet rs = null;
OnexTransaction ot = null;
try {
ot = OnexTransaction.getInstance(methodName);
ot.begin();
conn = PersistenceManager.getDSConnection();
psFetch = conn.prepareStatement(sqlFetch);
psFetch.setInt(1,tbfId);
rs = psFetch.executeQuery();
if (rs.next()) {
oracle.sql.CLOB myClob =
(oracle.sql.CLOB)rs.getClob("file_content");
myClob.putChars( myClob.length() + 1, buffer);
psUpdate = conn.prepareStatement(sqlUpdate);
psUpdate.setClob(1,myClob);
psUpdate.setInt(2,tbfId);
psUpdate.executeUpdate();
ot.commit();
} else {
ot.commit();
throw new DatabaseException(methodName+": couldn't find
tbfId ="+tbfId);
} catch ( Exception e ) {
throw new OnexSystemException(methodName,e);
} finally {
DBUtil.close(methodName,rs);
DBUtil.close(methodName,psFetch);
DBUtil.close(methodName,psUpdate);
DBUtil.close(methodName,conn);
OnexTransaction.close(ot); -
Hi,
I face the following error, i use the oracle jdbc driver as db driver and i use the same ojdbc14.jar file as the project library, but when i try to cast the clob object return from resutlset it throw me class cast exception, i did print out the class name it shown oracle.sql.CLOB, but when i cast the object to oracle.sql.CLOB it still show me the error.
Do you have any idea what is wrong?
====================// java code
import java.sql.Clob;
import oracle.sql.CLOB;
Clob clob = null;
if ( resultSet.next() )
clob = resultSet.getClob( 1 );
logger.debug( "resultSet.getClass() is " + resultSet.getClass() );
logger.debug( "clob.getClass() is " + clob.getClass() );
logger.debug( "clob is " + clob );
logger.debug( "(clob instanceof oracle.sql.CLOB) is " + (clob instanceof oracle.sql.CLOB));
CLOB oraClob = (CLOB)clob; // this is where the class cast exception occur
====================// log file
[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- selectUpdateStatement is [email protected]d5b222
[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- resultSet.getClass() is class oracle.jdbc.driver.OracleResultSetImpl
[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- clob.getClass() is class oracle.sql.CLOB
[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- clob is oracle.sql.CLOB@1a21321
[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- (clob instanceof oracle.sql.CLOB) is false
[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- error
java.lang.ClassCastExceptionSee JDBC error for CLOB
-
CLOB.getAsciiStream problem in 11gR2 with temp CLOB internal JVM
Hello,
i have a problem with using a termporary CLOB in PL/SQL that is going to be written with Java Code that runs inside Oracle Database (Internal JVM). The code works without problem in Oracle 11g R1 (11.1.0.7.0) but does not with Oracle 11g R2 (12.2.0.1.0). The example follows:
<b>Table Description:</b>
NAME Null? Type
ID NOT NULL NUMBER(*,0)
FILE_TYPE NOT NULL NUMBER(*,0)
INSERT_DATE NOT NULL DATE
PROCESSED NOT NULL NUMBER(*,0)
LFIELD001 CLOB(4000)
BFIELD001 BLOB(4000)
FILE_NAME VARCHAR2(4000)
<b>PL/SQL Example Run:</b>
DECLARE
clb CLOB;
p_result NUMBER; p_err VARCHAR2(4000);
t BLOB;
BEGIN
SELECT bfield001
INTO t
FROM file_data
WHERE id = 200;
clb := java_utils.clob_zipdecompress(t, 'BANKFILE_', p_result);
-- Output the results
dbms_output.put_line(SubStr('p_result = '||TO_CHAR(p_result), 1, 255));
dbms_output.put_line(SubStr('p_err = '||p_err, 1, 255));
dbms_output.put_line(SubStr('p_return_clob = '||SUBSTR(clb, 1,255), 1, 255));
END;
<b>Package example </b>
PACKAGE JAVA_UTILS
IS
-- Decompress a BLOB in ZIP format to a CLOB and return it with specified contained filename
FUNCTION clob_zipdecompress(p_blob IN BLOB, p_fname IN VARCHAR2, p_result OUT NUMBER)
RETURN CLOB;
END JAVA_UTILS;
PACKAGE BODY JAVA_UTILS
IS
-- Decompress a BLOB in ZIP format to a CLOB and return it with specified contained filename
FUNCTION clob_zipdecompress(p_blob IN BLOB, p_clob IN CLOB, p_fname IN VARCHAR2)
RETURN NUMBER
AS LANGUAGE JAVA NAME 'java_utils.Compress.ZipDecompress(oracle.sql.BLOB, oracle.sql.CLOB, java.lang.String) return int';
FUNCTION clob_zipdecompress(p_blob IN BLOB, p_fname IN VARCHAR2, p_result OUT NUMBER)
RETURN CLOB
IS
l_clob CLOB; l_result NUMBER;
BEGIN
IF p_blob IS NULL THEN
RETURN NULL;
END IF;
DBMS_LOB.createtemporary(l_clob, TRUE);
p_result := clob_zipdecompress(p_blob, l_clob, p_fname);
RETURN l_clob;
END clob_zipdecompress;
END JAVA_UTILS;
<b>Java Function Example simplified </b>
package java_utils;
import java.lang.*;
import oracle.sql.*;
import java.io.*;
import java.util.zip.*;
public class Compress
* Decompresses the BLOB into CLOB
* @param blob the source BLOB (compressed binary data)
* @param clob the target CLOB (will hold plain text) it should be an empty CLOB retrieved for
example with dbms_lob.createtemporary(l_clob,true);
* @throws Exception mostly I/O exception if ever
public static int ZipDecompress(BLOB blob, CLOB clob, String fname, String[] err)
OutputStream out; ZipInputStream z; ZipEntry ze; String zeName; byte[] buffer; int cnt;
boolean found = false;
try {
out = clob.setAsciiStream(0L); // Here it fails
catch (Exception ex) { err[0] = ex.getMessage(); return -1; }
return 0;
The execution of the example works well in 11gR1 but in 11gR2 returns error : <b>Invalid argument(s) in call. </b>
Any idea why this is happening?
Any help will be appreciated.
DionyssisHi Dionyssis:
Replace:
clob.setAsciiStream(0L); // Here it fails
by:
clob.setAsciiStream(1L);
the CLOB Api was changed from early implementation of Oracle to the standard implementation.
HTH, Marcelo. -
JAVA
Initially our Java servlet used ojdbc4.jar to connect to oracle database . After migrating to Oracle 11g database, we are facing difficulties to read clob data returned from a oracle function. This was working fine in the previous DB versions.
We later decided to use ojdbc6.jar to connect to Oracle 11g database but that didn't help either.
The challenge is we were able to read clob data only upto a certain length using substring say around 4000 characters. If we try to read a entire clob data to its length the DB connection gets closed.
TOAD
We got the same issue "Connection Closed" issue when running a direct SQL using TOAD Oracle Client.
I'm pretty sure the stored procedure works good as i'm able to query its length. I believe the problem lies within the clob serialization part by JDBC drivers.
Any help is much appreciated!!!
P.S: The oracle DB is located remotely and we usually establish VPN tunnel to connect to the Oracle DB instance for Java Servlet to communicate.
Thank You
ShashiYou say a function. Do you have a resultset? If so, I believe it is possible to fetch data of a specific column through an InputStream. That would minimize the memory needed by the driver to provide the data to you. When you say the problem happens when you fetch more data, I am inclined to think it is because of a lack of memory that it fails. When things break inside the driver I can imagine that a cleanup step performed as a reaction to the failure is to close the connection to the database, but that's conjecture on my part.
Note that what you say here does smell like a driver bug relating to function/procedure calls, so it might be worth reporting it to Oracle if you can figure out how. -
Errors while using plsql clob document in notification email
bq. hello
I am having a problem sending a plsql clob document in a notification email.Basically the procedure retrives some rows of data from the database and formats it as HTML before converting to clob. The email is generated fine when only a couple of rows are generated. however when the rows increase the workflow errors. we are using oracle ERP
---------------------------------Error Message-----
An Error occurred in the following Event Subscription: Event Subscription
Event Error Name: WFE_DISPATCH_GEN_ERR
Event Error Message: 3835: Error '-20002 - ORA-20002: 2018: Unable to generate the notification XML. Caused by: 2020: Error when getting notification content. Caused by: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Wf_Notification.NTF_Table(8, H)
BATCH_INFO.Batch Information(209112, text/html)
Wf_Notification.GetAttrClob(263883, BATCH_INFO, text/html)
Wf_Notification.oldGetAttrClob(263883, BATCH_INFO, text/html)
WF_NOTIFICATION.GetFullBody(nid => 263883, disptype => text/html)
WF_MAIL.GetLOBMessage3(nid => 263883, ' encountered during execution of Generate function 'WF_XML.Generate' for event 'oracle.apps.wf.notification.send'.
Event Error Stack:
WF_MAIL.GetLOBMessage3(263883, WFMAIL, 2020: Error when getting notification content. Caused by: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Wf_Notification.NTF_Table(8, H)
BATCH_INFO.Batch Information(209112, text/html)
Wf_Notification.GetAttrClob(263883, BATCH_INFO, text/html)
Wf_Notification.oldGetAttrClob(263883, BATCH_INFO, text/html)
WF_NOTIFICATION.GetFullBody(nid => 263883, disptype => text/html)
WF_MAIL.GetLOBMessage3(nid => 263883, r_ntf_pref => MAILHTML), Step -> Getting text/html body)
WF_XML.GenerateDoc(oracle.apps.wf.notification.send, 263883)
WF_XML.Generate(oracle.apps.wf.notification.send, 263883)
WF_XML.Generate(oracle.apps.wf.notification.send, 263883)
Wf_Event.setMessage(oracle.apps.wf.notification.send, 263883, WF_XML.Generate)
Wf_Event.dispatch_internal()
The Procedure is
bq. /********************************************************************************* \\ Procedure: BATCH_INFO \\ Purpose: Program displays batch level information. \\ *********************************************************************************/ \\ PROCEDURE batch_info ( \\ document_id IN VARCHAR2, \\ display_type IN VARCHAR2, \\ document IN OUT NOCOPY CLOB, \\ document_type IN OUT NOCOPY VARCHAR2 \\ ) \\ IS \\ table_width VARCHAR2 (8) := '100%'; \\ i PLS_INTEGER; \\ j PLS_INTEGER; \\ l_cells wf_notification.tdtype; \\ l_result VARCHAR2 (32767); \\ l_je_batch_name VARCHAR2 (100); \\ l_period_name VARCHAR2 (15); \\ l_control_total NUMBER; \\ l_running_total_dr NUMBER; \\ l_running_total_cr NUMBER; \\ l_document long; \\ cdoc clob; \\ amount NUMBER; \\ charbuff VARCHAR2(32767); \\ charbuff_size NUMBER; \\ CURSOR c_get_je (batch_id IN NUMBER) \\ IS \\ SELECT (SELECT description \\ FROM gl_lookups \\ WHERE lookup_type = 'BATCH_STATUS' \\ AND lookup_code = batch_status) batch_status, \\ je_source, \\ (SELECT user_je_category_name \\ FROM gl_je_categories \\ WHERE je_category_name = je_category) je_category, \\ period_name, batch_name, header_name, \\ header_running_total_dr_num debit, \\ header_running_total_cr_num credit \\ FROM apps.gl_je_batches_headers_v \\ WHERE je_batch_id = batch_id; \\ BEGIN \\ IF display_type = wf_notification.doc_text \\ THEN \\ document := NULL; \\ ELSE \\ /* ===========Second table Start=============*/ \\ j := 0; \\ i := 0; \\ j := 1; \\ /* Header*/ \\ l_cells (j) := 'S:' || 'Batch Status'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Journal Source'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Journal Category'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Period'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Batch Name'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Journal Name'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Journal Debit'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Journal Credit'; \\ j := j + 1; \\ i := 0; \\ /* Body*/ \\ SELECT NAME, default_period_name, control_total, \\ running_total_dr, running_total_cr \\ INTO l_je_batch_name, l_period_name, l_control_total, \\ l_running_total_dr, l_running_total_cr \\ FROM gl.gl_je_batches \\ WHERE je_batch_id = TO_NUMBER (document_id); \\ FOR histr IN c_get_je (TO_NUMBER (document_id)) \\ LOOP \\ l_cells (j) := 'S:' || histr.batch_status; \\ j := j + 1; \\ l_cells (j) := 'S:' || histr.je_source; \\ j := j + 1; \\ l_cells (j) := 'S:' || histr.je_category; \\ j := j + 1; \\ l_cells (j) := 'S:' || histr.period_name; \\ j := j + 1; \\ l_cells (j) := 'S:' || histr.batch_name; \\ j := j + 1; \\ l_cells (j) := 'S:' || histr.header_name; \\ j := j + 1; \\ l_cells (j) := \\ 'S:' \\ || NVL (TO_CHAR (histr.debit, \\ 'L999G999G999G999G999G999G999D99'), \\ '&' || 'nbsp;' \\ ); \\ j := j + 1; \\ l_cells (j) := \\ 'S:' \\ || NVL (TO_CHAR (histr.credit, \\ 'L999G999G999G999G999G999G999D99' \\ ), \\ '&' || 'nbsp;' \\ ); \\ j := j + 1; \\ i := i + 1; \\ END LOOP; \\ table_width := '100%'; \\ wf_notification.ntf_table (l_cells, 8, 'HL', l_result); \\ /* Write data to clob */ \\ -- create temp clob \\ dbms_lob.createTemporary(cdoc,false,dbms_lob.call); \\ charbuff_size:=length(l_result); \\ write html data to temp clob \\ dbms_lob.writeappend(cdoc,charbuff_size,l_result); \\ write temp clob to document \\ amount:=dbms_lob.getlength(cdoc); \\ dbms_lob.copy(document,cdoc,amount,1,1); \\ END IF; \\ document_type := 'text/html'; \\ EXCEPTION \\ WHEN OTHERS \\ THEN \\ wf_core.CONTEXT ('BATCH_INFO', 'Batch Information', document_id,display_type); \\ RAISE; \\ END batch_info;
Can somebody please guide me
thank youThe stack trace below the "ORA-06502: PL/SQL: numeric or value error: character string buffer too small" error suggests that this is being generated by the Wf_Notification.NTF_Table call. Given the way you have described the problem, I would assume that the HTML generated by that call for the data in l_cells is exceeding the length of your l_result variable (32767).
Have you checked the length of the data generated by this call for a single record and then divided 32767 by that number to work out the maximum number of rows you can support with this call?
If it is simply that you have too much data for WF_Notification.NTF_Table to produce the table within the 32767 limit, you try generating the HTML in smaller chunks and adding them to the CLOB bit by bit. For example, if 10 records work, then generate the HTML for 10 records, chop off the </table> from the result and add it to the clob. Then do the next 10 records (without the header this time) and chop off the <table> and </table> tags and add that to the clob. When you are done, add the closing </table> tag to the clob and return it.
I haven't done this with returning a clob, but I have done this with shorter strings to generate a HTML table with the standard look and feel but with headers in different places than could be done by default.
theFurryOne -
Is it possible in Oracle 8.1.6 to create a CLOB, read a file from the filesystem into the CLOB, and return the CLOB without connecting to the database?
Of course, you could also write your own Clob implementation. Haven't tried that before though. Something like:
class FileClob implements java.sql.Clob {
private final File file;
public FileClob(File file) {
this.file = file;
public long length() throws SQLException {
return this.file.length();
public Reader getCharacterStream() throws SQLException {
try {
return new FileReader(this.file);
} catch (FileNotFoundException e) {
throw new SQLException("File " + this.file.getAbsolutePath() + " not found: " + e);
// Remaining Clob methods implemented as necessary
// Or throw SQLException if not supported
}Exactly how many of the Clob methods you'd have to implement without throwing an error would depend on how the Clob is being used. If its read only, it should be fairly easy.
T -
A Run-Time error is raised by Visual Studio 2005Prof in my code when reading column of type clob and assigning its value to a std::string.
This is the code:
void GetClob( unsigned int col, std::string & clobStr )
if( resultSet_->isNull( col ) )
return;
oracle::occi::Clob clob = resultSet_->getClob( col );
if( clob.isNull() )
return;
clob.open( oracle::occi::OCCI_LOB_READONLY );
unsigned int clobSize = clob.length();
assert( clobSize > 0 );
clobStr.resize( clobSize );
clob.read( clobSize, (unsigned char *)&clobStr[ 0 ], clobSize );
clob.close();
The VS error occurs when leaving the scope of GetClob method and the message says:
Run-Time Check Failure #2 - Stack around the variable 'clob' was corrupted. I can see that clobStr variable contains the actual correct string.
======================
Even if I reduce the code like this:
void GetClob( unsigned int col, std::string & clobStr )
if( resultSet_->isNull( col ) )
return;
oracle::occi::Clob clob = resultSet_->getClob( col );
if( clob.isNull() )
return;
clob.open( oracle::occi::OCCI_LOB_READONLY );
// unsigned int clobSize = clob.length();
// assert( clobSize > 0 );
// clobStr.resize( clobSize );
// clob.read( clobSize, (unsigned char *)&clobStr[ 0 ], clobSize );
clob.close();
I still get the same error.
Please can you 1) comment on the above code, and/or 2) provide a sample code how reading columns of clob type should be handled?
I can read numeric columns w/o any problems.
I am using WinXP, occi 10.2.0.3.0 with the latest Patch 10 downloaded from here http://www.oracle.com/technology/tech/oci/occi/occidownloads.html.
Thank you for your help! This problem has taken me a lot of time already.Try the following code sample.
#include <iostream>
#include <fstream>
#include <occi.h>
using namespace oracle::occi;
using namespace std;
* The demo sample has starts from startDemo method. This method is called
* by main. startDemo calls other methods, the supporting methods for
* startDemo are,
* insertRows - insert the rows into the table
* dataRollBack - deletes the inserted rows
* populateClob - populates a given clob
* dumpClob - prints the clob as an integer stream
// These will tell the type of read/write we use
#define USE_NORM 1
#define USE_CHUN 2
#define USE_BUFF 3
/* Buffer Size */
#define BUFSIZE 200;
class occiClob
public:
string username;
string password;
string url;
void insertRows (Connection *conn)
throw (SQLException)
Statement *stmt = conn->createStatement ("INSERT INTO electronic_media(product_id,ad_id,ad_composite,ad_sourcetext) VALUES (:v1,:v2,:v3,:v4)");
Blob blob(conn);
blob.setEmpty();
Clob clob(conn);
clob.setEmpty();
stmt->setInt(1,6666);
stmt->setInt(2,11001);
stmt->setBlob(3,blob);
stmt->setClob(4,clob);
stmt->executeUpdate();
stmt->setSQL ("INSERT INTO electronic_media(product_id,ad_id,ad_composite,ad_sourcetext) VALUES (:v1, :v2, :v3, :v4)");
stmt->setInt(1,7777);
stmt->setInt(2,11001);
stmt->setBlob(3,blob);
stmt->setClob(4,clob);
stmt->executeUpdate();
stmt->setSQL ("INSERT INTO electronic_media(product_id,ad_id,ad_composite,ad_sourcetext) VALUES (:v1, :v2, :v3, :v4)");
stmt->setInt(1,8888);
stmt->setInt(2,11001);
stmt->setBlob(3,blob);
stmt->setClob(4,clob);
stmt->executeUpdate();
conn->commit();
conn->terminateStatement (stmt);
void dataRollBack (Connection *conn)
throw (SQLException)
Statement *stmt = conn->createStatement ("DELETE FROM electronic_media WHERE product_id=6666 AND ad_id=11001");
stmt->executeUpdate();
stmt->setSQL("DELETE FROM electronic_media WHERE product_id=7777 AND ad_id=11001");
stmt->executeUpdate();
stmt->setSQL("DELETE FROM electronic_media WHERE product_id=8888 AND ad_id=11001");
stmt->executeUpdate();
conn->commit();
conn->terminateStatement (stmt);
* populating the clob uses write method;
void populateClob (Clob &clob,unsigned int way)
throw (SQLException)
unsigned int bufsize=BUFSIZE;
if (way == USE_NORM)
cout << "Populating the Clob using write method" << endl;
unsigned int offset=1;
unsigned char *buffer = new unsigned char[bufsize];
strcpy((char *)buffer,
"Just for source text content(added using write method)");
unsigned int size=strlen((char *)buffer);
unsigned int bytesWritten=clob.write (size,buffer, size,offset);
//cout <<"Bytes Written : " << bytesWritten << endl;
delete[] buffer;
else if(way==USE_CHUN)
cout << "Populating the Clob using writeChunk method" << endl;
unsigned int offset=1;
unsigned int pieceCount = 4;
unsigned char *buffer = new unsigned char[bufsize*pieceCount];
strcpy((char *)buffer,
"Just for source text content(added using writeChunk method)");
unsigned int size=strlen((char *)buffer);
// Open the clob for writeChunk
clob.open(OCCI_LOB_READWRITE);
for (int i = 0; i < pieceCount; ++i,offset+=size)
clob.writeChunk(size,buffer,size,offset);
cout << "Clob Size " << clob.length() << endl;
delete[] buffer;
clob.close();
else if(way==USE_BUFF)
// Uses stream here
cout << "Populating the Clob using writeBuffer(Stream) method" << endl;
char file = (char )"clobdemo.dat";
char *buffer = new char[bufsize + 1];
ifstream inFile;
inFile.open(file,ios::in);
if (!inFile)
cout << "clobdemo.dat file not found\n";
delete[] buffer;
return;
unsigned int size;
Stream *strm=clob.getStream();
while(inFile)
memset (buffer, NULL, bufsize + 1);
inFile.read(buffer,bufsize);
strm->writeBuffer(buffer,strlen(buffer));
strcpy(buffer,"This piece for writeLastBuffer");
size=strlen(buffer);
strm->writeLastBuffer(buffer,size);
clob.closeStream(strm);
inFile.close();
delete[] buffer;
cout << "Populating the Clob - Success" << endl;
* printing the clob data as integer stream
void dumpClob (Clob &clob,unsigned int way)
throw (SQLException)
unsigned int size=BUFSIZE;
unsigned int offset = 1;
if (clob.isNull())
cout << "Clob is Null\n";
return;
unsigned int cloblen = clob.length();
cout << "Length of Clob : "<< cloblen << endl;
if (cloblen == 0)
return;
unsigned char *buffer= new unsigned char[size];
memset (buffer, NULL, size);
if (way==USE_NORM)
cout << "Dumping clob (using read ): ";
int bytesRead=clob.read(size,buffer,size,offset);
for (int i = 0; i < bytesRead; ++i)
cout << buffer;
cout << endl;
else if(way==USE_BUFF)
Stream *inStream = clob.getStream (1,0);
cout << "Dumping clob(using stream): ";
int bytesRead=(inStream->readBuffer((char *)buffer, size));
while (bytesRead > 0)
for (int i = 0; i < bytesRead; ++i)
cout << buffer[i];
bytesRead=(inStream->readBuffer((char *)buffer, size));
cout << endl;
clob.closeStream (inStream);
delete []buffer;
occiClob ()
* default values of username & password
username = "HR";
password = "HR";
url = "";
void setUsername (string u)
username = u;
void setPassword (string p)
password = p;
void setUrl (string u)
url = u;
void runSample ()
throw (SQLException)
Environment *env = Environment::createEnvironment (
Environment::DEFAULT);
Connection *conn = env->createConnection (username, password, url);
insertRows (conn);
// Selecting and modifying the clob column of the table
string sqlQuery =
"SELECT product_id,ad_id,ad_sourcetext FROM electronic_media FOR UPDATE";
Statement *stmt1 = conn->createStatement (sqlQuery);
ResultSet *rset1 = stmt1->executeQuery ();
cout << "Query :" << sqlQuery << endl;
unsigned int way=USE_NORM;
while (rset1->next ())
cout << "Product_id : " << (int)rset1->getInt(1) << endl;
cout << "Ad_id : " << (int)rset1->getInt(2) << endl;
Clob clob = rset1->getClob (3);
dumpClob (clob, USE_NORM);
if (way==USE_NORM)
populateClob(clob,USE_NORM);
way=USE_CHUN;
else if(way==USE_CHUN)
populateClob(clob,USE_CHUN);
way=USE_BUFF;
else if(way==USE_BUFF)
populateClob(clob,USE_BUFF);
way=USE_NORM;
stmt1->executeUpdate();
stmt1->closeResultSet (rset1);
// Printing after updating the clob content.
way = USE_BUFF;
sqlQuery = "SELECT product_id, ad_id, ad_sourcetext FROM electronic_media \
ORDER BY product_id";
Statement *stmt2 = conn->createStatement (sqlQuery);
ResultSet *rset2 = stmt2->executeQuery ();
cout << "Query :" << sqlQuery << endl;
while (rset2->next ())
cout << "Product_id : " << (int)rset2->getInt(1) << endl;
cout << "Ad_id : " << (int)rset2->getInt(2) << endl;
Clob clob = rset2->getClob (3);
if (way==USE_NORM)
dumpClob (clob, USE_NORM);
way=USE_BUFF;
else if(way==USE_BUFF)
dumpClob (clob, USE_BUFF);
way=USE_NORM;
stmt2->closeResultSet (rset2);
dataRollBack(conn);
conn->terminateStatement (stmt1);
conn->terminateStatement (stmt2);
env->terminateConnection (conn);
Environment::terminateEnvironment (env);
};//end of class occiClob
int main (void)
try
occiClob *b = new occiClob ();
b->setUsername ("HR");
b->setPassword ("HR");
b->runSample ();
catch (exception &e)
cout << e.what();
Maybe you are looking for
-
No matter how many times you ask... I DON'T WANT McAFEE!
You know why I signed up to this forum? Specifically to tell you to stop auto-checking the McAfee box for me when updating Flash. Thanks for wasting my time. With the frequency at which Flash Player is updated, this annoying McAfee option is single-h
-
Can i use a 60 watt charger on my macbook pro, 15 inch?
Is it safe to use a 60 watt charger on my macbook pro? Will it break the charger? Please reply..
-
I have been sent a word doc and I need to find errors and make comments and send it back to her. I want to add a side comment. I'm using pages and not sure how to do this? Help please?
-
Personal Data iview can be changed
ESS-PersonalInformation--PersonalData-Webdynpro based iview I have a scenario that i need Personal Data only for display purpose.There should not be Edit button inorder to edit. Can we make changes to the Personal Data iview
-
Re: Get video dimensions (resolution: Width x Height)
I dunno. Google search for JMF (Java Media Framework).