8.22.2011

Searching in CLOB

I wanted to search the login_name from a xml file. And, that xml file was stored in a clob column.
-- = starting tag
--
= ending tag


select * from (
select t.id,form_id
, dbms_lob.substr(
t.enteredBy
,(dbms_lob.instr(t.enteredBy, '',1,1) - dbms_lob.instr(t.enteredBy, '',1,1) - 11)
,dbms_lob.instr(t.enteredBy, '',1,1)+11
) login_name
from
(
select o.id,o.form_id
,dbms_lob.substr(
o.clob_data
,(dbms_lob.instr(o.clob_data, '
',1,1) - dbms_lob.instr(o.clob_data, '',1,1) - 11)
,dbms_lob.instr(o.clob_data, '',1,1)+11
) enteredBy
from old_data_type_idf o
where dbms_lob.instr(o.clob_data, '',1,1)>0
) t
)X
where X.form_id='IDF-PRIMECT-36J2M5VWFC';

5.03.2011

ORA-01779: cannot modify a column which maps to a non key-preserved table.

I wanted to update a table column based on another table data but it faild with
ORA-01779: cannot modify a column which maps to a non key-preserved table.


Update (
select c.central_client_id,cc.id
from client c,central_client cc
where c.id = cc.orginal_client_id)
Set central_client_id = id;

Adding an unique constraint will solve the problem.

alter table central_client add constraint central_client_org_cid_uk unique (orginal_client_id);

3.09.2011

Rownum related

select * from (
select p.*,rownum as newrow from PROVIDER p where rownum<=20) a where newrow>5;