DBMS_LOB Question
I have a problem I hope someone can help with.
I am reading CSV files and storing as a BLOB. Later I want to interpret the contents of the BLOB so I am using the DBMS_LOB.convertToCLOB procedure. How should I use the blob_csid and lang_context parameters if my original file was taken from a PC using one character set (e.g. WE8MSWIN1252) and the server database has a different character set (e.g. AL32UTF8)? The CSV file can contain extended characters like trade mark (™) and copyright (©) symbols.
Any help gratefully received,
Thanks.
Yes, you can according to http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#ADFNS012:
- see "Example: Modifying LOB Columns with a Trigger" section
- no DBMS_LOB mentioned in "Restrictions on Creating Triggers " section.
Similar Messages
-
Dbms_lob.instr question
Hello,
I have a field that holds CLOBs in the database. I have a textfield in which the user can enter a target string, then I hope to use dbms_lob.instr to search for the target string in CLOB. The code looks like: dbms_lob.instr(upper(I.COMMENTS),upper(nvl(:P26_SEARCH_NAME,I.COMMENTS))). If I replace the textfield value :P26_SEARCH_NAME with a string, the line works fine, but the current line returns the error
ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 6250, maximum: 4000) Can someone offer some help with a fix?Steven - Try v('P26_SEARCH_NAME') as a test to see if it makes any difference. If not, I can look at your test case if you put it on apex.oracle.com.
Scott -
A question about error with jasperserver for pdf and Apex
I have created a pdf report on jasperserver and I can call it from apex via a url and it displays fine. The url is this format {http://server:port/jasperserver/flow.html?_flowId=viewReportFlow&reportUnit=/reports/Apex/deptemp&output=pdf&deptNo=#DEPTNO#&j_username=un&j_password=pw}
However, I am trying to follow a stored procedure executed from Apex so it would not expose the username/pwd in the url like above.
If I am reading the apache error log correctly it is erroring in this piece of the code below where it executes {Dbms_Lob.writeAppend}
loop
begin
-- read the next chunk of binary data
Utl_Http.read_raw(vResponse, vData);
-- append it to our blob for the pdf file
Dbms_Lob.writeAppend
( lob_loc => vBlobRef
, amount => Utl_Raw.length(vData)
, buffer => vData
exception when utl_http.end_of_body then
exit; -- exit loop
end;
end loop;
Utl_Http.end_response(vResponse);}
The error log says this; HTTP-500 ORA-14453: attempt to use a LOB of a temporary table, whose data has alreadybeen purged\n
What is this error telling me and how can I correct it?
The stored procedure I am following is below but replaced the vReportURL with my url like above that works.
Thank you,
Mark
{CREATE OR REPLACE procedure runJasperReport(i_deptno in varchar2)
is
vReportURL varchar2(255);
vBlobRef blob;
vRequest Utl_Http.req;
vResponse Utl_Http.resp;
vData raw(32767);
begin
-- build URL to call the report
vReportURL := 'http://host:port/jasperserver/flow.html?_flowId=viewReportFlow'||
'&reportUnit=/reports/Apex/deptemp'||
'&output=pdf'||
'&j_username=un&j_password=pw'||
'&deptNo='||i_deptno;
-- get the blob reference
insert into demo_pdf (pdf_report)
values( empty_blob() )
returning pdf_report into vBlobRef;
-- Get the pdf file from JasperServer by simulating a report call from the browser
vRequest := Utl_Http.begin_request(vReportUrl);
Utl_Http.set_header(vRequest, 'User-Agent', 'Mozilla/4.0');
vResponse := Utl_Http.get_response(vRequest);
loop
begin
-- read the next chunk of binary data
Utl_Http.read_raw(vResponse, vData);
-- append it to our blob for the pdf file
Dbms_Lob.writeAppend
( lob_loc => vBlobRef
, amount => Utl_Raw.length(vData)
, buffer => vData
exception when utl_http.end_of_body then
exit; -- exit loop
end;
end loop;
Utl_Http.end_response(vResponse);
owa_util.mime_header('application/pdf',false);
htp.p('Content-length: ' || dbms_lob.getlength(vBlobRef));
owa_util.http_header_close;
wpg_docload.download_file(vBlobRef);
end runJasperReport;
/}I am new to working with working with jasperserver to apex interfacing, and also using utl_http with binary data.
But I guess typing my question down helped me figure out a way to make it work for me.
I combined info from http://www.oracle-base.com/articles/misc/RetrievingHTMLandBinariesIntoTablesOverHTTP.php
and from http://sqlcur.blogspot.com/2009_02_01_archive.html
to come up with this procedure.
{create or replace PROCEDURE download_file (p_url IN VARCHAR2) AS
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_blob BLOB;
l_raw RAW(32767);
BEGIN
-- Initialize the BLOB.
DBMS_LOB.createtemporary(l_blob, FALSE);
-- Make a HTTP request, like a browser had called it, and get the response
l_http_request := UTL_HTTP.begin_request(p_url);
Utl_Http.set_header(l_http_request, 'User-Agent', 'Mozilla/4.0');
l_http_response := UTL_HTTP.get_response(l_http_request);
-- Copy the response into the BLOB.
BEGIN
LOOP
UTL_HTTP.read_raw(l_http_response, l_raw, 32767);
DBMS_LOB.writeappend (l_blob, UTL_RAW.length(l_raw), l_raw);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.end_of_body THEN
UTL_HTTP.end_response(l_http_response);
END;
-- make it display in apex
owa_util.mime_header('application/pdf',false);
htp.p('Content-length: ' || dbms_lob.getlength(l_blob));
owa_util.http_header_close;
wpg_docload.download_file(l_blob);
-- Release the resources associated with the temporary LOB.
DBMS_LOB.freetemporary(l_blob);
EXCEPTION
WHEN OTHERS THEN
UTL_HTTP.end_response(l_http_response);
DBMS_LOB.freetemporary(l_blob);
RAISE;
END download_file; }
Don;t know what I did wrong, but I could not create an 'on-demand' process to call my procedure. I did not understand what it means when it says 'To create an on-demand page process, at least one application level process must be created with the type 'ON-DEMAND'.
so I had to use a blank page with a call to my procedure in the onload - before header process and that seems to work ok.
Thank you,
Mark -
Hi,
i´m working still along time with Oracle, but not very often with Lob-Types.
The docs and metalink didn´t helped me very much with the following questions:
1. What is the maximum length of a CLOB Datatype in PL/SQL (long ago it was 32767 Bytes, but now (10.2) ?)
2. Is empty_blob()/empty_clob() still necessary in 10.2? or when do i use it?
3. What is the maximum length of a pl/sql clob datatype when i update a clob column in a table?
declare
c clob;
begin
c:=.......... very long;
update t set col=c where id=1;
end;
4. Does a select in pl/sql return a locator or the data ob the lob (If locator, is there a easy way the read the contents of a clob without dbms_lob.read?)
5. Is there dbms_lob Package faster/better/??? then using insert/update/delete direct on the column?
Thanks
Marco
Message was edited by:
mpatzwahYou may find the following link useful:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#sthref173
E.g., search for CLOB yields:
CLOB objects can store up to (4 gigabytes -1) * (the value of the
CHUNK parameter of LOB storage) of character data.
If the tablespaces in your database are of standard block size,
and if you have used the default value of the CHUNK parameter
of LOB storage when creating a LOB column, then this is
equivalent to (4 gigabytes - 1) * (database block size).
CLOB objects have full transactional support. Changes made
through SQL, the DBMS_LOB package, or the Oracle Call
Interface (OCI) participate fully in the transaction.
CLOB value manipulations can be committed and rolled back.
However, you cannot save a CLOB locator in a PL/SQL or
OCI variable in one transaction and then use it in another
transaction or session. -
PDF file created from Oracle Report is created wrongly using dbms_lob
Hi,
Please help. It is very urgent.
I am using Oracle Developer 10gR2, Oracle Report 10.1.2 on Windows 2000.
I would like to attach the PDF file created by Oracle Report to the Notification sent from Workflow.
I use the following package procedure in my Workflow.
procedure Create_File_Attachment (document_id in varchar2, display_type in varchar2,
document in out blob, document_type in out varchar2)
is
l_itemtype varchar2(100);
l_itemkey varchar2(100);
l_output_directory varchar2(30);
l_filename varchar2(255);
src_loc bfile;
bdoc blob;
src_offset number := 1;
dst_offset number := 1;
amount number;
begin
l_itemtype := substr(document_id, 1, instr(document_id, ':') - 1);
l_itemkey := substr(document_id, instr(document_id, ':') + 1, length(document_id) - 2);
l_output_directory := 'USR_TMP_DIR';
l_filename := Wf_Engine.GetItemAttrText(l_itemtype, l_itemkey, 'ATR_FILENAME');
src_loc := bfilename(l_output_directory,l_filename);
dbms_lob.createTemporary(bdoc, FALSE, dbms_lob.call);
dbms_lob.fileopen(src_loc, dbms_lob.file_readonly);
dbms_lob.loadblobfromfile(bdoc,src_loc,dbms_lob.lobmaxsize,src_offset,dst_offset);
dbms_lob.fileclose(src_loc);
amount := dbms_lob.getLength(bdoc);
dbms_lob.copy(document,bdoc,amount,1,1);
document_type := 'application/pdf; name=attach.pdf';
end Create_File_Attachment;Oracle Report created the PDF file correctly (original.pdf).
I tried to attach the PDF into my Workflow.
I can see the file is attached (attach.pdf), but it cannot be opened.
The Adobe shows : 'A drawing error occured.' each time I open the attachment.
I compare the original.pdf and the attach.pdf
However, there is one specific difference
- in original.pdf, the line started with '.' (single period)
in attach.pdf, the line is started with '..' (two periods)
Thus the attachment cannot be opened.
After I delete the period, it can be opened.
Question:
- Has someone ever succeed in attaching the PDF created from Report?
- Are the codes above is wrong?
- Or perhaps the DBMS_LOB.LOADBLOBFROMFILE always double the single period on front of the line?
- Is there any solution on this?
Note:
I have succeed in attaching PDF files unless the PDF created by the Report.
Sorry for the long post.
Please help. It is very urgent.
Any help is appreciated.
Many thanks,
BuntoroHi,
Please help. It is very urgent.
I am using Oracle Developer 10gR2, Oracle Report 10.1.2 on Windows 2000.
I would like to attach the PDF file created by Oracle Report to the Notification sent from Workflow.
I use the following package procedure in my Workflow.
procedure Create_File_Attachment (document_id in varchar2, display_type in varchar2,
document in out blob, document_type in out varchar2)
is
l_itemtype varchar2(100);
l_itemkey varchar2(100);
l_output_directory varchar2(30);
l_filename varchar2(255);
src_loc bfile;
bdoc blob;
src_offset number := 1;
dst_offset number := 1;
amount number;
begin
l_itemtype := substr(document_id, 1, instr(document_id, ':') - 1);
l_itemkey := substr(document_id, instr(document_id, ':') + 1, length(document_id) - 2);
l_output_directory := 'USR_TMP_DIR';
l_filename := Wf_Engine.GetItemAttrText(l_itemtype, l_itemkey, 'ATR_FILENAME');
src_loc := bfilename(l_output_directory,l_filename);
dbms_lob.createTemporary(bdoc, FALSE, dbms_lob.call);
dbms_lob.fileopen(src_loc, dbms_lob.file_readonly);
dbms_lob.loadblobfromfile(bdoc,src_loc,dbms_lob.lobmaxsize,src_offset,dst_offset);
dbms_lob.fileclose(src_loc);
amount := dbms_lob.getLength(bdoc);
dbms_lob.copy(document,bdoc,amount,1,1);
document_type := 'application/pdf; name=attach.pdf';
end Create_File_Attachment;Oracle Report created the PDF file correctly (original.pdf).
I tried to attach the PDF into my Workflow.
I can see the file is attached (attach.pdf), but it cannot be opened.
The Adobe shows : 'A drawing error occured.' each time I open the attachment.
I compare the original.pdf and the attach.pdf
However, there is one specific difference
- in original.pdf, the line started with '.' (single period)
in attach.pdf, the line is started with '..' (two periods)
Thus the attachment cannot be opened.
After I delete the period, it can be opened.
Question:
- Has someone ever succeed in attaching the PDF created from Report?
- Are the codes above is wrong?
- Or perhaps the DBMS_LOB.LOADBLOBFROMFILE always double the single period on front of the line?
- Is there any solution on this?
Note:
I have succeed in attaching PDF files unless the PDF created by the Report.
Sorry for the long post.
Please help. It is very urgent.
Any help is appreciated.
Many thanks,
Buntoro -
Hi,
I have a need to open blob_content files from wwv_document$ and read/print them in a portlet. Can i do that using dbms_blob?. If so can somebody guide me the steps to follow? Else is there any other way sicne the files are really huge and i need to read from DB only.
Thanks in advance
nullA lot of the answer to your question depends on what is in your BLOB and what you are trying to do with it. If you can post more details about your end goals.. and what is being stored in your documents (MS Word Docs, Random Binary Files, Images, Text files... etc) I can post specific details about what statements to use.
In general you can use DBMS_LOB.READ to pull information directly out of a BLOB. See the Packages Reference documentation for details about the syntax. When you need to pass the BLOB locator, that is just what you get when you do a simple select on the BLOB_CONTENT column in the WWDOC_DOCUMENT$ table. -
Using dbms_lob append to insert text how do you insert a new line inbetween
DBMS_LOB.APPEND (P_TEXT,'* Operator Phone,');
---- inbetween I need to insert new I am using DBMS_LOB.APPEND (P_TEXT,CHR(10)); IS there amy better method?
DBMS_LOB.APPEND (P_TEXT,'* Operator Email Address,');Sorry if the question was not clear ---
Lets say in the folowing example every write append needs to start on a new line followed by text. How do we do that?
Do we add another writeappend(cvar,22, chr(10)); inbetween?
dbms_lob.writeappend(cvar, 19, '<root><book><title>');
dbms_lob.writeappend(cvar, length(r.title), r.title);
dbms_lob.writeappend(cvar, 14, '</title><desc>');
dbms_lob.writeappend(cvar, length(r.description), r.description);
dbms_lob.writeappend(cvar, 27, '</desc></book><author_name>');
dbms_lob.writeappend(cvar, length(r.author_name), r.author_name);
dbms_lob.writeappend(cvar, 21, '</author_name></root>');
Edited by: user521218 on May 7, 2009 12:34 PM -
Dbms_lob , where did my time go ?
Hi all
After using 10046 to identify the sql that is causing the slowness in a program “ less commits cause my program to go slower” i realised that i am missing something ,
There was a lot of time missing in the tkprof file , and no sql or wait event allocate the missing time , so i put the following test case together in an attempt to understand where the time is going .
Version of test database : 11.1.0.6.0
Name of test database: stdby ( :-) used my standby database)
Database non-default values
# Parameter Value1
1: audit_file_dest /u01/app/oracle/admin/stdby/adump
2: audit_trail DB
3: compatible 11.1.0.0.0
4: control_files /u01/app/oracle/oradata/stdby/control01.ctl
5: control_files /u01/app/oracle/oradata/stdby/control02.ctl
6: control_files /u01/app/oracle/oradata/stdby/control03.ctl
7: db_block_size 8192
8: db_domain
9: db_name stdby
10: db_recovery_file_dest /u01/app/oracle/flash_recovery_area
11: db_recovery_file_dest_size 2147483648
12: diagnostic_dest /u01/app/oracle
13: dispatchers (PROTOCOL=TCP) (SERVICE=stdbyXDB)
14: memory_target 314572800
15: open_cursors 300
16: processes 150
17: remote_login_passwordfile EXCLUSIVE
18: undo_tablespace UNDOTBS1More accurately I used existing example from http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4084920819312
I hope Tom does not mind .
create table t ( x clob );
create or replace procedure p( p_open_close in boolean default false,
p_iters in number default 100 )
as
l_clob clob;
begin
insert into t (x) values ( empty_clob() )
returning x into l_clob;
if ( p_open_close )
then
dbms_lob.open( l_clob, dbms_lob.lob_readwrite );
end if;
for i in 1 .. p_iters
loop
dbms_lob.WriteAppend( l_clob, 5, 'abcde' );
end loop;
if ( p_open_close )
then
dbms_lob.close( l_clob );
end if;
commit;
end;I did the tracing and the run of the pkg with this
alter session set timed_statistics = true;
alter session set max_dump_file_size = unlimited;
alter session set tracefile_identifier = 'test_clob_commit';
alter session set events '10046 trace name context forever, level 12';
exec p(TRUE,20000);
exitDid the tkprof of the 10046 trace file with
tkprof stdby_ora_3656_test_clob_commit.trc stdby_ora_3656_test_clob_commit.trc.tkp sort=(prsela,exeela,fchela) aggregate=yes waits=yes sys=yesWith output of
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 1 0.02 0.02 0 0 0 0
Execute 1 46.89 147.81 38915 235267 492471 1
Fetch 0 0.00 0.00 0 0 0 0
total 2 46.92 147.83 38915 235267 492471 1
Misses in library cache during parse: 1
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 2 0.00 0.00
SQL*Net message from client 2 0.00 0.00
latch: shared pool 24 0.05 0.07
latch: row cache objects 2 0.00 0.00
log file sync 1 0.01 0.01
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 117 0.11 0.10 0 0 2 0
Execute 426 0.37 0.40 6 4 9 2
Fetch 645 0.17 0.51 63 1507 0 1952
total 1188 0.65 1.03 69 1511 11 1954
Misses in library cache during parse: 22
Misses in library cache during execute: 22
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 19778 1.12 30.31
direct path write 19209 0.00 0.44
direct path read 19206 0.00 0.37
log file switch completion 8 0.20 0.70
latch: cache buffers lru chain 5 0.01 0.02
3 user SQL statements in session.
424 internal SQL statements in session.
427 SQL statements in session.And it’s here where the time is being lost.The time of the main pkg p(TRUE,2000) takes 147.83 sec, which is correct , but what is making this time up.
From sorted trace file
SQL ID : catnjk0zv6jz1
BEGIN p(TRUE,20000); END;
call count cpu elapsed disk query current rows
Parse 1 0.02 0.02 0 0 0 0
Execute 1 46.89 147.81 38915 235267 492471 1
Fetch 0 0.00 0.00 0 0 0 0
total 2 46.92 147.83 38915 235267 492471 1
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 81
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
latch: shared pool 24 0.05 0.07
latch: row cache objects 2 0.00 0.00
log file sync 1 0.01 0.01
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 0.00 0.00
SQL ID : db78fxqxwxt7r
select /*+ rule */ bucket, endpoint, col#, epvalue
from
histgrm$ where obj#=:1 and intcol#=:2 and row#=:3 order by bucket
intresting , oracle is still using the rule hint in 11g ?
call count cpu elapsed disk query current rows
Parse 3 0.00 0.00 0 0 0 0
Execute 98 0.05 0.05 0 0 0 0
Fetch 98 0.04 0.17 28 294 0 1538
total 199 0.10 0.22 28 294 0 1538
Misses in library cache during parse: 0
Optimizer mode: RULE
Parsing user id: SYS (recursive depth: 3)
Rows Row Source Operation
20 SORT ORDER BY (cr=3 pr=1 pw=1 time=8 us cost=0 size=0 card=0)
20 TABLE ACCESS CLUSTER HISTGRM$ (cr=3 pr=1 pw=1 time=11 us)
1 INDEX UNIQUE SCAN I_OBJ#_INTCOL# (cr=2 pr=0 pw=0 time=0 us)(object id 408)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 28 0.02 0.12
SQL ID : 5n1fs4m2n2y0r
select pos#,intcol#,col#,spare1,bo#,spare2,spare3
from
icol$ where obj#=:1
call count cpu elapsed disk query current rows
Parse 2 0.00 0.00 0 0 0 0
Execute 19 0.03 0.03 0 0 0 0
Fetch 60 0.00 0.04 1 120 0 41
total 81 0.04 0.08 1 120 0 41
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 2)
Rows Row Source Operation
1 TABLE ACCESS BY INDEX ROWID ICOL$ (cr=4 pr=0 pw=0 time=0 us cost=2 size=54 card=2)
1 INDEX RANGE SCAN I_ICOL1 (cr=3 pr=0 pw=0 time=0 us cost=1 size=0 card=2)(object id 42)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 1 0.04 0.04None of the parse , execute ,fetch and wait times makes up the 147.83 seconds.
So i turned to oracles trcanlzr.sql that Carlos Sierra wrote and parsed the same trace file to find the offending sql .
And it starts getting intrestting
Trace Analyzer 11.2.6.2 Report: trcanlzr_75835.html
stdby_ora_3656_test_clob_commit.trc (6970486 bytes)
Total Trace Response Time: 148.901 secs.
2009-MAY-03 20:03:51.771 (start of first db call in trace).
2009-MAY-03 20:06:20.672 (end of last db call in trace).
RESPONSE TIME SUMMARY
~~~~~~~~~~~~~~~~~~~~~
pct of pct of pct of
Time total Time total Time total
Response Time Component (in secs) resp time (in secs) resp time (in secs) resp time
CPU: 47.579 32.0%
Non-idle Wait: 0.467 0.3%
ET Unaccounted-for: 100.825 67.7%
Total Elapsed(1): 148.871 100.0%
Idle Wait: 0.001 0.0%
RT Unaccounted-for: 0.029 0.0%
Total Response(2): 148.901 100.0%
(1) Total Elapsed = "CPU" + "Non-Idle Wait" + "ET Unaccounted-for".
(2) Total Response = "Total Elapsed Time" + "Idle Wait" + "RT Unaccounted-for".
Total Accounted-for = "CPU" + "Non-Idle Wait" + "Idle Wait" = 148.872 secs.
Total Unccounted-for = "ET Unaccounted-for" + "RT Unaccounted-for" = 100.854 secs.{font:Courier}
{color:red}
{size:19}100.825 seconds Wow , that is a lot 67.7 % of the time is not accounted for {size}
{color}
{font}
I even used TVD$XTAT TriVaDis eXtended Tracefile Analysis Tool with the same conclution .
{font:Courier}
{color:green}
{size:19}Looking at the raw trace file i see a lot of lines like this{size}
{color}
{font}
WAIT #7: nam='direct path read' ela= 11 file number=4 first dba=355935 block cnt=1 obj#=71067 tim=1241337833498756
WAIT #7: nam='direct path write' ela= 12 file number=4 first dba=355936 block cnt=1 obj#=71067 tim=1241337833499153
WAIT #7: nam='db file sequential read' ela= 1095 file#=4 block#=399 blocks=1 obj#=71067 tim=1241337833501366{font:Courier}
{color:green}
{size:19}
What is even more interesting is the sql for "PARSING IN CURSOR #7" is not in the trace file !
The question is where is the time going or is the parser of the 10046 trace file just not putting the detail in ? How do i fix this, without speculating, if I do not know where the problem is ?
I thought of doing a strace on the process . Where else can i look for my 100 sec
Please point me in a direction where i can look for my 100,825 seconds as this is a test case with a production system that is loosing the same amount of time but with a lot more sql arround its dbms_lob.writeappend.
{size}
{color}
{font}
Edited by: user5174849 on 2009/05/16 11:17 PMuser5174849 wrote:
After using 10046 to identify the sql that is causing the slowness in a program “ less commits cause my program to go slower” i realised that i am missing something ,
There was a lot of time missing in the tkprof file , and no sql or wait event allocate the missing time , so i put the following test case together in an attempt to understand where the time is going .
Version of test database : 11.1.0.6.0
What is even more interesting is the sql for "PARSING IN CURSOR #7" is not in the trace file !
The question is where is the time going or is the parser of the 10046 trace file just not putting the detail in ? How do i fix this, without speculating, if I do not know where the problem is ?
I thought of doing a strace on the process . Where else can i look for my 100 sec
Please point me in a direction where i can look for my 100,825 seconds as this is a test case with a production system that is loosing the same amount of time but with a lot more sql arround its dbms_lob.writeappend.I guess that the separate cursor that is opened for the LOB operation is where the time is spent, and unfortunately this part is not very well exposed via the usual interfaces (V$SQL, 10046 trace file etc).
You might want to read this post where Kerry identifies the offending SQL via V$OPEN_CURSOR: http://kerryosborne.oracle-guy.com/2009/04/hidden-sql-why-cant-i-find-my-sql-text/
The waits of this cursor #7 are quite likely rather relevant since they probably show you what the LOB operation is waiting for.
The LOB is created with the default NOCACHE attribute therefore it's read and written using direct path operations.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Dbms_lob.loadfromfile help
sorry in advance if this is basic - SQL developer virgin here . . .
Using the examples in this document
http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10840/mm_uses.htm
specifically the code:
INSERT INTO soundtable(id, sound) VALUES (1, EMPTY_BLOB());
COMMIT;
DECLARE
f_lob BFILE := BFILENAME('AUDDIR','chimes.wav');
b_lob BLOB;
Lob BLOB;
Length INTEGER;
BEGIN
SELECT sound INTO b_lob FROM soundtable WHERE id=1 FOR UPDATE;
-- Open the LOBs.
dbms_lob.open(f_lob, dbms_lob.file_readonly);
dbms_lob.open(b_lob, dbms_lob.lob_readwrite);
dbms_lob.loadfromfile
(b_lob, f_lob, dbms_lob.getlength(f_lob));
-- Close the LOBs.
dbms_lob.close(b_lob);
dbms_lob.close(f_lob);
COMMIT;
-- Select the LOB:
SELECT sound INTO Lob FROM soundtable
WHERE ID = 1;
-- Opening the LOB is optional.
DBMS_LOB.OPEN (Lob, DBMS_LOB.LOB_READONLY);
-- Get the length of the LOB.
length := DBMS_LOB.GETLENGTH(Lob);
IF length IS NULL THEN
DBMS_OUTPUT.PUT_LINE('LOB is null.');
ELSE
DBMS_OUTPUT.PUT_LINE('The length is '|| length);
END IF;
-- Closing the LOB is mandatory if you have opened it.
DBMS_LOB.CLOSE (Lob);
END;
2 questions for anyone who has done this before or has an opinion:
1) In the initial insert -- INSERT INTO soundtable(id, sound) VALUES (1, EMPTY_BLOB()); -- if the value for the column "id" is sequence.next_val I could end up with an "id" of 3012 for example:
so how would I find out what value the "id" is before doing the next step:
SELECT sound INTO b_lob FROM soundtable WHERE id=1 FOR UPDATE;
I would have to do:
SELECT sound INTO b_lob FROM soundtable WHERE id=<whatever_was_generated_by_the_sequence> FOR UPDATE;
and if there are 10 people inserting at about the same time, how the heck am I supposed to know which "id" goes with which content file?
any help is appreciatedYou can use the returning clause to store the generated sequence value that was inserted into id into a variable, then reference that variable in the rest of your code, as demonstrated below.
SCOTT@10gXE> CREATE TABLE soundtable
2 (id NUMBER,
3 sound BLOB DEFAULT EMPTY_BLOB ())
4 /
Table created.
SCOTT@10gXE> CREATE SEQUENCE your_sequence
2 /
Sequence created.
SCOTT@10gXE> VARIABLE g_id_seq NUMBER
SCOTT@10gXE> INSERT INTO soundtable (id)
2 VALUES (your_sequence.NEXTVAL)
3 RETURNING id INTO :g_id_seq
4 /
1 row created.
SCOTT@10gXE> COMMIT
2 /
Commit complete.
SCOTT@10gXE> CREATE OR REPLACE DIRECTORY auddir AS 'C:\WINDOWS\Media'
2 /
Directory created.
SCOTT@10gXE> SET SERVEROUTPUT ON
SCOTT@10gXE> DECLARE
2 f_lob BFILE := BFILENAME ('AUDDIR', 'chimes.wav');
3 b_lob BLOB;
4 Lob BLOB;
5 Length INTEGER;
6 BEGIN
7
8 SELECT sound
9 INTO b_lob
10 FROM soundtable
11 WHERE id = :g_id_seq
12 FOR UPDATE;
13
14 dbms_lob.open (f_lob, dbms_lob.file_readonly);
15 dbms_lob.open (b_lob, dbms_lob.lob_readwrite);
16 dbms_lob.loadfromfile
17 (b_lob, f_lob, dbms_lob.getlength (f_lob));
18 dbms_lob.close(b_lob);
19 dbms_lob.close(f_lob);
20 COMMIT;
21
22 SELECT sound
23 INTO Lob
24 FROM soundtable
25 WHERE ID = :g_id_seq;
26 length := DBMS_LOB.GETLENGTH (Lob);
27 IF length IS NULL THEN
28 DBMS_OUTPUT.PUT_LINE ('LOB is null.');
29 ELSE
30 DBMS_OUTPUT.PUT_LINE ('The length is '|| length);
31 END IF;
32 END;
33 /
The length is 55776
PL/SQL procedure successfully completed.
SCOTT@10gXE> -
Hi all
I am using dbms_lob.erase to delete part of data in my Clob
My question is does dbms_lob.erase also free up the space allocated by previous content of my clob?
If not is there someway to do it? After .erase i want to populate clob with different set of data and the amount of data is bigget than existing size of clob
Thanks for all your helpGalia,
I hope this example illustrates your question
completely:
SQL> declare
2 clb clob;
3 orig varchar2(10) := '1234567890';
4 adds varchar2(3) := '456';
5 amnt number := 3;
6 begin
7
8 dbms_lob.createtemporary(clb,true);
9 dbms_lob.write(clb,10,1,orig);
10 dbms_output.put_line('Original content: ' || clb);
11 dbms_lob.erase(clb,amnt,4);
12 dbms_output.put_line('After-erase content: ' || clb);
13 dbms_lob.writeappend(clb,3,adds);
14 dbms_output.put_line('After-writeappend content: ' || clb);
15 dbms_lob.write(clb,3,4,adds);
16 dbms_output.put_line('After-write content: ' || clb);
17 amnt := dbms_lob.getlength(clb);
18 dbms_lob.erase(clb,amnt);
19 dbms_output.put_line('After-complete erase content: ' || clb);
20 dbms_lob.write(clb,20,1,orig || orig);
21 dbms_output.put_line('New content: ' || clb);
22 end;
23 /
Original content: 1234567890
After-erase content: 123 7890
After-writeappend content: 123 7890456
After-write content: 1234567890456
After-complete erase content:
New content: 12345678901234567890
 
