How to query a CLOB column
Hello All,
I am trying to query a CLOB column with some text string. Can anyone tell me how to do this. Here is a simple example of my code and the error message I get....
SQL> select title_column from atlas_table where clob_column like '%a%';
select title_column from atlas_table where clob_column like '%e%'
ERROR at line 1:
ORA-00932: inconsistent datatypes
Thanks,
Danny
Selecting a LOB from a table actually returns the LOB's locator and not the entire LOB value..
and you should have a frontend to retrieve the clob or blob..
if u have you can view/update/..do DML operations on the column
null
Similar Messages
-
How to Update a clob column..it gives error string literal too long
I am trying to update a clob column of a table but it gives error string literal too long plz tell me what's the issue
ORA-01704: string literal too longPeeyush wrote:
I am trying to update a clob column of a table but it gives error string literal too long plz tell me what's the issue
ORA-01704: string literal too longThere's a problem with my car. It won't start. Why won't it start? Please tell me!
Oh wait, you can't, because I haven't given you nearly enough information...
In other words, if you would like help in trying to work out where you've gone wrong, you should provide a small enough example of your code that demonstrates the error. We might then actually stand a chance of being able to help you! -
here is my problem.
I have a table called t_clob as follows:
SQL> desc t_clob
Name Null? Type
C CLOB
I need to update an existing row with new data (overwrite). The new data is a big java script string with line break, spaces, alignment etc. as follows :
<form name="abcdeg" accept-charset="utf-8" class="adadad" method="get" action="abd/def" id="asdsdas">
<label class="abcdef" for="sdfgsdgjgerigh">Search</label>
<div class="qwert">
<label class="qwert">
<input type="radio" name="search_type" value="wweer" id="qwert_trye" onclick="aab(ddgdfgdf);switchTo(''abcd'');" class="radio" <#if localchecked??> ${localchecked}</#if> />Site
</label>
<label class="abcdefgh">
<input type="radio" name="asddfere" value="sssd" id="sdfswererwerew" onclick="abcdefghij(this.value);switchTo(''dfsdfs'');" class="radio" <#if webchecked??> ${sdfsdfsdf}</#if> style="display:none" disabled />
<input type="radio" name="sdfsdfsdfs" value="fsdfsdfsdf" id="sdfsdfsdfsd" onclick="sdfsdfsdfsdfsdfsdf(this.value);" class="radio" <#if sfsdfsdfsdf??> ${sdfsdfsdfsdf}</#if> /> qwe
</label>
<label class="sdfdsfsdfs" style="font-size:8px">
sfsdfsdf <br>
<img src="/sdfsd/sdfsd/sfsdfsd.lfg" alt="Search"/>
</label>
<label class="qweqwe" style="display:none">
<input type="radio" name="qwewewqe" value="weqwewq" id="qweqweqwewqeq" onclick="weqweqweqeqweqw(this.value);switchTo(''business'');" class="radio" <#if localbusinesschecked??> ${qweqweweqwe}</#if> />qweqweqw
</label>
</div>
<input type="text" value="<#if q??>${q}</#if>" name="qweqwewqe" id="qweqweqwew" autocomplete="off"/>
<button type="submit" onclick="qweqweqweqw()">
<img src="/weqweqw/qweqweqwe.gif" alt="Search" />
</button>
<input type="hidden" value="<#if sm??>${sm}</#if>" id="sm" name="qwe" class="hidden"/>
<input type="hidden" value="<#if srm??>${srm}</#if>" id="srm" name="srm" class="hidden"/>
<input type="hidden" id="startIndex" name="startIndex" value="<#if start??>${start}</#if>"/>
<input type="hidden" id="currentPage" name="currentPage" value="<#if currentpage??>${currentpage}</#if> "/>
</form>
<script type="text/javascript">
window.qweqwewq = "<#if appid??>${appid}</#if>";
</script>
<script type="text/javascript" src="http://qwewqeqwewewe/qwewq/qwew/qweqwe.js"></script>
Currently, we have the normal update statement (updating as a varchr value) in a .sql file. but running the .sql file, throws the following error:
SP2-0042: unknown command "</script>" - rest of line ignored.
SP2-0734: unknown command beginning "<script ty..." - rest of line ignored.
SP2-0734: unknown command beginning "where EXT..." - rest of line ignored.
For a work-around, we are updating the column through TOAD --> Schema Browser--> Data tab. But, this TOAD way is appearing to be error prone, though it works.
Can anybody help us in modifying the update statement so that it can directly be run from the .sql file and the spacing/ new lines are preserved.
Thanks in Advance.I'm not 100% sure i understand your problem, is this of any help?
ME_XE?create table t1 (id number, col1 clob);
Table created.
Elapsed: 00:00:00.10
ME_XE?insert into t1 (id) values (1);
1 row created.
Elapsed: 00:00:00.01
ME_XE?
ME_XE?declare
2 my_clob clob default
3 '
4 <form name="abcdeg" accept-charset="utf-8" class="adadad" method="get" action="abd/def" id="asdsdas">
5 <label class="abcdef" for="sdfgsdgjgerigh">Search</label>
6 <label class="qwert">
7 <input type="radio" name="search_type" value="wweer" id="qwert_trye" onclick="aab(ddgdfgdf);switchTo(''abcd'');" class="radio" <#if localchecked??> ${localchecked}</#if> />Site
8 </label>
9 <label class="abcdefgh">
10 <input type="radio" name="asddfere" value="sssd" id="sdfswererwerew" onclick="abcdefghij(this.value);switchTo(''dfsdfs'');" class="radio" <#if webchecked??> ${sdfsdfsdf}</#if> style="display:none" disabled />
11 <input type="radio" name="sdfsdfsdfs" value="fsdfsdfsdf" id="sdfsdfsdfsd" onclick="sdfsdfsdfsdfsdfsdf(this.value);" class="radio" <#if sfsdfsdfsdf??> ${sdfsdfsdfsdf}</#if> /> qwe
12 </label>
13 <label class="sdfdsfsdfs" style="font-size:8px">
14 sfsdfsdf
15 <img src="/sdfsd/sdfsd/sfsdfsd.lfg" alt="Search"/>
16 </label>
17 <label class="qweqwe" style="display:none">
18 <input type="radio" name="qwewewqe" value="weqwewq" id="qweqweqwewqeq" onclick="weqweqweqeqweqw(this.value);switchTo(''business'');" class="radio" <#if localbusinesschecked??> ${qweqweweqwe}</#if> />qweqweqw
19 </label>
20 <input type="text" value="<#if q??>${q}</#if>" name="qweqwewqe" id="qweqweqwew" autocomplete="off"/>
21 <button type="submit" onclick="qweqweqweqw()">
22 <img src="/weqweqw/qweqweqwe.gif" alt="Search" />
23 </button>
24 <input type="hidden" value="<#if sm??>${sm}</#if>" id="sm" name="qwe" class="hidden"/>
25 <input type="hidden" value="<#if srm??>${srm}</#if>" id="srm" name="srm" class="hidden"/>
26 <input type="hidden" id="startIndex" name="startIndex" value="<#if start??>${start}</#if>"/>
27 <input type="hidden" id="currentPage" name="currentPage" value="<#if currentpage??>${currentpage}</#if> "/>
28 </form>
29 <script type="text/javascript">
30 window.qweqwewq = "<#if appid??>${appid}</#if>";
31 </script>
32 <script type="text/javascript" src="http://qwewqeqwewewe/qwewq/qwew/qweqwe.js"></script>
33 ';
34
35 begin
36 update t1 set col1 = my_clob where id = 1;
37 end;
38 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.03
ME_XE? -
How do you select a clob column in an SQL query report?
I must be missing something fundamental as there is practically no help on this on the forum.
All I want to do is ...
select numcol,aclob_col from table
in an SQL Query report.
Sounds easy??? I get no data appearing in the clob column. Doesn't work in SQL Workshop either. What's the catch??
regards
Paul PPaul,
It works when I try it. What version of Application Express, what is the table DDL, the exact query, and how much data is in the clob columns?
Scott -
How to query XML data stored in a CLOB column
I don't know XMLDB, so I have a dumb question about querying XML data which is saved as CLOB in a table.
I have a table (OLAP_AW_PRC), with a CLOB column - AW_XML_TMPL_VAL
This column contains this xml data - [click here|http://www.nasar.net/aw.xml]
Now I want to query the data using the xml tags - like returning the name of AW. This is where I am having trouble, how to query the data from AW_XML_TMPL_VAL clob column.
The following query generates error:
ORA-31011: XML parsing failed.
ORA-19202: Error occurred in XML processing
LPX-00229: input source is empty
SELECT
extractValue(value(x), '/AW/LongName') as "AWNAME"
from
OLAP_AW_PRC,
table(xmlsequence(extract (xmltype(AW_XML_TMPL_VAL), '/AWXML/AWXML.content/Create/ActiveObject/AW'))) x
where
extractValue(value(x) , '/AW/Name') = 'OMCR4'
- NasarMark,
Thanks. This is exactly what I was looking for.
After doing @Name in both places (SELECT and WHERE clause) it worked.
Now I have one more question.
There are multiple DIMENSION tags in my xml, and I want to see the NAME attribute values for all of those DIMENSIONs. The following query returns
ORA-19025: EXTRACTVALUE returns value of only one node.
Cause: Given XPath points to more than one node.
Action: Rewrite the query so that exactly one node is returned.
SELECT
extractValue(value(x), '/AW/@Name') as "AW",
extractValue(value(x), '/AW/Dimension/@Name') as "DIMENSIONS"
from
OLAP_AW_PRC,
table(xmlsequence(extract (xmltype(AW_XML_TMPL_VAL), '/AWXML/AWXML.content/Create/ActiveObject/AW'))) x
where
extractValue(value(x) , '/AW/@Name') = 'OMCR4' -
Forms 6.0 how to query clob column with oracle 9.2 DB
hi every body,
i made install for oracle 9.2 oracle DB every thing goes ok but when i made query in my form version 6.0 which have CLOB column the form closed automatically without any message?
and just for know when i run the same form with oracle 8.1.7 DB the form made query normally without any problem.
i want your help please.
Message was edited by:
mshaqalaihI know there was a problem in 6i where you would get a crash if your query returned more than {Max Length} characters of the field representing the CLOB column.
-
How to update html file in clob column in oracle
hi,
please help me how to update html file in clob column in oracle
ThanksThis is your main query as i am able to understand and you want to update your html file into terms columns based on conditions :
SELECT b.terms As terms
FROM chklst_item_x_enrlmnt_type a, prvdr_enrlmnt_agreement b
WHERE a.enrlmnt_type_cid = 1
AND a.chklst_item_cid = b.chklst_item_cid
AND a.chklst_item_cid = 79
AND a.oprtnl_flag = 'A'
AND b.oprtnl_flag = 'A'
AND TRUNC (SYSDATE) BETWEEN b.from_date AND b.TO_DATE;So i suggest below one but you need to create a directory where you can store your html file and then you can update .. And remaining consult Experts suggestions too as your
question is improperly posted . . .
DECLARE
vclob CLOB;
v_bfile BFILE := BFILENAME ('YOUR_DIR', 'filename.html');
BEGIN
SELECT b.terms
INTO vclob
FROM chklst_item_x_enrlmnt_type a, prvdr_enrlmnt_agreement b
WHERE a.enrlmnt_type_cid = 1
AND a.chklst_item_cid = b.chklst_item_cid
AND a.chklst_item_cid = 79
AND a.oprtnl_flag = 'A'
AND b.oprtnl_flag = 'A'
AND TRUNC (SYSDATE) BETWEEN b.from_date AND b.TO_DATE
FOR UPDATE;
DBMS_LOB.fileopen (v_bfile);
DBMS_LOB.loadfromfile (vclob, v_bfile, DBMS_LOB.getlength (v_bfile));
DBMS_LOB.fileclose (v_bfile);
END;
/ Regards.. -
I am trying to query a column which is of CLOB data type,in Oracle, and My Data is stored something like this
<Result><Institution>XXX</Institution><Application>XXX</Application><ID>123123123</ID><SequenceID>MSGID123123</SequenceID><DateTime></DateTime></Result>
I am trying to run the xquery on this like this
SELECT Message FROM LOGS
('for $i in ora:view("LOGS")
where $i/Result/Institution/ = 'XXX'
return $i/Result/Institution/
PASSING :Institution AS 'XXX').
I either get exception that "missing right parenthesis" or doesnt execute at all.
My Table "LOGS" as the Columns Message as CLOB.
Any Ideas how to query on this kind of columns in a table in Oracle using XQuery?
Cheers
SridharHi,
First of all, please always give your database version (all digits from "select * from v$version").
Oracle XML support is achieved through the XMLType datatype, so you must first convert any string variable (CLOB, VARCHAR2) holding XML data to that type in order to use XML-related functions.
Now, to the point, if you want to check the existence of a particular node, you can try the following :
-- if Institution may occur multiple times :
select message
from logs
where existsnode(xmltype(message), '/Result[Institution="'||:p_institution||'"]') = 1
-- if only one Institution element is expected :
select message
from logs
where extractvalue(xmltype(message), '/Result/Institution') = :p_institution
;And the 11g equivalent :
select message
from logs
where xmlexists('$d/Result[Institution=$p]' passing xmltype(message) as "d", :p_institution as "p")
select message
from logs
where xmlcast(
xmlquery('$d/Result/Institution' passing xmltype(message) as "d" returning content)
as varchar2(30)
) = :p_institution
; -
How can i join additional column without using a query
Hi,
I created a report using a base query; Now i want to add an additional coloumn to it without using another table i.e. from no new query; That additional column is complex computed value from different tables created for each record; How can i attach it to each record;
thanks in advance
prasanthAdd a formula column in your existing query.
-
How to read/write .CSV file into CLOB column in a table of Oracle 10g
I have a requirement which is nothing but a table has two column
create table emp_data (empid number, report clob)
Here REPORT column is CLOB data type which used to load the data from the .csv file.
The requirement here is
1) How to load data from .CSV file into CLOB column along with empid using DBMS_lob utility
2) How to read report columns which should return all the columns present in the .CSV file (dynamically because every csv file may have different number of columns) along with the primariy key empid).
eg: empid report_field1 report_field2
1 x y
Any help would be appreciated.If I understand you right, you want each row in your table to contain an emp_id and the complete text of a multi-record .csv file.
It's not clear how you relate emp_id to the appropriate file to be read. Is the emp_id stored in the csv file?
To read the file, you can use functions from [UTL_FILE|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#BABGGEDF] (as long as the file is in a directory accessible to the Oracle server):
declare
lt_report_clob CLOB;
l_max_line_length integer := 1024; -- set as high as the longest line in your file
l_infile UTL_FILE.file_type;
l_buffer varchar2(1024);
l_emp_id report_table.emp_id%type := 123; -- not clear where emp_id comes from
l_filename varchar2(200) := 'my_file_name.csv'; -- get this from somewhere
begin
-- open the file; we assume an Oracle directory has already been created
l_infile := utl_file.fopen('CSV_DIRECTORY', l_filename, 'r', l_max_line_length);
-- initialise the empty clob
dbms_lob.createtemporary(lt_report_clob, TRUE, DBMS_LOB.session);
loop
begin
utl_file.get_line(l_infile, l_buffer);
dbms_lob.append(lt_report_clob, l_buffer);
exception
when no_data_found then
exit;
end;
end loop;
insert into report_table (emp_id, report)
values (l_emp_id, lt_report_clob);
-- free the temporary lob
dbms_lob.freetemporary(lt_report_clob);
-- close the file
UTL_FILE.fclose(l_infile);
end;This simple line-by-line approach is easy to understand, and gives you an opportunity (if you want) to take each line in the file and transform it (for example, you could transform it into a nested table, or into XML). However it can be rather slow if there are many records in the csv file - the lob_append operation is not particularly efficient. I was able to improve the efficiency by caching the lines in a VARCHAR2 up to a maximum cache size, and only then appending to the LOB - see [three posts on my blog|http://preferisco.blogspot.com/search/label/lob].
There is at least one other possibility:
- you could use [DBMS_LOB.loadclobfromfile|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i998978]. I've not tried this before myself, but I think the procedure is described [here in the 9i docs|http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96591/adl12bfl.htm#879711]. This is likely to be faster than UTL_FILE (because it is all happening in the underlying DBMS_LOB package, possibly in a native way).
That's all for now. I haven't yet answered your question on how to report data back out of the CLOB. I would like to know how you associate employees with files; what happens if there is > 1 file per employee, etc.
HTH
Regards Nigel
Edited by: nthomas on Mar 2, 2009 11:22 AM - don't forget to fclose the file... -
How to insert more than 32k xml data into oracle clob column
how to insert more than 32k xml data into oracle clob column.
xml data is coming from java front end
if we cannot use clob than what are the different options availableAre you facing any issue with my code?
String lateral size error will come when you try to insert the full xml in string format.
public static boolean writeCLOBData(String tableName, String id, String columnName, String strContents) throws DataAccessException{
boolean isUpdated = true;
Connection connection = null;
try {
connection = ConnectionManager.getConnection ();
//connection.setAutoCommit ( false );
PreparedStatement PREPARE_STATEMENT = null;
String sqlQuery = "UPDATE " + tableName + " SET " + columnName + " = ? WHERE ID =" + id;
PREPARE_STATEMENT = connection.prepareStatement ( sqlQuery );
// converting string to reader stream
Reader reader = new StringReader ( strContents );
PREPARE_STATEMENT.setClob ( 1, reader );
// return false after updating the clob data to DB
isUpdated = PREPARE_STATEMENT.execute ();
PREPARE_STATEMENT.close ();
} catch ( SQLException e ) {
e.printStackTrace ();
finally{
return isUpdated;
Try this JAVA code. -
How to use a Formula Column in the main query?
Hi All,
I've tried to use a formula columns defined in some query in the condition of that query like this:
where (:cf_ex - :cf_ex2) >= 5
but when I run the report no data returned! Why? and how to use it the condition of the query?
Note: I'm using Forms 6iwhere (:cf_ex - :cf_ex2) >= 5You cannot do that. Formula columns are not part of the select statement (which runs in the database), but are processed in the report.
When you created this query, my guess is that you got the message "Note: the query Q1 has created the bind parameter(s) cf_ex, cf_ex2". Check these User Parameters in your data model. So, you are actually referencing user parameters in the query, not formula columns.
I made a computations and things using PL/SQL that can't be done in the select statement in the data model!If it's pl/sql you can probably use that in your query. Create some database functions for cf_ex and cf_ex2 and use these in your query. -
How to store large text in clob column???
i have create a table this ..
create table realistic_docs
id number primary key,
text clob
and i want to load text data into clob column
the data is ....
The solar system may not be alone. Yesterday
astronomers announced the first ever
discovery of a planetary system like our own.
Three planets, they say, orbit a nearby star, Upsilon
Andromedae.
If confirmed, their discovery suggests that the Milky
Way galaxy is filled with planets. "This shows that
[outside of the solar system] it is possible to have more
than one planet going around a star. If we can prove
this once, we can extrapolate that it may happen
elsewhere," said Adam Contos from the
Harvard-Smithsonian Center for Astrophysics.
The planets orbiting Upsilon Andromedae are believed
to be gas giants like Jupiter and are not thought to
harbor life. According to Contos, however, the more
planetary systems there are, the greater the chance of
finding a planet with the elements essential for life.
The astronomers detected the proposed planets by
measuring the wavelengths of light from stars similar
to our sun. The presence of a planet would be
indicated by a tiny shift in wavelength known as a
gravitational wobble.
how to do this?kindly list me steps which are required...
thanks a lot .....Here is the code. You will have to create a directory object first. The idea is to get the clob by reading it from a file using bfile and dbms_lob package.
declare
l_clob clob;
l_bfile bfile;
begin
dbms_lob.createtemporary ( l_clob, false );
l_bfile := bfilename ( 'MY_FILE_DIR', 'file_name.txt' );
dbms_lob.fileopen ( l_bfile );
dbms_lob.loadfromfile ( l_clob, l_bfile, dbms_lob.getlength ( l_bfile ) );
dbms_lob.fileclose ( l_bfile );
insert into table ( l_clob );
dbms_lob.freetemporary ( l_clob );
end;
Pratap -
How to view CLOB column in SQLdeveloper
I'd like to know how to display the value of a CLOB column when in SQLDeveloper. Thanks.
The data grid's cell has a popup editor (a ... button in the cell) where you can see CLOB contents.
-Raghu -
How to publish XML document whose source is stored in clob column
I have to create simple application:
in one table are stored some information about XML documents (date of creation, etc.) and the document source itself in one (unfortunatelly clob type) column.
The point is to anable users finding document(s) and viewing it.
Using forms I can search and display information about documents. But I have no idea how to publish XML document whose source is stored in clob column.
I am using Oracle Portal 3.0 on NT.
Thanks in advance.Hi Sergio,
This link might be helpful:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/apex31blob.htm
Also refer the BLOB Download Format Mask :
{message:id=9716335}
Here I have given the format mask for APEX 4.0, which will slightly differ for 3.2.1 and proposed changes
in the format mask are:
1) Format Mask: DOWNLOAD
2) Content Disposition: Inline
This will be achieved with it:
>
But now, my user would like to know if it´s possible that APEX application can OPEN some of these files stored on this BLOB column WITHOUT download it.
My user would like to see a hiperlink (or button) that, if pressed/acessed, can open a new page (or a page inside application) with the document. He doesn´t need to edit this oppened file. He only wants to see it.
>
Hope it helps!
Regards,
Kiran
Maybe you are looking for
-
Multicast works for a day and then stops
I'm running multicast in unicast mode on our WLC because I can't enable PIM on wired side yet for a couple reasons. It works consistently on 3 out of 6 WLAN's. And the weird thing is the other 3 WLAN's will work for a day, and when I come in the ne
-
Adding pictures from iPhoto to iMovie ?
I have recently updated to iLife 11. I am a little new to imovie and get on with it quite well but i don't seem to be able to add stills. I am clicking on the photo icon and opening iphoto but then nothing...... what do I do? I have tried dragging an
-
IPad keeps freezing when using iplayer
I have just updated my iPad to 4.2 and since then when using iplayer the screen freezes after about 3-5 minutes. I have cleared both cookies and cache from the settings menu and this has made no difference!? Very frustrating when you've jst started t
-
HT1296 Trying to backup or sync calendar on iPhone to computer so I can have a copy
The only option for syncing my calendar is to outlook; does not give me the option to sync anywhere else. No data appears in outlook calendar, though, after syncing and after backup to computer. How do I transfer calendar to computer so that I can
-
PLPO-LIFNR. Vendor field in blank
Hello, I am new in the forum and I have a question I would like to comment. I hope to explain correctly. My problem is this: In CA01, I use a number of modification (AENNR) and I modify an external operation (routing - outsourced manufacturing). Then