Using user_datastore in 8.1.7
I am trying to use the user_datastore feature, but I am getting the following
error when I try to build the index:
DRG-12604: execution of user datastore procedure has failed
DRG-50857: oracle error in drsinopen
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'S_EBT_CM_TEXT_DATASTOR
E'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments i
DRG-12604: execution of user datastore procedure has failed
The procedure being called is defined:
create or replace procedure s_ebt_cm_text_datastore(rid in rowid, text in out nocopy VARCHAR2)
is
begin
appowner.ebt_cm_text_datastore(rid,text);
end;
grant execute on s_ebt_cm_text_datastore to entrepid
I have verified that the ebt_cm_text_datastore procedure works, and that calling the 's_ebt_cm_text_datastore' in ctxsys by hand works as well.
Is there a problem with using varchar2? The doc says it is acceptable, but all examples I have been able to find are using CLOB.
Thanks in advance.
More info:
In fact sync and drop/recreate impact a user datastore index in different ways: sync creates new tokens (token_text) in dr$<IDX>$i, and drop/recreate groups token and increment references (token_count).
Assuming it's a feature, does it impact the search in any ways? If so, which method is recommended: sync or drop/recreate?
Thanks in advance
Eric
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by eric vespierre:
Hello,
When using ctx_ddl.sync_index in 8.1.7 on a user datastore index, the synchronization is not done (same values in dr$<IDX>$i). If I drop and recreate the index, values in dr$<IDX>$i are correct. ctx_ddl.sync_index works ok with other indexes (non user datastore).
Is this a limitation, or is there another way to sync a user datastore index?
Thanks and have s good day
Eric<HR></BLOCKQUOTE>
null
Similar Messages
-
How do I use user_datastore with a feeder proc to add an mdata section?
Hi,
I have text data spread across a number of different tables. I have created a user_datastore with a feeder procedure that creates an xml document which is then indexed into a dummy column on the parent table. This works fine. However I need to add an mdata section to the index, via my xml document. I haven't seen any examples of this being done in conjunction with the ctxsys.auto_section_group option of the create index statement, and am wondering if it is possible?
Could somebody furnish me an example of how I achieve this.
Oracle 11.2.
Thanks
RalphYou can't use MDATA with AUTO_SECTION_GROUP. AUTO means it automatically assigns zone sections for every tag it finds - if you want anything other than zone sections you must use BASIC_SECTION_GROUP, XML_SECTION_GROUP or HTML_SECTION_GROUP and manually define your sections.
-
How to use a USER_DATASTORE to index multiple columns in different tables
I would appreciate if somebody can give an example or point to links with examples on how to use USER_DATASTORE on multiple columns in different tables. THe Oracle Text documentation only shows multiple columns in the same table.
Thanks in advance.I am not sure why your getting the wrong results but you should seriously reconsider the approach your are taking. Using functions like this is very ineffecient and should be avoided at all cost.
-
Which option to use to search text in multiple table columns
Hi, I have a case where I have 4 db tables. On the UI there is an option to search a keyword from some columns of these 4 tables.
Table1 = summary, description are the columns user can search on
Table2 = project_name is the column user can search on
Table3 = need_by_date is the column user can search on
Table4 = owner is the column user can search on
On the UI, user can enter a keyword and check the columns they want to search on. Out of the above, they can check one column, or more, or all.
My question is what is the best option to use oracle text search in this case.
Option 1 = I create a procedure to select these columns and then create an index on this procedure. In this case, is there a way to specify
which columns to search on?
Option 2= Create 4 separate indexes on these table/columns and then query the columns which user has selected to search on.
Any other better idea?Hi,
multicolumn only works on columns in the same table.
If you can also query just on one field, then an index per field will be preferable. If you query always on all the fields then the one index approach is good. For this last the options are:
1. Use User_datastore, create a procedure and a dummy column
2. Create a materialized view for the query and build an index on this materialized view
3. Store the fields as an xml in the main table and index the xml column.
The maintanance of options 1 and 3 are bigger, because you need triggers to be aware of an update. Option 2 and 3 will need more storage.
Herald ten Dam
http://htendam.wordpress.com -
Creating a single context index on a one-to-many and lookup table
Hello,
I've been successfully setting up text indexes on multiple columns on the same table (using MULTI_COLUMN_DATASTORE preferences), but now I have a situation with a one-to-many data collection table (with a FK to a lookup table), and I need to search columns across both of these tables. Sample code below, more of my chattering after the code block:
CREATE TABLE SUBMISSION
( SUBMISSION_ID NUMBER(10) NOT NULL,
SUBMISSION_NAME VARCHAR2(100) NOT NULL
CREATE TABLE ADVISOR_TYPE
( ADVISOR_TYPE_ID NUMBER(10) NOT NULL,
ADVISOR_TYPE_NAME VARCHAR2(50) NOT NULL
CREATE TABLE SUBMISSION_ADVISORS
( SUBMISSION_ADVISORS_ID NUMBER(10) NOT NULL,
SUBMISSION_ID NUMBER(10) NOT NULL,
ADVISOR_TYPE_ID NUMBER(10) NOT NULL,
FIRST_NAME VARCHAR(50) NULL,
LAST_NAME VARCHAR(50) NULL,
SUFFIX VARCHAR(20) NULL
INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (1, 'Some Research Paper');
INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (2, 'Thesis on 17th Century Weather Patterns');
INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (3, 'Statistical Analysis on Sunny Days in March');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (1, 'Department Chair');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (2, 'Department Co-Chair');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (3, 'Professor');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (4, 'Associate Professor');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (5, 'Scientist');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (1,1,2,'John', 'Doe', 'PhD');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (2,1,2,'Jane', 'Doe', 'PhD');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (3,2,3,'Johan', 'Smith', NULL);
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (4,2,4,'Magnus', 'Jackson', 'MS');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (5,3,5,'Williard', 'Forsberg', 'AMS');
COMMIT;I want to be able to create a text index to lump these fields together:
SUBMISSION_ADVISORS.FIRST_NAME
SUBMISSION_ADVISORS.LAST_NAME
SUBMISSION_ADVISORS.SUFFIX
ADVISOR_TYPE.ADVISOR_TYPE_NAME
I've looked at DETAIL_DATASTORE and USER_DATASTORE, but the examples in Oracle Docs for DETAIL_DATASTORE leave me a little bit perplexed. It seems like this should be pretty straightforward.
Ideally, I'm trying to avoid creating new columns, and keeping the trigger adjustments to a minimum. But I'm open to any and all suggestions. Thanks for for your time and thoughts.
-JamieI would create a procedure that creates a virtual document with tags, which is what the multi_column_datatstore does behind the scenes. Then I would use that procedure in a user_datastore, so the result is the same for multiple tables as what a multi_column_datastore does for one table. I would also use either auto_section_group or some other type of section group, so that you can search using WITHIN as with the multi_column_datastore. Please see the demonstration below.
SCOTT@orcl_11gR2> -- tables and data that you provided:
SCOTT@orcl_11gR2> CREATE TABLE SUBMISSION
2 ( SUBMISSION_ID NUMBER(10) NOT NULL,
3 SUBMISSION_NAME VARCHAR2(100) NOT NULL
4 )
5 /
Table created.
SCOTT@orcl_11gR2> CREATE TABLE ADVISOR_TYPE
2 ( ADVISOR_TYPE_ID NUMBER(10) NOT NULL,
3 ADVISOR_TYPE_NAME VARCHAR2(50) NOT NULL
4 )
5 /
Table created.
SCOTT@orcl_11gR2> CREATE TABLE SUBMISSION_ADVISORS
2 ( SUBMISSION_ADVISORS_ID NUMBER(10) NOT NULL,
3 SUBMISSION_ID NUMBER(10) NOT NULL,
4 ADVISOR_TYPE_ID NUMBER(10) NOT NULL,
5 FIRST_NAME VARCHAR(50) NULL,
6 LAST_NAME VARCHAR(50) NULL,
7 SUFFIX VARCHAR(20) NULL
8 )
9 /
Table created.
SCOTT@orcl_11gR2> INSERT ALL
2 INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
3 VALUES (1, 'Some Research Paper')
4 INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
5 VALUES (2, 'Thesis on 17th Century Weather Patterns')
6 INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
7 VALUES (3, 'Statistical Analysis on Sunny Days in March')
8 SELECT * FROM DUAL
9 /
3 rows created.
SCOTT@orcl_11gR2> INSERT ALL
2 INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
3 VALUES (1, 'Department Chair')
4 INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
5 VALUES (2, 'Department Co-Chair')
6 INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
7 VALUES (3, 'Professor')
8 INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
9 VALUES (4, 'Associate Professor')
10 INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
11 VALUES (5, 'Scientist')
12 SELECT * FROM DUAL
13 /
5 rows created.
SCOTT@orcl_11gR2> INSERT ALL
2 INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
3 VALUES (1,1,2,'John', 'Doe', 'PhD')
4 INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
5 VALUES (2,1,2,'Jane', 'Doe', 'PhD')
6 INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
7 VALUES (3,2,3,'Johan', 'Smith', NULL)
8 INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
9 VALUES (4,2,4,'Magnus', 'Jackson', 'MS')
10 INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
11 VALUES (5,3,5,'Williard', 'Forsberg', 'AMS')
12 SELECT * FROM DUAL
13 /
5 rows created.
SCOTT@orcl_11gR2> -- constraints presumed based on your description:
SCOTT@orcl_11gR2> ALTER TABLE submission ADD CONSTRAINT submission_id_pk
2 PRIMARY KEY (submission_id)
3 /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE advisor_type ADD CONSTRAINT advisor_type_id_pk
2 PRIMARY KEY (advisor_type_id)
3 /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT submission_advisors_id_pk
2 PRIMARY KEY (submission_advisors_id)
3 /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT submission_id_fk
2 FOREIGN KEY (submission_id) REFERENCES submission (submission_id)
3 /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT advisor_type_id_fk
2 FOREIGN KEY (advisor_type_id) REFERENCES advisor_type (advisor_type_id)
3 /
Table altered.
SCOTT@orcl_11gR2> -- resulting data:
SCOTT@orcl_11gR2> COLUMN submission_name FORMAT A45
SCOTT@orcl_11gR2> COLUMN advisor FORMAT A40
SCOTT@orcl_11gR2> SELECT s.submission_name,
2 a.advisor_type_name || ' ' ||
3 sa.first_name || ' ' ||
4 sa.last_name || ' ' ||
5 sa.suffix AS advisor
6 FROM submission_advisors sa,
7 submission s,
8 advisor_type a
9 WHERE sa.advisor_type_id = a.advisor_type_id
10 AND sa.submission_id = s.submission_id
11 /
SUBMISSION_NAME ADVISOR
Some Research Paper Department Co-Chair John Doe PhD
Some Research Paper Department Co-Chair Jane Doe PhD
Thesis on 17th Century Weather Patterns Professor Johan Smith
Thesis on 17th Century Weather Patterns Associate Professor Magnus Jackson MS
Statistical Analysis on Sunny Days in March Scientist Williard Forsberg AMS
5 rows selected.
SCOTT@orcl_11gR2> -- procedure to create virtual documents:
SCOTT@orcl_11gR2> CREATE OR REPLACE PROCEDURE submission_advisors_proc
2 (p_rowid IN ROWID,
3 p_clob IN OUT NOCOPY CLOB)
4 AS
5 BEGIN
6 FOR r1 IN
7 (SELECT *
8 FROM submission_advisors
9 WHERE ROWID = p_rowid)
10 LOOP
11 IF r1.first_name IS NOT NULL THEN
12 DBMS_LOB.WRITEAPPEND (p_clob, 12, '<first_name>');
13 DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.first_name), r1.first_name);
14 DBMS_LOB.WRITEAPPEND (p_clob, 13, '</first_name>');
15 END IF;
16 IF r1.last_name IS NOT NULL THEN
17 DBMS_LOB.WRITEAPPEND (p_clob, 11, '<last_name>');
18 DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.last_name), r1.last_name);
19 DBMS_LOB.WRITEAPPEND (p_clob, 12, '</last_name>');
20 END IF;
21 IF r1.suffix IS NOT NULL THEN
22 DBMS_LOB.WRITEAPPEND (p_clob, 8, '<suffix>');
23 DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.suffix), r1.suffix);
24 DBMS_LOB.WRITEAPPEND (p_clob, 9, '</suffix>');
25 END IF;
26 FOR r2 IN
27 (SELECT *
28 FROM submission
29 WHERE submission_id = r1.submission_id)
30 LOOP
31 DBMS_LOB.WRITEAPPEND (p_clob, 17, '<submission_name>');
32 DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r2.submission_name), r2.submission_name);
33 DBMS_LOB.WRITEAPPEND (p_clob, 18, '</submission_name>');
34 END LOOP;
35 FOR r3 IN
36 (SELECT *
37 FROM advisor_type
38 WHERE advisor_type_id = r1.advisor_type_id)
39 LOOP
40 DBMS_LOB.WRITEAPPEND (p_clob, 19, '<advisor_type_name>');
41 DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r3.advisor_type_name), r3.advisor_type_name);
42 DBMS_LOB.WRITEAPPEND (p_clob, 20, '</advisor_type_name>');
43 END LOOP;
44 END LOOP;
45 END submission_advisors_proc;
46 /
Procedure created.
SCOTT@orcl_11gR2> SHOW ERRORS
No errors.
SCOTT@orcl_11gR2> -- examples of virtual documents that procedure creates:
SCOTT@orcl_11gR2> DECLARE
2 v_clob CLOB := EMPTY_CLOB();
3 BEGIN
4 FOR r IN
5 (SELECT ROWID rid FROM submission_advisors)
6 LOOP
7 DBMS_LOB.CREATETEMPORARY (v_clob, TRUE);
8 submission_advisors_proc (r.rid, v_clob);
9 DBMS_OUTPUT.PUT_LINE (v_clob);
10 DBMS_LOB.FREETEMPORARY (v_clob);
11 END LOOP;
12 END;
13 /
<first_name>John</first_name><last_name>Doe</last_name><suffix>PhD</suffix><submission_name>Some
Research Paper</submission_name><advisor_type_name>Department Co-Chair</advisor_type_name>
<first_name>Jane</first_name><last_name>Doe</last_name><suffix>PhD</suffix><submission_name>Some
Research Paper</submission_name><advisor_type_name>Department Co-Chair</advisor_type_name>
<first_name>Johan</first_name><last_name>Smith</last_name><submission_name>Thesis on 17th Century
Weather Patterns</submission_name><advisor_type_name>Professor</advisor_type_name>
<first_name>Magnus</first_name><last_name>Jackson</last_name><suffix>MS</suffix><submission_name>The
sis on 17th Century Weather Patterns</submission_name><advisor_type_name>Associate
Professor</advisor_type_name>
<first_name>Williard</first_name><last_name>Forsberg</last_name><suffix>AMS</suffix><submission_name
Statistical Analysis on Sunny Days inMarch</submission_name><advisor_type_name>Scientist</advisor_type_name>
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- user_datastore that uses procedure:
SCOTT@orcl_11gR2> BEGIN
2 CTX_DDL.CREATE_PREFERENCE ('sa_datastore', 'USER_DATASTORE');
3 CTX_DDL.SET_ATTRIBUTE ('sa_datastore', 'PROCEDURE', 'submission_advisors_proc');
4 END;
5 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- index (on optional extra column) that uses user_datastore and section group:
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD (any_column VARCHAR2(1))
2 /
Table altered.
SCOTT@orcl_11gR2> CREATE INDEX submission_advisors_idx
2 ON submission_advisors (any_column)
3 INDEXTYPE IS CTXSYS.CONTEXT
4 PARAMETERS
5 ('DATASTORE sa_datastore
6 SECTION GROUP CTXSYS.AUTO_SECTION_GROUP')
7 /
Index created.
SCOTT@orcl_11gR2> -- what is tokenized, indexed, and searchable:
SCOTT@orcl_11gR2> SELECT token_text FROM dr$submission_advisors_idx$i
2 /
TOKEN_TEXT
17TH
ADVISOR_TYPE_NAME
AMS
ANALYSIS
ASSOCIATE
CENTURY
CHAIR
CO
DAYS
DEPARTMENT
DOE
FIRST_NAME
FORSBERG
JACKSON
JANE
JOHAN
JOHN
LAST_NAME
MAGNUS
MARCH
PAPER
PATTERNS
PHD
PROFESSOR
RESEARCH
SCIENTIST
SMITH
STATISTICAL
SUBMISSION_NAME
SUFFIX
SUNNY
THESIS
WEATHER
WILLIARD
34 rows selected.
SCOTT@orcl_11gR2> -- sample searches across all data:
SCOTT@orcl_11gR2> VARIABLE search_string VARCHAR2(100)
SCOTT@orcl_11gR2> EXEC :search_string := 'professor'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
2 a.advisor_type_name || ' ' ||
3 sa.first_name || ' ' ||
4 sa.last_name || ' ' ||
5 sa.suffix AS advisor
6 FROM submission_advisors sa,
7 submission s,
8 advisor_type a
9 WHERE CONTAINS (sa.any_column, :search_string) > 0
10 AND sa.advisor_type_id = a.advisor_type_id
11 AND sa.submission_id = s.submission_id
12 /
SUBMISSION_NAME ADVISOR
Thesis on 17th Century Weather Patterns Professor Johan Smith
Thesis on 17th Century Weather Patterns Associate Professor Magnus Jackson MS
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'doe'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> /
SUBMISSION_NAME ADVISOR
Some Research Paper Department Co-Chair John Doe PhD
Some Research Paper Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'paper'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> /
SUBMISSION_NAME ADVISOR
Some Research Paper Department Co-Chair John Doe PhD
Some Research Paper Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> -- sample searches within specific columns:
SCOTT@orcl_11gR2> EXEC :search_string := 'chair'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
2 a.advisor_type_name || ' ' ||
3 sa.first_name || ' ' ||
4 sa.last_name || ' ' ||
5 sa.suffix AS advisor
6 FROM submission_advisors sa,
7 submission s,
8 advisor_type a
9 WHERE CONTAINS (sa.any_column, :search_string || ' WITHIN advisor_type_name') > 0
10 AND sa.advisor_type_id = a.advisor_type_id
11 AND sa.submission_id = s.submission_id
12 /
SUBMISSION_NAME ADVISOR
Some Research Paper Department Co-Chair John Doe PhD
Some Research Paper Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'phd'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
2 a.advisor_type_name || ' ' ||
3 sa.first_name || ' ' ||
4 sa.last_name || ' ' ||
5 sa.suffix AS advisor
6 FROM submission_advisors sa,
7 submission s,
8 advisor_type a
9 WHERE CONTAINS (sa.any_column, :search_string || ' WITHIN suffix') > 0
10 AND sa.advisor_type_id = a.advisor_type_id
11 AND sa.submission_id = s.submission_id
12 /
SUBMISSION_NAME ADVISOR
Some Research Paper Department Co-Chair John Doe PhD
Some Research Paper Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'weather'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
2 a.advisor_type_name || ' ' ||
3 sa.first_name || ' ' ||
4 sa.last_name || ' ' ||
5 sa.suffix AS advisor
6 FROM submission_advisors sa,
7 submission s,
8 advisor_type a
9 WHERE CONTAINS (sa.any_column, :search_string || ' WITHIN submission_name') > 0
10 AND sa.advisor_type_id = a.advisor_type_id
11 AND sa.submission_id = s.submission_id
12 /
SUBMISSION_NAME ADVISOR
Thesis on 17th Century Weather Patterns Professor Johan Smith
Thesis on 17th Century Weather Patterns Associate Professor Magnus Jackson MS
2 rows selected. -
Text index for UNION queries.
Hi All,
Can anyone please help me in tuning search query mentioned below
select id from usr1.organizations where lower(ID_official_name) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_NORM_NAME) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NAME) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_TRANS_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NORM_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_TRANS_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_dba_name) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_NORM_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_TRANS_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fka_name) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_NORM_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_TRANS_NAME) like 'technology%'Here organizations table is the parent table having primary key on id column, and rest all tables are children tables having foreign key on id column referencing to primary key id column in organizations table.
Planning to implement multiple column(Userdatastore) text index on dummy column appended to organizations table. And write triggers on other child tables to trigger the sync for Text index.
But not sure whether we can rewrite this above sql query by replacing union into joins, not sure why developer has not done so.
Can anyone please help me in creating text index for this sql. I do not want to approach cartesian joins as these are having parent-child relationship.
Oracle Version: 10.2.0.4
Please let me know if you need more information1 .As text index is created in parent table on id column, can we somehow search only from particular columns(Parent or child) by using user_datastore and tags for sectioning it?
Below are the sql which i need to make use of text index
select m.id from id_ALIAS_NAMEs an
join organizations m on(m.id=an.id)
where lower(ID_ALIAS_NAME) like 'technology%' and m.id_data_provider<100;
select M.id,ID_ALIAS_NAME,'ID_ALIAS_NAME' AS NAMETYPE
from id_alias_names an JOIN organizations m ON m.id=an.id
where id_data_provider<100 AND coalesce(m.ID_COUNTRY_OF_DOMICILE,m.ID_COUNTRY_OF_INCORPORATION)='US'
AND LOWER(ID_ALIAS_NAME) like LOWER('TECHNOLOGY%')
and F_GetFirstWord(ORG_ALIAS_NAME)='TECHNOLOGY'
The text index must be created on a text column, not a numeric id column. It is common to create it on a dummy column. You can name that column anything you like instead of dummy, like search_columns or some such thing. You can add tags in your procedure, so that your resulting virtual column is like xml data. You can then create a section group, so that you can search within each of those tags. In the example below, I used ctxsys.auto_section_group because it is the simplest to create, but you may get better performance by using another type of section group and naming each individual tag.
SCOTT@orcl_11gR2> -- tables you already have:
SCOTT@orcl_11gR2> create table organizations
2 (id number primary key,
3 id_official_name varchar2 (10),
4 id_official_norm_name varchar2 (10),
5 id_official_eng_name varchar2 (10),
6 id_official_trans_name varchar2 (10),
7 id_data_provider number,
8 id_country_of_domicile varchar2 (10),
9 id_country_of_incorporation varchar2 (10))
10 /
Table created.
SCOTT@orcl_11gR2> create table id_alias_names
2 (id number references organizations (id),
3 id_alias_name varchar2 (10),
4 id_alias_norm_name varchar2 (10),
5 id_alias_eng_name varchar2 (10),
6 id_alias_trans_name varchar2 (10))
7 /
Table created.
SCOTT@orcl_11gR2> create table id_doing_business_as_names
2 (id number references organizations (id),
3 id_dba_name varchar2 (10),
4 id_dba_norm_name varchar2 (10),
5 id_dba_eng_name varchar2 (10),
6 id_dba_trans_name varchar2 (10))
7 /
Table created.
SCOTT@orcl_11gR2> create table id_fka_names
2 (id number references organizations (id),
3 id_fka_name varchar2 (10),
4 id_fka_norm_name varchar2 (10),
5 id_fka_eng_name varchar2 (10),
6 id_fka_trans_name varchar2 (10))
7 /
Table created.
SCOTT@orcl_11gR2> -- test data:
SCOTT@orcl_11gR2> insert all
2 into organizations values (1, 'test', 'name2', 'name3', 'name4', 99, 'US', null)
3 into organizations values (2, 'name1', 'name2', 'name3', 'name4', 99, null, 'US')
4 into organizations values (3, 'name1', 'name2', 'name3', 'name4', 99, null, null)
5 into organizations values (4, 'name1', 'name2', 'name3', 'name4', 101, 'US', 'US')
6 into organizations values (5, 'technology', 'technology', 'technology', 'technology', 99, 'US', 'US')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> insert all
2 into id_alias_names values (1, 'technology', 'name6', 'name7', 'name8')
3 into id_alias_names values (2, 'technology', 'test', 'name7', 'name8')
4 into id_alias_names values (3, 'technology', 'name6', 'name7', 'name8')
5 into id_alias_names values (4, 'technology', 'name6', 'name7', 'name8')
6 into id_alias_names values (5, 'name5', 'technology', 'technology', 'technology')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> insert all
2 into id_doing_business_as_names values (1, 'name9', 'name10', 'name11', 'name12')
3 into id_doing_business_as_names values (2, 'name9', 'name10', 'name11', 'name12')
4 into id_doing_business_as_names values (3, 'name9', 'name10', 'test', 'name12')
5 into id_doing_business_as_names values (4, 'name9', 'name10', 'name11', 'name12')
6 into id_doing_business_as_names values (5, 'technology', 'technology', 'technology', 'technology')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> insert all
2 into id_fka_names values (1, 'name13', 'name14', 'name15', 'name16')
3 into id_fka_names values (2, 'name13', 'name14', 'name15', 'name16')
4 into id_fka_names values (3, 'name13', 'name14', 'name15', 'name16')
5 into id_fka_names values (4, 'name13', 'name14', 'name15', 'test')
6 into id_fka_names values (5, 'technology', 'technology', 'technology', 'technology')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> -- revised procedure to join tables with tags:
SCOTT@orcl_11gR2> create or replace procedure your_proc
2 (p_rowid in rowid,
3 p_clob in out nocopy clob)
4 as
5 begin
6 for r1 in
7 (select id,
8 '<id_official_name>'
9 || id_official_name
10 || '</id_official_name><id_official_norm_name>'
11 || id_official_norm_name
12 || '</id_official_norm_name><id_official_eng_name>'
13 || id_official_eng_name
14 || '</id_official_eng_name><id_official_trans_name>'
15 || id_official_trans_name
16 || '</id_official_trans_name>' as tags_and_values
17 from organizations
18 where rowid = p_rowid)
19 loop
20 dbms_lob.writeappend
21 (p_clob, length (r1.tags_and_values), r1.tags_and_values);
22 for r2 in
23 (select '<id_alias_name>'
24 || id_alias_name
25 || '</id_alias_name><id_alias_norm_name>'
26 || id_alias_norm_name
27 || '</id_alias_norm_name><id_alias_eng_name>'
28 || id_alias_eng_name
29 || '</id_alias_eng_name><id_alias_trans_name>'
30 || id_alias_trans_name
31 || '</id_alias_trans_name>' as tags_and_values
32 from id_alias_names
33 where id = r1.id)
34 loop
35 dbms_lob.writeappend
36 (p_clob, length (r2.tags_and_values), r2.tags_and_values);
37 end loop;
38 for r3 in
39 (select '<id_dba_name>'
40 || id_dba_name
41 || '</id_dba_name><id_dba_norm_name>'
42 || id_dba_norm_name
43 || '</id_dba_norm_name><id_dba_eng_name>'
44 || id_dba_eng_name
45 || '</id_dba_eng_name><id_dba_trans_name>'
46 || id_dba_trans_name
47 || '</id_dba_trans_name>' as tags_and_values
48 from id_doing_business_as_names
49 where id = r1.id)
50 loop
51 dbms_lob.writeappend
52 (p_clob, length (r3.tags_and_values), r3.tags_and_values);
53 end loop;
54 for r4 in
55 (select '<id_fka_name>'
56 || id_fka_name
57 || '</id_fka_name><id_fka_norm_name>'
58 || id_fka_norm_name
59 || '</id_fka_norm_name><id_fka_eng_name>'
60 || id_fka_eng_name
61 || '</id_fka_eng_name><id_fka_trans_name>'
62 || id_fka_trans_name
63 || '</id_fka_trans_name>' as tags_and_values
64 from id_fka_names
65 where id = r1.id)
66 loop
67 dbms_lob.writeappend
68 (p_clob, length (r4.tags_and_values), r4.tags_and_values);
69 end loop;
70 end loop;
71 end your_proc;
72 /
Procedure created.
SCOTT@orcl_11gR2> show errors
No errors.
SCOTT@orcl_11gR2> -- examples of virtual columns that revised procedure returns:
SCOTT@orcl_11gR2> declare
2 v_clob clob;
3 begin
4 for r in
5 (select rowid, id
6 from organizations)
7 loop
8 dbms_lob.createtemporary (v_clob, true);
9 your_proc (r.rowid, v_clob);
10 dbms_output.put_line (r.id);
11 dbms_output.put_line (v_clob);
12 dbms_lob.freetemporary (v_clob);
13 end loop;
14 end;
15 /
1
<id_official_name>test</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name3
</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><i
d_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
2
<id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
id_alias_norm_name>test</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
3
<id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>test</id_db
a_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_fk
a_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
4
<id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_
dba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_
fka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>test</id_fka_trans_name>
5
<id_official_name>technology</id_official_name><id_official_norm_name>technology</id_official_norm_name><id_official_eng
_name>technology</id_official_eng_name><id_official_trans_name>technology</id_official_trans_name><id_alias_name>name5</
id_alias_name><id_alias_norm_name>technology</id_alias_norm_name><id_alias_eng_name>technology</id_alias_eng_name><id_al
ias_trans_name>technology</id_alias_trans_name><id_dba_name>technology</id_dba_name><id_dba_norm_name>technology</id_dba
_norm_name><id_dba_eng_name>technology</id_dba_eng_name><id_dba_trans_name>technology</id_dba_trans_name><id_fka_name>te
chnology</id_fka_name><id_fka_norm_name>technology</id_fka_norm_name><id_fka_eng_name>technology</id_fka_eng_name><id_fk
a_trans_name>technology</id_fka_trans_name>
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- user_datastore:
SCOTT@orcl_11gR2> begin
2 ctx_ddl.create_preference ('your_datastore', 'user_datastore');
3 ctx_ddl.set_attribute ('your_datastore', 'procedure', 'your_proc');
4 end;
5 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- dummy column:
SCOTT@orcl_11gR2> alter table organizations add (dummy varchar2(1))
2 /
Table altered.
SCOTT@orcl_11gR2> -- index with auto_section_group,
SCOTT@orcl_11gR2> -- must be on a text column, like dummy, not numeric id column:
SCOTT@orcl_11gR2> create index your_index
2 on organizations (dummy)
3 indextype is ctxsys.context
4 parameters
5 ('datastore your_datastore
6 section group ctxsys.auto_section_group')
7 /
Index created.
SCOTT@orcl_11gR2> -- example queries:
SCOTT@orcl_11gR2> select id
2 from organizations
3 where contains (dummy, 'technology within id_alias_name') > 0
4 and id_data_provider < 100
5 /
ID
1
2
3
3 rows selected.
SCOTT@orcl_11gR2> select m.id, an.id_alias_name, 'ID_ALIAS_NAME' as nametype
2 from id_alias_names an join organizations m on m.id = an.id
3 where contains (m.dummy, 'technology within id_alias_name') > 0
4 and m.id_data_provider < 100
5 and coalesce (m.id_country_of_domicile, m.id_country_of_incorporation) = 'US'
6 /
ID ID_ALIAS_N NAMETYPE
1 technology ID_ALIAS_NAME
2 technology ID_ALIAS_NAME
2 rows selected.
SCOTT@orcl_11gR2> -
Indexing multiple columns of multiple tables
Hi,
I'm trying to index multiple columns of multiple tables.
As I have seen, the way to do this is using User_Datastore.
have the tables to share a (foreign)key? My tables have only 2 or 3 similar columns(description, tagnr...)
I want to get the different tagnr belonging to the same description etc.
Can I do this?
Has anyone a Samplecode indexing multiple tables?
Any suggestion would be helpful.
ArsinehA USER_DATASTORE works like this:
create table A
( id number primary key,
textA varchar2(100));
create table B
( id number primary key,
textB varchar2(100));
procedure foo (rid in rowid, v_document in out varchar2)
v_textA varchar2(2000);
v_idA number;
v_textB varchar2(2000);
begin
select id, textA
into v_idA, v_textA
from A
where rowid = rid;
select textB
into v_textB
from B
where id = v_idA;
v_document := textA | | ' ' | | textB;
end;
create preferences for USER_DATASTORE
create index ...
on table A ( text) ...
you also can build on table B
This depends where you want the
trigger to be build to sync the
documents.
null -
Hi all,
I have a problem indexing files residing on a different server from the one where oracle system resides. I can however load the files into BLOB field using SQLLDR and later index them using CTXSYS.CONTEXT type.
The problem is when using file_datastore to index the files remotely rather than copying them to the database
As shown below:
exec ctx_ddl.create_preference('My_user_datastore', 'FILE_DATASTORE');
exec ctx_ddl.create_preference('My_index_storage', 'BASIC_STORAGE');
exec ctx_ddl.set_attribute('My_index_storage', 'I_TABLE_CLAUSE','tablespace indx storage (initial 1m)');
exec ctx_ddl.set_attribute('My_index_storage', 'K_TABLE_CLAUSE','tablespace indx storage (initial 1m)');
exec ctx_ddl.set_attribute('My_index_storage', 'R_TABLE_CLAUSE','tablespace indx storage (initial 1m)');
exec ctx_ddl.set_attribute('My_index_storage', 'N_TABLE_CLAUSE','tablespace indx storage (initial 1m)');
exec ctx_ddl.set_attribute('My_index_storage', 'I_INDEX_CLAUSE','tablespace indx storage (initial 1m)');
Then create the index as:
CREATE INDEX FILES_INDX
ON FILES_TABLE(FILE_PATH)
INDEXTYPE IS CTXSYS.CONTEXT
parameters ('datastore My_user_datastore storage My_index_storage memory 1m');
This creates a ghost index.
Can anybody help?
Thanks in advance
Regards
NehroIf you use Windows platform it's possible
because Oracle does not support BFILE work with UNC paths.
You can use USER_DATASTORE and read files through HTTP protocol or using Java procedure for loading files from
remote host.
If you want I can send you my Java stored procedure for
work with files. -
USER_DATASTORE: changing index_col invalidates index
I'm using 10g express.
I have a user_data_store defined as:
BEGIN
ctx_ddl.create_preference('rpt_report_store', 'user_datastore');
ctx_ddl.set_attribute('rpt_report_store', 'procedure', 'rpt_search_pkg.report_filter');
ctx_ddl.set_attribute('rpt_report_store', 'output_type', 'CLOB');
END;
CREATE INDEX rpt_report_index ON rpt_reports(index_col) INDEXTYPE IS ctxsys.context
PARAMETERS ('datastore rpt_report_store')
A user uploads a document (which may be one of several versions of a document), and all documents as well as some metadata are indexed together as part of the same "report."
Whenever some one uploads a new document it changes index_col, so that the report will be reindexed. Reindexes are done every hour.
However, as soon as index_col is changed, that entry no longer shows up in the search results. Is there a way to make it sill show up in the results even after this column has changed? I would rather still have it show up based on the old index than not show up at all.
Thanks.Ok. that works.
I ended up doing something like this:
begin
ctx_ddl.create_preference('encrypted_store', 'BASIC_STORAGE');
ctx_ddl.set_attribute('encrypted_store', 'I_TABLE_CLAUSE',
'tablespace encrypted_ts storage (initial 1K)');
ctx_ddl.set_attribute(encrypted_store', 'K_TABLE_CLAUSE',
'tablespace encrypted_ts storage (initial 1K)');
ctx_ddl.set_attribute('encrypted_store', 'R_TABLE_CLAUSE',
'tablespace users storage (initial 1K) lob
(data) store as (disable storage in row cache)');
ctx_ddl.set_attribute('encrypted_store', 'N_TABLE_CLAUSE',
'tablespace encrypted_ts storage (initial 1K)');
ctx_ddl.set_attribute('encrypted_store', 'I_INDEX_CLAUSE',
'tablespace encrypted_ts storage (initial 1K) compress 2');
ctx_ddl.set_attribute('encrypted_store', 'P_TABLE_CLAUSE',
'tablespace encrypted_ts storage (initial 1K)');
end;
CREATE INDEX event_index ON events(index_col) INDEXTYPE IS ctxsys.context
PARAMETERS ('datastore event_store
storage encrypted_store')
Edited by: Abc123Xyz on Oct 30, 2009 10:52 AM -
USER_DATASTORE with VARCHAR2
I'm using Oracle Text with Oracle Enterprise Server 8.1.7 on Solaris.
I try to create an index with a user_datastore based on a procedure returning a varchar2.
It seems to me that I wrote that procedure as the documentation says but I get that error message:
DRG-12604: execution of user datastore procedure has failed
DRG-50857: oracle error in drsinopen
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'STUDY_DATASTORE'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
The procedure I wrote is owned by an application schema:
PROCEDURE STUDY_DATASTORE (rid in rowid, tvarchar2 in out varchar2) IS
cursor cur_study (p_rid in rowid) is
select otherinstitutionname,
othercoursetitle
from study, csuser
where csuser.rowid = p_rid
and csuser.csuserno = study.candidateno
and study.jobofferno = -1;
begin
for rec_study in cur_study (rid)
loop
tvarchar2 := tvarchar2 | | rec_study.otherinstitutionname;
end loop;
END STUDY_DATASTORE;
Then I wrote the procedure owned by CTXSYS:
procedure study_datastore(rid in rowid, tvarchar2 in out nocopy varchar2) is
begin
huge_400.study_datastore(rid, tvarchar2);
end;
I then granted that procedure to the application schema:
grant execute study_datastore to huge_400;
Anyone can see the problem ?
When I write my procedure with a returning clob, I get no problems but it is very slow. That's why I tried with varchar2.You have to set an attribute
ctx_ddl.set_attribute('mystore','output_type','varchar2');
See Documentation about USER_DATASTORE
Regards
Thomas
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Yves Bergeron ([email protected]):
I'm using Oracle Text with Oracle Enterprise Server 8.1.7 on Solaris.
I try to create an index with a user_datastore based on a procedure returning a varchar2.
It seems to me that I wrote that procedure as the documentation says but I get that error message:
DRG-12604: execution of user datastore procedure has failed
DRG-50857: oracle error in drsinopen
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'STUDY_DATASTORE'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
The procedure I wrote is owned by an application schema:
PROCEDURE STUDY_DATASTORE (rid in rowid, tvarchar2 in out varchar2) IS
cursor cur_study (p_rid in rowid) is
select otherinstitutionname,
othercoursetitle
from study, csuser
where csuser.rowid = p_rid
and csuser.csuserno = study.candidateno
and study.jobofferno = -1;
begin
for rec_study in cur_study (rid)
loop
tvarchar2 := tvarchar2 | | rec_study.otherinstitutionname;
end loop;
END STUDY_DATASTORE;
Then I wrote the procedure owned by CTXSYS:
procedure study_datastore(rid in rowid, tvarchar2 in out nocopy varchar2) is
begin
huge_400.study_datastore(rid, tvarchar2);
end;
I then granted that procedure to the application schema:
grant execute study_datastore to huge_400;
Anyone can see the problem ?
When I write my procedure with a returning clob, I get no problems but it is very slow. That's why I tried with varchar2.<HR></BLOCKQUOTE>
null -
InterMedia Text with USER_DATASTORE and ORA-03113
Hi,
I have problems using Oracle's InterMedia Text-index with a
USER_DATASTORE. I'm using Oracle 8.1.7 on Windows NT 4.0.
What I try to do is to create a context-index on multiple columns
of multiple tables. I created a table containing the original
tablenames and primary keys plus a char(1)-column to index, a
user_datastore, a procedure in a user-schema, a
wrapping-procedure in ctxsys' schema and finally the index. All
works fine so far but I get an ORA-03113 "end-of-file on
communication channel" error when querying the table with
contains. The procedure itself works.
Here's what I tried in detail:
I created a table "alldocs" containing the tablename and
primary-key-value of each line of each table plus a dummy-column
for the index:
create table alldocs(
table varchar2(30) not null,
id number not null,
data char(1),
primary key(tabelle, id)
I filled this table:
insert into alldocs (select 'MYDOCS', id, 'a' from mydocs);
insert into alldocs (select 'OTHERDOCS', id, 'b' from otherdocs);
The user's procedure - only dummy for testing - is:
create procedure test.GetAllDocsData(row IN ROWID, data IN OUT
NOCOPY CLOB) IS
tabname varchar2(30);
myid number;
tmpclob clob;
begin
dbms_lob.createtemporary(tmpclob, TRUE);
dbms_lob.writeappend(tmpclob, 34, 'Ein Text mit ca. 20
Zeichen Ldnge.');
data := tmpclob;
end;
In ctxsys' schema I defined the following procedure and the
datastore:
create or replace procedure sysGetAllDocsData(rid in rowid, tlob
in out clob) is
begin
test.GetAllDocsData(rid, tlob);
end sysGetAllDocsData;
grant execute on sysGetAllDocsData to test;
call ctx_ddl.create_preference('MyUserDS', 'user_datastore');
call ctx_ddl.set_attribute('MyUserDS', 'procedure',
'sysGetAllDocsData');
call ctx_ddl.set_attribute('MyUserDS', 'output_type', 'CLOB');
Finally I defined the index:
create index test.alldocs_ctx on test.alldocs(data)
indextype is ctxsys.context
parameters ('DATASTORE CTXSYS.MyUserDS FILTER
CTXSYS.INSO_FILTER LEXER BASIC_LEXER');
This all works without errors. But when querying like this:
select * from test.alldocs where contains('data', 'Text')>0
the answer is
ORA-03113: end-of-file on communication channel
I hope someone can help.
Greetings
RalfHi Ralf,
please define first your own preferences like this:
exec CTX_DDL.drop_preference('MY_LEXER');
exec CTX_DDL.create_preference('MY_LEXER','BASIC_LEXER');
exec CTX_DDL.set_attribute('MY_LEXER','ALTERNATE_SPELLING',
'GERMAN');
exec CTX_DDL.set_attribute('MY_LEXER','BASE_LETTER','YES');
exec CTX_DDL.set_attribute('MY_LEXER','MIXED_CASE', 'NO');
exec CTX_DDL.set_attribute('MY_LEXER','INDEX_THEMES','NO');
exec CTX_DDL.set_attribute('MY_LEXER','INDEX_TEXT', 'YES');
exec CTX_DDL.set_attribute('MY_LEXER','COMPOSITE', 'GERMAN');
exec ctx_ddl.Drop_Preference ('MY_FILTER');
exec ctx_ddl.Create_Preference ('MY_FILTER','NULL_FILTER');
exec ctx_ddl.drop_section_group ('MY_SECTION');
exec ctx_ddl.create_section_group
('MY_SECTION','NULL_SECTION_GROUP');
and then create your index with this preferences. You only need
an INSO filter if you want to index pdf,word,...
create index test.alldocs_ctx on test.alldocs(data)
indextype is ctxsys.context
parameters ('DATASTORE CTXSYS.MyUserDS FILTER
CTXSYS.INSO_FILTER LEXER BASIC_LEXER');create index test.alldocs_ctx on test.alldocs(data)
indextype is ctxsys.context
parameters ('
DATASTORE CTXSYS.MyUserDS
lexer MY_LEXER
filter MY_FILTER
section group MY_SECTION');
Then see in the token table what tokens are in the index:
select token_text from dr$alldocs_ctx$i;
If you got also an ORA-3113 see in alert.log if there is a trace
referenced with this error and have a look in this file to find a
better error message.
Good luck.
Thomas -
OK, so nobody has seen the problem that I
am seeing with user_datastore, per my
previous post.
Is anybody here using the user_datastore
feature in 8.1.7 successfully? It would
help me just to know that somebody is
actually using it, because I can't even
get the Oracle samples for this feature to
work. I suspect it is a problem with my
ctx configuration, but have no idea where to
start looking.....You have to set an attribute
ctx_ddl.set_attribute('mystore','output_type','varchar2');
See Documentation about USER_DATASTORE
Regards
Thomas
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Yves Bergeron ([email protected]):
I'm using Oracle Text with Oracle Enterprise Server 8.1.7 on Solaris.
I try to create an index with a user_datastore based on a procedure returning a varchar2.
It seems to me that I wrote that procedure as the documentation says but I get that error message:
DRG-12604: execution of user datastore procedure has failed
DRG-50857: oracle error in drsinopen
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'STUDY_DATASTORE'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
The procedure I wrote is owned by an application schema:
PROCEDURE STUDY_DATASTORE (rid in rowid, tvarchar2 in out varchar2) IS
cursor cur_study (p_rid in rowid) is
select otherinstitutionname,
othercoursetitle
from study, csuser
where csuser.rowid = p_rid
and csuser.csuserno = study.candidateno
and study.jobofferno = -1;
begin
for rec_study in cur_study (rid)
loop
tvarchar2 := tvarchar2 | | rec_study.otherinstitutionname;
end loop;
END STUDY_DATASTORE;
Then I wrote the procedure owned by CTXSYS:
procedure study_datastore(rid in rowid, tvarchar2 in out nocopy varchar2) is
begin
huge_400.study_datastore(rid, tvarchar2);
end;
I then granted that procedure to the application schema:
grant execute study_datastore to huge_400;
Anyone can see the problem ?
When I write my procedure with a returning clob, I get no problems but it is very slow. That's why I tried with varchar2.<HR></BLOCKQUOTE>
null -
Hello,
i'm trying to use synonyms in an oracle namesearch. I setup a name seqarch like in the second example described in the oracle text application developer's guide at http://download.oracle.com/docs/cd/E18283_01/text.112/e16594/search.htm
Now the name i'm searching for might contain a '&', for example 'B & V'.
I'd like to find this text when i enter 'B&V', B & V' or even 'B and V'.
I found a thread about setting up a thesaurus with synonyms for '&' and 'and' at "and" and Ampersand or special characters
Now i wonder how to combine this.
Thanks for help in advance,
DirkIn the following example, I started with the code from the second example in the link provided. I added one row of data containing the "B & V" for testing. I added "&" and "and" to the thesaurus as synonyms. I added a function to format the search string by adding an extra space around "&", removing duplicate spaces, adding "{" and "}" around each reserved keyword, trimming the result, and returning it. I then modified the query to use the function. That seems to be all that is necessary. It does not seem to be necessary to change the stoplist or printjoins, due to the way the rest of the code is written. I added comment lines to show where I made changes. I did not change the procedure, but you may want to modify it as the usage of regexp seems to be only outputting the last four digits of the phone.
SCOTT@orcl_11gR2> create table emp (
2 first_name varchar2(30),
3 middle_name varchar2(30),
4 last_name varchar2(30),
5 email varchar2(30),
6 phone varchar2(30));
Table created.
SCOTT@orcl_11gR2> insert into emp values
2 ('John', 'Black', 'Smith', '[email protected]', '123-456-7890');
1 row created.
SCOTT@orcl_11gR2>
SCOTT@orcl_11gR2> -- added row of data:
SCOTT@orcl_11gR2> set define off
SCOTT@orcl_11gR2> insert into emp values
2 ('Jane', 'Doe', 'word B & V word', '[email protected]', '321-654-0987');
1 row created.
SCOTT@orcl_11gR2>
SCOTT@orcl_11gR2> create or replace procedure empuds_proc
2 (rid in rowid, tlob in out nocopy clob) is
3 tag varchar2(30);
4 phone varchar2(30);
5 begin
6 for c1 in (select FIRST_NAME, MIDDLE_NAME, LAST_NAME, EMAIL, PHONE
7 from emp
8 where rowid = rid)
9 loop
10 tag :='<email>';
11 dbms_lob.writeappend(tlob, length(tag), tag);
12 if (c1.EMAIL is not null) then
13 dbms_lob.writeappend(tlob, length(c1.EMAIL), c1.EMAIL);
14 end if;
15 tag :='</email>';
16 dbms_lob.writeappend(tlob, length(tag), tag);
17 tag :='<phone>';
18 dbms_lob.writeappend(tlob, length(tag), tag);
19 if (c1.PHONE is not null) then
20 phone := nvl(REGEXP_SUBSTR(c1.PHONE, '\d\d\d\d($|\s)'), ' ');
21 dbms_lob.writeappend(tlob, length(phone), phone);
22 end if;
23 tag :='</phone>';
24 dbms_lob.writeappend(tlob, length(tag), tag);
25 tag :='<fullname>';
26 dbms_lob.writeappend(tlob, length(tag), tag);
27 if (c1.FIRST_NAME is not null) then
28 dbms_lob.writeappend(tlob, length(c1.FIRST_NAME), c1.FIRST_NAME);
29 dbms_lob.writeappend(tlob, length(' '), ' ');
30 end if;
31 if (c1.MIDDLE_NAME is not null) then
32 dbms_lob.writeappend(tlob, length(c1.MIDDLE_NAME), c1.MIDDLE_NAME);
33 dbms_lob.writeappend(tlob, length(' '), ' ');
34 end if;
35 if (c1.LAST_NAME is not null) then
36 dbms_lob.writeappend(tlob, length(c1.LAST_NAME), c1.LAST_NAME);
37 end if;
38 tag :='</fullname>';
39 dbms_lob.writeappend(tlob, length(tag), tag);
40 end loop;
41 end;
42 /
Procedure created.
SCOTT@orcl_11gR2> show errors
No errors.
SCOTT@orcl_11gR2> begin
2 ctx_ddl.create_preference('empuds', 'user_datastore');
3 ctx_ddl.set_attribute('empuds', 'procedure', 'empuds_proc');
4 ctx_ddl.set_attribute('empuds', 'output_type', 'CLOB');
5 end;
6 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> begin
2 ctx_ddl.create_section_group('namegroup', 'BASIC_SECTION_GROUP');
3 ctx_ddl.add_ndata_section('namegroup', 'fullname', 'fullname');
4 ctx_ddl.add_ndata_section('namegroup', 'phone', 'phone');
5 ctx_ddl.add_ndata_section('namegroup', 'email', 'email');
6 end;
7 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> begin
2 ctx_thes.create_thesaurus ('nicknames');
3 ctx_thes.create_relation ('nicknames', 'John', 'syn', 'Jon');
4 end;
5 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2>
SCOTT@orcl_11gR2> -- added synonym to thesaurus:
SCOTT@orcl_11gR2> begin
2 ctx_thes.create_relation ('nicknames', '&', 'syn', 'and');
3 end;
4 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2>
SCOTT@orcl_11gR2> begin
2 ctx_ddl.create_preference('NDATA_WL', 'BASIC_WORDLIST');
3 ctx_ddl.set_attribute('NDATA_WL', 'NDATA_ALTERNATE_SPELLING', 'FALSE');
4 ctx_ddl.set_attribute('NDATA_WL', 'NDATA_BASE_LETTER', 'TRUE');
5 ctx_ddl.set_attribute('NDATA_WL', 'NDATA_THESAURUS', 'NICKNAMES');
6 ctx_ddl.set_attribute('NDATA_WL', 'NDATA_JOIN_PARTICLES',
7 'de:di:la:da:el:del:qi:abd:los:la:dos:do:an:li:yi:yu:van:jon:un:sai:ben:al');
8 end;
9 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> create index name_idx on emp (first_name)
2 indextype is ctxsys.context
3 parameters
4 ('datastore empuds
5 section group namegroup
6 wordlist ndata_wl');
Index created.
SCOTT@orcl_11gR2>
SCOTT@orcl_11gR2> -- added function to format search string:
SCOTT@orcl_11gR2> create or replace function format_string
2 (p_string in varchar2)
3 return varchar2
4 as
5 v_string varchar2 (32767) := ' ' || p_string || ' ';
6 begin
7 -- add extra spaces around ampersand:
8 v_string := replace (v_string, '&', ' & ');
9 -- remove duplciate spaces:
10 while instr (v_string, ' ') > 0
11 loop
12 v_string := replace (v_string, ' ', ' ');
13 end loop;
14 -- add { and } around each reserved word:
15 for r in
16 (select keyword,
17 ' ' || keyword || ' ' keyword2
18 from v$reserved_words)
19 loop
20 v_string := replace (upper (v_string), r.keyword2, ' {' || r.keyword || '} ');
21 end loop;
22 return ltrim (rtrim (v_string));
23 end format_string;
24 /
Function created.
SCOTT@orcl_11gR2> show errors
No errors.
SCOTT@orcl_11gR2> -- examples of usage of function:
SCOTT@orcl_11gR2> select format_string ('B & V') from dual;
FORMAT_STRING('B&V')
B {&} V
1 row selected.
SCOTT@orcl_11gR2> select format_string ('B and V') from dual;
FORMAT_STRING('BANDV')
B {AND} V
1 row selected.
SCOTT@orcl_11gR2> select format_string ('B&V') from dual;
FORMAT_STRING('B&V')
B {&} V
1 row selected.
SCOTT@orcl_11gR2>
SCOTT@orcl_11gR2> -- query modified to apply foramt_string function to :name variable:
SCOTT@orcl_11gR2> var name varchar2(80);
SCOTT@orcl_11gR2> exec :name := 'Jon Blacksmith'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> column first_name format a10
SCOTT@orcl_11gR2> column middle_name format a11
SCOTT@orcl_11gR2> column last_name format a9
SCOTT@orcl_11gR2> column phone format a12
SCOTT@orcl_11gR2> column email format a22
SCOTT@orcl_11gR2> select first_name, middle_name, last_name, phone, email, scr
2 from (select /*+ FIRST_ROWS */
3 first_name, middle_name, last_name, phone, email, score(1) scr
4 from emp
5 where contains
6 (first_name,
7 'ndata (phone,' || format_string (:name) || ') OR
8 ndata (email,' || format_string (:name) || ') OR
9 ndata (fullname,' || format_string (:name) || ')',
10 1) > 0
11 order by score (1) desc)
12 where rownum <= 10;
FIRST_NAME MIDDLE_NAME LAST_NAME PHONE EMAIL SCR
John Black Smith 123-456-7890 [email protected] 93
1 row selected.
SCOTT@orcl_11gR2> -- enter new values for :name and re-run query:
SCOTT@orcl_11gR2> exec :name := 'B & V'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> /
FIRST_NAME MIDDLE_NAME LAST_NAME PHONE EMAIL SCR
Jane Doe word B & 321-654-0987 [email protected] 61
V word
1 row selected.
SCOTT@orcl_11gR2> exec :name := 'B and V'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> /
FIRST_NAME MIDDLE_NAME LAST_NAME PHONE EMAIL SCR
Jane Doe word B & 321-654-0987 [email protected] 80
V word
1 row selected.
SCOTT@orcl_11gR2> exec :name := 'B&V'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> /
FIRST_NAME MIDDLE_NAME LAST_NAME PHONE EMAIL SCR
Jane Doe word B & 321-654-0987 [email protected] 61
V word
1 row selected.
SCOTT@orcl_11gR2> exec :name := 'B something V'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> /
no rows selected
SCOTT@orcl_11gR2>
SCOTT@orcl_11gR2> -- cleanup:
SCOTT@orcl_11gR2> drop function format_string;
Function dropped.
SCOTT@orcl_11gR2> exec ctx_ddl.drop_preference('ndata_wl');
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> exec ctx_thes.drop_thesaurus ('nicknames');
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> exec ctx_ddl.drop_section_group('namegroup');
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> exec ctx_ddl.drop_preference('empuds');
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> drop procedure empuds_proc;
Procedure dropped.
SCOTT@orcl_11gR2> drop table emp;
Table dropped.
SCOTT@orcl_11gR2> -
Oracle Text with User_DataStore is not working
Hi Expert,
Based on this url : http://docs.oracle.com/cd/B28359_01/text.111/b28304/cdatadic.htm#i1006810
I was trying to create an oracle text index , but i wasn't able to retrieve the data
here are my scripts:
create table articles(
id number,
author varchar2(80),
title varchar2(120),
text clob );
create procedure myproc(rid in rowid, tlob in out clob nocopy) is
begin
for c1 in (select author, title, text from articles
where rowid = rid)
loop
dbms_lob.writeappend(tlob, length(c1.title), c1.title);
dbms_lob.writeappend(tlob, length(c1.author), c1.author);
dbms_lob.writeappend(tlob, length(c1.text), c1.text);
end loop;
end;
begin
ctx_ddl.create_preference('myud', 'user_datastore');
ctx_ddl.set_attribute('myud', 'procedure', 'myproc');
ctx_ddl.set_attribute('myud', 'output_type', 'CLOB');
end;
create index myindex2 on articles(text)
indextype is ctxsys.context
parameters ('DATASTORE myud');
insert into articles(id,author,title)values (1,'A','AAAAAA');commit;
insert into articles(id,author,title)values (2,'B','BBBBBB');commit;
insert into articles(id,author,title)values (3,'C','CCCCCC');commit;
insert into articles(id,author,title)values (4,'D','DDDDDD');commit;
EXEC CTX_DDL.SYNC_INDEX('myindex2','2M');
select * from articles where contains(text,'B',1)>0; -- this display nothing.
Can anybody help me?It's absolutly essential to get into the details of Oracle Text if it is used for more than pretty simple things.
Query the index tables and view the tokens stored.
Is there any token like 'B'?
I guess no. Because your function constructs something other ...
What do you get, if you try 'B%' instead of 'B'? -
How do I use Edge Web Fonts with Muse?
How do I use Edge Web Fonts with Muse - is it an update to load, a stand alone, how does it interface with Muse? I've updated to CC but have no info on this.
Hello,
Is there a reason why you want to use Edge Web Fonts with Adobe Muse?
Assuming you wish to improve typography of your web pages, you should know that Muse is fully integrated with Typekit. This allows you to access and apply over 500 web fonts from within Muse. Here's how you do it:
Select a text component within Muse, and click the Text drop-down.
Select Add Web Fonts option, to pop-open the Add Web Fonts dialog.
Browse and apply fonts per your design needs.
Muse also allows you to create paragraph styles that you can save and apply to chunks of text, a la InDesign. Watch this video for more information: http://tv.adobe.com/watch/muse-feature-tour/using-typekit-with-adobe-muse/
Also take a look at these help files to see if they help you:
http://helpx.adobe.com/muse/tutorials/typography-muse-part-1.html
http://helpx.adobe.com/muse/tutorials/typography-muse-part-2.html
http://helpx.adobe.com/muse/tutorials/typography-muse-part-3.html
Hope this helps!
Regards,
Suhas Yogin
Maybe you are looking for
-
PSE 11 Organizer shows broken images on almost all jpgs
1. I spent three days reorganizing all of my 90,000+ photos, putting them in hierarchical date ordered folders on my Windows 7 PC with 16GB RAM, lots of HD space on my second HD E (recently installed from an older laptop but with 700GB, 60% available
-
Runtime type of Collection contents?
I'm pretty certain I know the answer to this question, but anyway: In a JavaBean editor, one property of the bean may be a collection of (potentially editable) beans. To edit the property I can display the appropriate editor if I can determine the ty
-
Recently, I installed Yosemite on my MacBook Air. After that I had no sound. Not even the start up chime. In Sound preferences there are no input devices and no output devices. I have had three meetings with Apple support with no results. Can anyone
-
Ways to show only the non-end dated portofolio manager.
Hi All, I have a fund raising application (Raiser's edge), and I have to show each donor along with his/her primary portfolio manager. Each donor could have more than one manager but there could be only two current manager (primary & secondary). If
-
I just ran the latest update to 10.8.2 and now Mail won't open. I get an error message saying that the version 6.2 I have is not compatible with the 10.8.2 OSX. Any ideas what to do...I depend on Mail for work!