Is there a way to select strings where the wildcard is found elsewhere.
For example:
Say I pump a bunch of files into a database so I can analyze the data.
if file1.xml maps to a table with rows that contain this data
file line description
file1 1 <mytag id="aaa"/>
file1 2 <mytag id="bbb"/>
file1 3 <mytag id="ccc"/>
and file2.xml maps to a table with rows that contain this data
file line description
file2 1 <mytag2 lookup="aaa"/>
file2 2 <mytag2 lookup="aaa"/>
file2 3 <mytag2 lookup="bbb"/>
Then is there some query that will return rows:
file1 1 <mytag id="aaa"/> file2 1 <mytag2 lookup="aaa"/>
file1 1 <mytag id="aaa"/> file2 2 <mytag2 lookup="aaa"/>
file1 2 <mytag id="bbb"/> file2 3 <mytag2 lookup="bbb"/>
Thanks
Jeff Kish
> Is there a way to select strings where the wildcard is found elsewhere.
>
[quoted text clipped - 21 lines]
> file1 1 <mytag id="aaa"/> file2 2 <mytag2 lookup="aaa"/>
> file1 2 <mytag id="bbb"/> file2 3 <mytag2 lookup="bbb"/>
AFAIK there is no general solution. You certainly could do something with
user defined functions but that is quite inefficient unless your database
model allows to define indexes on these function columns.
You better choose a different storage scheme for your files, use an XML
enabled database or use proprietary code to figure these things out. If
you just need to do it once, then I'd probably write a script that does
the job. Dunno however what else will be part of your analysis.
Kind regards
robert
> Is there a way to select strings where the wildcard is found elsewhere.
>
[quoted text clipped - 21 lines]
> file1 1 <mytag id="aaa"/> file2 2 <mytag2 lookup="aaa"/>
> file1 2 <mytag id="bbb"/> file2 3 <mytag2 lookup="bbb"/>
Followings might not the way you want. But, it worked on DB2 UDB.
CREATE TABLE File_XML
(file CHAR(8) NOT NULL
,line SMALLINT NOT NULL
,desc VARCHAR(30) NOT NULL
) IN USERSPACE1
;
INSERT INTO File_XML
VALUES
('file1', 1, '<mytag id="aaa"/>')
,('file1', 2, '<mytag id="bbb"/>')
,('file1', 3, '<mytag id="ccc"/>')
,('file2', 1, '<mytag2 lookup="aaa"/>')
,('file2', 2, '<mytag2 lookup="aaa"/>')
,('file2', 3, '<mytag2 lookup="bbb"/>')
;
SELECT f1.file
, f1.line
, f1.desc
, f2.file
, f2.line
, f2.desc
FROM File_XML f1
, File_XML f2
WHERE f1.file = 'file1'
AND f2.file = 'file2'
AND SUBSTR(f1.desc, LOCATE('id="', f1.desc)+4,
LOCATE('"/>', SUBSTR(f1.desc,
LOCATE('id="', f1.desc)+4)) -1)
= SUBSTR(f2.desc, LOCATE('lookup="', f2.desc)+8,
LOCATE('"/>', SUBSTR(f2.desc,
LOCATE('lookup="', f2.desc)+8)) -1)
;
------------------------------------------------------------------------------
FILE LINE DESC FILE LINE DESC
-------- ------ ------------------------------ -------- ------
------------------------------
file1 1 <mytag id="aaa"/> file2 1 <mytag2
lookup="aaa"/>
file1 1 <mytag id="aaa"/> file2 2 <mytag2
lookup="aaa"/>
file1 2 <mytag id="bbb"/> file2 3 <mytag2
lookup="bbb"/>
Jeff Kish - 30 Sep 2004 19:46 GMT
>> Is there a way to select strings where the wildcard is found elsewhere.
>>
[quoted text clipped - 68 lines]
>file1 2 <mytag id="bbb"/> file2 3 <mytag2
>lookup="bbb"/>
Thanks.. let me give it a try on Oracle and ms sql server etc...
Jeff Kish
Jeff Kish - 30 Sep 2004 19:59 GMT
<snip>
Hi.. what does 'locate' do? I want to find the exact equivalent for oracle.
Thanks
>SELECT f1.file
> , f1.line
[quoted text clipped - 24 lines]
>file1 2 <mytag id="bbb"/> file2 3 <mytag2
>lookup="bbb"/>
Jeff Kish