PL/SQL procedure successfully completed.Rgds. -
Dbms_lob.getlength() returns different values
Hi !
I am not a developer.. So, possibly cannot answer developer specific question.
We have two instances running on 10.2.0.4 but both giving different value for
declare
xml varchar2(32676) :=
'SELECT XT_STRATEGY, ACCT_DESCRIPTION,sum(MON_PL) PL_MON ,sum(TUE_PL) PL_TUE,sum(WED_PL) PL_WED ,sum(THU_PL) PL_THU, sum(FRI_PL) PL_FRI, sum(WTD_PL) PL_WTDPL,sum(WTD_PREMIUM_PL) PL_WTDPRMPL, sum(MTD_PL) PL_MARKPL,sum(MTD_PREMIUM_PL) PL_MTDPRMPL,sum(YTD_PL) PL_YTDPL,sum(YTD_PREMIUM_PL) PL_YTDPRMPL,
DLC_REGION,DLC_ENTITY FROM (SELECT xt_strategy, acct_description ,case when blankout_date < to_char( to_date( fv[EOD] )+ (1 -to_char(to_date(to_date( fv[EOD] )),''D''))) then 0 else MON_PL end as MON_PL, case when blankout_date < to_char( to_date( fv[EOD] )+ (1 -to_char(to_date(to_date( fv[EOD] )),''D''))) then 0 else tue_pl end as tue_pl,
case when blankout_date < to_char( to_date( fv[EOD] )+ (1 -to_char(to_date(to_date( fv[EOD] )),''D''))) then 0 else WED_PL end as WED_PL, case when blankout_date < to_char( to_date( fv[EOD] )+ (1 -to_char(to_date(to_date( fv[EOD] )),''D''))) then 0 else THU_PL end as THU_PL,
case when blankout_date < to_char( to_date( fv[EOD] )+ (1 -to_char(to_date(to_date( fv[EOD] )),''D''))) then 0 else FRI_PL end as FRI_PL, case when blankout_date < to_char( to_date( fv[EOD] )+ (1 -to_char(to_date(to_date( fv[EOD] )),''D''))) then 0 else WTD_PL end as WTD_PL,
case when blankout_date < to_char( to_date( fv[EOD] )+ (1 -to_char(to_date(to_date( fv[EOD] )),''D''))) then 0 else WTD_PREMIUM_PL end as WTD_PREMIUM_PL,
case when blankout_date < (select actual_date from tbl_date where date_type = ''PLMonthStart'' and to_char(actual_date, ''MMYYYY'') = to_char(to_date( fv[EOD] ),''MMYYYY'')) then 0 else mtd_pl end as mtd_pl,
case when blankout_date < (select actual_date from tbl_date where date_type = ''PLMonthStart'' and to_char(actual_date, ''MMYYYY'') = to_char(to_date( fv[EOD] ),''MMYYYY'')) then 0 else MTD_PREMIUM_PL end as MTD_PREMIUM_PL,
case when blankout_date < (select to_date(''01-JAN-''|| to_char(to_date((fv[EOD]),''DD-MON-YYYY''),''YYYY''),''DD-MON-YYYY'') from tbl_business_date) then 0 else ytd_PL end as ytd_PL,
case when blankout_date < (select to_date(''01-JAN-''|| to_char(to_date((fv[EOD]),''DD-MON-YYYY''),''YYYY''),''DD-MON-YYYY'') from tbl_business_date) then 0 else ytd_premium_PL end as ytd_premium_PL,
IN_STRIKECURR, IN_QUOTEDCUR, case dlc_region when ''LON'' then ''LN'' when ''NYC'' then ''NY'' when ''TOK'' then ''TK'' else dlc_region
end as DLC_REGION, DLC_ENTITY,DTL_REFERENCE,TRADE_STATE,blankout_date
FROM (select a.bo_book_id as xt_strategy, a.bo_book_id as acct_description , b.mon_pl, b.tue_pl, b.wed_pl,b.thu_pl,b.fri_pl,b.wtd_pl, b.wtd_premium_pl , b.mtd_pl , b.mtd_premium_pl, b.ytd_pl, b.ytd_premium_pl,
a.BASE_CCY as IN_STRIKECURR, A.QUOTED_CCY AS IN_QUOTEDCUR, a.region_code as dlc_region, a.entity_acronym as dlc_entity, TP.EBI_TRADE_ID AS DTL_REFERENCE, a.trade_state,
case when a.trade_state in (7,8,13) then a.amendment_date when a.maturity_date > nvl(a.premium_settlement_date, to_date(''01-JAN-1900'')) then
Case when a.trade_state in (4,5 ) then trunc(a.updated_date) else a.maturity_date end else a.premium_settlement_date end as blankout_date FROM TBL_TRADE_HIST A
join vw_feed_downstream_trade_id tp on a.trade_id = tp.trade_id and tp.mapping_source_name = ''ramfx''
join tbl_pl b on a.trade_id = b.trade_id and a.version = b.trade_version and b.pl_date = (select max(pl_date) from tbl_pl d where a.trade_id = d.trade_id and pl_date <= fv[EOD] )
join tbl_bo_book bk on a.bo_book_id = bk.bo_book_id and bk.business_Area = ''OPTIONS''
where b.pl_date < fv[EOD]
AND NOT EXISTS (SELECT 1 FROM TBL_EOD_TRADES D WHERE A.TRADE_ID = D.TRADE_ID AND D.BUSINESS_DATE = fv[EOD] )
UNION
SELECT A.XT_STRATEGY, A.ACCT_DESCRIPTION, C.MON_PL,C.TUE_PL, C.WED_PL,C.THU_PL, C.FRI_PL,C.WTD_PL,C.WTD_PREMIUM_PL,C.MTD_PL,C.MTD_PREMIUM_PL,C.YTD_PL,C.YTD_PREMIUM_PL,
A.IN_STRIKECURR, A.IN_QUOTEDCUR, A.DLC_REGION,A.DLC_ENTITY, A.DTL_REFERENCE , a.trade_state , case when a.trade_state in (7,8,13) then a.DLC_BUSDATEUPD when a.IN_EXPIRATION > nvl(a.XT_SETTLEDATE, to_date(''01-JAN-1900'')) then a.IN_EXPIRATION else a.XT_SETTLEDATE end as blankout_date
FROM VW_EBI_FEED A , TBL_EOD_TRADES B , TBL_PL C
WHERE A.TRADE_ID = B.TRADE_ID AND A.VERSION = B.TRADE_VERSION AND A.TRADE_ID = C.TRADE_ID
AND A.ACCT_RISKFEED = ''D'' AND A.DLC_DEALSTATE in (''LIVE'',''PENDING'',''CANCELLED'',''REVERSED'') AND A.VERSION = C.TRADE_VERSION
AND B.BUSINESS_DATE = to_date( fv[EOD] ,''DD-MON-YYYY'') AND C.PL_DATE = to_date( fv[EOD] ,''DD-MON-YYYY'')
UNION
SELECT A.BO_BOOK_ID AS XT_STRATEGY , A.BO_BOOK_ID AS ACCT_DESCRIPTION, a.MON_PL , a.TUE_PL , a.WED_PL, a.THU_PL , a.FRI_PL, a.WTD_PL ,a.WTD_PREMIUM_PL , a.mtd_pl, a.MTD_PREMIUM_PL,a.ytd_PL , a.ytd_premium_PL,A.BASE_CCY AS IN_STRIKECURR,A.QUOTED_CCY AS IN_QUOTEDCUR,
A.REGION_CODE as dlc_region ,A.ENTITY_ACRONYM AS DLC_ENTITY, A.MAPPING_SOURCE_ID AS DTL_REFERENCE, 12 as trade_state , a.PL_DATE as blankout_date
FROM TBL_PL_ARCH A , tbl_bo_book b where a.bo_book_id = b.bo_book_id and b.business_area = ''OPTIONS''
union
select d.bo_book_id as xt_strategy, d.bo_book_id as acct_description, case when to_char(b.pl_date,''D'') = 6 then (b.inception_pl + b.inception_premium_pl ) else (b.mon_pl * -1) end as mon_pl ,
case when to_char(b.pl_date,''D'') = 2 then (b.inception_pl + b.inception_premium_pl ) when to_char(b.pl_date,''D'') > 2 then (b.tue_PL * -1) else 0 end as tue_pl, case when to_char(b.pl_date,''D'') = 3 then (b.inception_pl + b.inception_premium_pl ) when to_char(b.pl_date,''D'') > 3 then (b.wed_pl * -1) else 0 end as wed_pl ,
case when to_char(b.pl_date,''D'') = 4 then (b.inception_pl + b.inception_premium_pl) when to_char(b.pl_date,''D'') > 4 then (b.thu_pl * -1) else 0 end as thu_pl ,case when to_char(b.pl_date,''D'') = 5 then (b.inception_pl + b.inception_premium_pl) when to_char(b.pl_date,''D'') > 5 then (b.fri_pl * -1) else 0 end as fri_pl ,
(b.mon_pl + b.tue_pl + b.wed_pl + b.thu_pl + b.fri_pl) * -1 + (b.inception_pl + b.inception_premium_pl) as wtd_pl, case when b.wtd_premium_pl <> 0 then b.wtd_premium_pl *-1 + (b.inception_premium_pl) else b.wtd_premium_pl end as wtd_premium_pl , case when b.mtd_pl <> 0 then b.mtd_pl * -1 + (b.inception_pl) else b.mtd_pl end as mtd_pl ,
case when b.mtd_premium_pl <> 0 then b.mtd_premium_pl * -1 + (b.inception_premium_pl ) else b.mtd_premium_pl end as mtd_premium_pl, case when b.ytd_pl <> 0 then b.ytd_pl * -1 + (b.inception_pl) else b.ytd_pl end as ytd_pl,
case when b.ytd_premium_pl <> 0 then b.ytd_premium_pl * -1 + (b.inception_premium_pl) else b.ytd_premium_pl end as ytd_premium_pl ,
c.base_ccy as IN_STRIKECURR,c.quoted_ccy as IN_QUOTEDCUR,c.region_code as dlc_region,c.entity_acronym as dlc_entity, to_char(c.trade_id) as dtl_reference,
8 as trade_state, case when to_char(b.pl_date,''D'') = 6 then b.pl_date + 2 else b.pl_date end as blankout_date
from tbl_trade_hist a
join tbl_pl b on a.trade_id = b.trade_id and a.version = b.trade_version
join tbl_trade_hist c on a.tradE_id = c.trade_id
join tbl_pl d on c.trade_id = d.trade_id and c.version = d.trade_version and d.pl_date = (select max(e.pl_date) from tbl_pl e where c.trade_id = e.trade_id and e.pl_date <= c.amendment_date)
join tbl_bo_book f on a.bo_book_id = f.bo_book_id and f.business_area = ''OPTIONS''
where (b.bo_book_id <> d.bo_book_id or a.region_code <> c.region_code or a.entity_acronym <> c.entity_acronym or a.base_ccy <> c.base_ccy or a.quoted_ccy <> c.quoted_ccy)
and d.pl_date - b.pl_date = case when to_char(d.pl_date,''DAY'') = ''MON'' then 3 else 1 end
and d.pl_date <= to_date( fv[EOD] ,''DD-MON-YYYY'')
union all
select b.bo_book_id as xt_strategy, b.bo_book_id as acct_description,case when to_char(b.pl_date,''D'') = 6 then (b.inception_pl * -1 + b.inception_premium_pl * -1) else (b.mon_pl ) end as mon_pl ,
case when to_char(b.pl_date,''D'') = 2 then (b.inception_pl * -1 + b.inception_premium_pl * -1) when to_char(b.pl_date,''D'') > 2 then (b.tue_PL) else 0 end as tue_pl, case when to_char(b.pl_date,''D'') = 3 then (b.inception_pl * -1 + b.inception_premium_pl * -1 ) when to_char(b.pl_date,''D'') > 3 then (b.wed_pl) else 0 end as wed_pl ,
case when to_char(b.pl_date,''D'') = 4 then (b.inception_pl * -1 + b.inception_premium_pl * -1 ) when to_char(b.pl_date,''D'') > 4 then (b.thu_pl ) else 0 end as thu_pl , case when to_char(b.pl_date,''D'') = 5 then (b.inception_pl *-1 + b.inception_premium_pl * -1) when to_char(b.pl_date,''D'') > 5 then (b.fri_pl) else 0 end as fri_pl ,
(b.mon_pl + b.tue_pl + b.wed_pl + b.thu_pl + b.fri_pl) + (b.inception_pl* -1 + b.inception_premium_pl * -1) as wtd_pl, case when b.wtd_premium_pl <> 0 then b.wtd_premium_pl + (b.inception_premium_pl * -1) else b.wtd_premium_pl end as wtd_premium_pl , case when b.mtd_pl <> 0 then b.mtd_pl + (b.inception_pl * -1) else b.mtd_pl end as mtd_pl ,
case when b.mtd_premium_pl <> 0 then b.mtd_premium_pl + (b.inception_premium_pl * -1) else b.mtd_premium_pl end as mtd_premium_pl, case when b.ytd_pl <> 0 then b.ytd_pl + (b.inception_pl * -1) else b.ytd_pl end as ytd_pl,
case when b.ytd_premium_pl <> 0 then b.ytd_premium_pl + (b.inception_premium_pl * -1) else b.ytd_premium_pl end as ytd_premium_pl ,
a.base_ccy as IN_STRIKECURR, a.quoted_ccy as IN_QUOTEDCUR, a.region_code as dlc_region,a.entity_acronym as dlc_entity, to_char(a.trade_id) as dtl_reference, 8 as trade_state,
case when to_char(b.pl_date,''D'') = 6 then b.pl_date + 2 else b.pl_date end as blankout_date
from tbl_trade_hist a
join tbl_pl b on a.trade_id = b.trade_id and a.version = b.trade_version
join tbl_trade_hist c on a.tradE_id = c.trade_id join tbl_pl d on c.trade_id = d.trade_id and c.version = d.trade_version and d.pl_date = (select max(e.pl_date) from tbl_pl e where c.trade_id = e.trade_id and e.pl_date <= c.amendment_date)
join tbl_bo_book f on a.bo_book_id = f.bo_book_id and f.business_area = ''OPTIONS''
where (b.bo_book_id <> d.bo_book_id or a.region_code <> c.region_code or a.entity_acronym <> c.entity_acronym or a.base_ccy <> c.base_ccy or a.quoted_ccy <> c.quoted_ccy)
and d.pl_date - b.pl_date = case when to_char(d.pl_date,''DAY'') = ''MON'' then 3 else 1 end and d.pl_date <= to_date( fv[EOD] ,''DD-MON-YYYY'') ))
group by xt_strategy,ACCT_DESCRIPTION,DLC_REGION,DLC_ENTITY';
c clob;
s varchar2(25000);
i numeric := 424;
begin
c := xml;
dbms_output.put_line('length of clob: ' || dbms_lob.getlength(c));
dbms_output.put_line('split clob at: ' || i);
dbms_output.put_line('desired substring length: ' || to_char(dbms_lob.getlength(c) - i));
s := dbms_lob.substr(c, dbms_lob.getlength(c) - i, i + 1);
dbms_output.put_line('length of substring: ' || length(s));
end;I checked for the database characterset and they are same - AL32UTF8
The result we get is
Output from MD1 database
length of clob: 10616
split clob at: 424
desired substring length: 10192
length of substring: 10192
Output from MD2 database
length of clob: 10616
split clob at: 424
desired substring length: 10192
length of substring: 8191Any idea why there is this discrepancy ?
Edited by: USER101 on Feb 19, 2010 4:24 PMThe EOF and the LF versus CR/LF could influence the count difference, yes.
Another explain could possibly be character set conversions. The BFILE I believe counts bytes, a CLOB would count "characters" - so if the source happens to contain a few multibyte characters (UTF), then the byte count would be larger than the character count.
To help you find the cause for your exact file, then I can suggest a couple of things you might do to explore the issue:
<li>Load the file into a BLOB instead of a CLOB and see what getlength() returns for the BLOB. BLOBs would also do byte counts and not try to treat the source as text.
<li>Save the CLOB back into the filesystem and compare the original file with the exported CLOB and check the differences with some filecompare tool. -
DBMS_LOB and memory management
Hello all,
When I declare a CLOB variable (myclob) do I always have to free it with dbms_lob.freetemporary(myclob) at the end of my procedure ?
I know I have to free it if it was created with dbms.createtemporary(myclob,....) but what happens when I run statements like "SELECT to_clob('Test') INTO myCLOB FROM DUAL;"
I don't find in Oracle documentation a good answer to this question ! Can someone explain the difference ? I hope memory is freed correctly without having to explicitly do a "freetemporary" but I'm not sure !
Thanks for your answers !Thanks
But imagine you have something like
DECLARE
myCLOB CLOB
BEGIN
myCLOB := to_clob('test clob');
-- Is it necessary ???
-- dbms_lob.freetemporary(myCLOB,...) ;
END;1) Do I have to explicitely free "myCLOB" or is it automatically done by Oracle ?
2) Does the declaration of myCLOB involves the creation of a "new temporary LOB" or is it only when we create the lob explicitly with the dbms_lob.createtemporary(...);
Regards -
DBMS_LOB.INSTR - Searching for a pattern
Hi
I have a program supporting several databases. F.ex SQL2000 and Oracle 8/9.
The field in question, text, might contain a lot of characters. In Oracle, it's a CLOB,
on SQL2000 it's a varchar. It is not possible for me to alter the database-structure in
any ways at this moment. The database-schema is locked.
My question is pretty simple, you have probably seen it before.
In SQL2000 I can use this query:
select count(*) from crm5.text where text like 'n%'.
The result returned = 8.
The same on Oracle will be somewhat like:
select count(*) from crm5.text where dbms_lob.instr( text, 'n') > 0
The result returned = 29.
The databases has the same data.
It seems to me that the dbms_lob.instr
does a (case-sensitive) query like this:
select count(*) from crm5.text where text like '%n%
Is this the right assumption? How can I get the correct number
of rows and do the search case-insensitive at the same time not
killing the performance of the database? We use a pretty smart
little thing on "normal" LIKE. But how can we do this with the
CLOB?
Regards,
IvarFound the solution.
On Oracle 9, use LIKE as you want.
On Oracle 8, use
select count(*) from crm5.text
where dbms_lob.instr( text, 'N') = 1
or dbms_lob.instr( text, 'n') = 1.
Ivar (same account, different mail-address). -
Problem with BLOB fields (DBMS_LOB)
I want to read a word document from hard disc and save it into a BLOB field with using DBMS_LOB package. but when using it I always receive error "Invalid LOB locator specified" even I use oracle examples.
I use FormBuilder 6.0.
How can I do this. plz give me a code.
Thanks so much>
help plzzz
>
If you want help in the forum you need to use English when you post.
You also need to actually ask a question or present the issue that you need help with. Just saying you nave a problem and then posting code isn't sufficient.
Please edit your post and provide the English version of your code, comments, error messages and your action question or issue. -
Auditing lob column changes when working with dbms_lob
Hi,
It seems that dml trigger doesn't fire when lob field is being updated using dbms_lob package.
As it stated in Oracle documentation:
"Using OCI functions or the DBMS_LOB package to update LOB values or LOB attributes of object columns does not cause Oracle to fire triggers defined on the table containing the columns or the attributes."
I need to know that table was updated (or is about to be updated), how can I do that in case it is lob field that is being updated?
Thank you!I need to know that table was updatedAUDIT
Handle: user13133099
Status Level: Newbie
Registered: Jul 21, 2010
Total Posts: 6
Total Questions: 4 (4 unresolved)
so many questions without ANY answers.
http://forums.oracle.com/forums/ann.jspa?annID=718
Edited by: sb92075 on Oct 26, 2010 7:43 AM
Maybe you are looking for
-
To Firewire Or Not To Firewire
First post here ~ I have a 15" Powerbook G4, 1 GHz, 1 GB SDRAM, 60MB Hard Drive that I bought in, ahem, 2003, but right now do not have the moolah to upgrade. I have FCP 5.0.1 installed and a Lacie 250 GB External FW Drive. Since my computer only has
-
Do you gotta plug up your iPod 5 gen while it's updatting to ios8? Because I updated mine and it won't stay charged plus it's losing battery life very fast.
-
I am about to create a failover with Data Guard using my current Oracle 11g database on Windows 2003. I have done some intensive reading, but I will appreate if anybody can share with me the steps involved in setting up a Data Guard with the same ope
-
I upgraded my phone to ios 5 and had to restore it; now it is frozen. what do I do?
-
NEED ADVICE , WANNA BUY A HOUSE SOON!!!!
I SPOKE W/ A LENDER AND HE ADVISED I GET A SECURED CREDIT CARD. I CURRENTLY HAVE A SECURED LOAN W/ A LOCAL CREDIT UNION.BELOW IS A COPY OF MY CREDIT REPORT THAT WAS PULLED BY THE LENDER. THE ONLY DIFFERENCE IS MY CAR LOAN WAS PAID OFF ON JUNE 28...PL