error when collecting tokens from a full text database - oracle

I want to test Oracle's CTX_DOC.TOKENS procedure in order to count the number of occurrence of a string into a document.
For this, I have:
create table documents (id number primary key, text bfile);
insert into documents values (1, bfilename('MY_DIR','12things_about_122.pdf'));
create index documents_idx on documents (text) indextype is ctxsys.context;
declare
the_tokens ctx_doc.token_tab;
begin
ctx_doc.set_key_type ('PRIMARY_KEY');
ctx_doc.tokens('documents_idx','1',the_tokens);
dbms_output.put_line('Number of tokens: '|| the_tokens.count);
end;
When I test this, the PLSQL part fails with:
Error report:
ORA-20000: Oracle Text error:
DRG-10001: can not access result table the_tokens
ORA-06512: at "CTXSYS.DRUE", line 160
ORA-06512: at "CTXSYS.CTX_DOC", line 862 ORA-06512: at line 5
00000 - "%s"
*Cause: The stored procedure 'raise_application_error'
was called which causes this error to be generated.
*Action: Correct the problem as described in the error message or contact
the application administrator or DBA for more information.
Can you help me to understand what is needed much more in order to work correctly, please?
Thank you,

it seems that the answer was too easy to be seen from the 1st time:
It was necessary to referenciate the ctx_doc.token_tab; with schema name, too.
Instead of the_tokens ctx_doc.token_tab, I had to do the_tokens ctxsys.ctx_doc.token_tab;

Related

Object is invalid PLSQL Procedure

I use a dataset that has billing information:
Table Image
And I want to create a procedure that gives information about a specific bill by giving an invoice id
CREATE OR REPLACE PROCEDURE print_information(
invoiceID varchar(11);
) IS
p_smtable supermarket%ROWTYPE;
BEGIN
SELECT * INTO p_smtable FROM SUPERMARKET
WHERE invoice_id = invoiceID;
DBMS_OUTPUT.PUT_LINE(p_smtable.brancj || p_smtable.city);
END;
The compilation is successful.
Compile
begin
print_information('750-67-8428');
end;
But I get an error that says:
Error starting at line : 12 in command -
begin
print_information('750-67-8428');
end;
Error report -
ORA-06550: line 2, column 1:
PLS-00905: object SYSTEM.PRINT_INFORMATION is invalid
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
The code in the screenshot is different to the version in your question, but both have an error at line 2. The parameter should be varchar2 or supermarket.invoice_id%type, with no semicolon.
Also, we normally use a p_ prefix for parameters, not variables. (There are other conventions, but whatever you use, p_ for a variable is just confusing.)
A fixed version might be:
create or replace procedure print_information
( p_invoice_id supermarket.invoice_id%type )
as
l_market supermarket%rowtype;
begin
select * into l_market
from supermarket
where invoice_id = p_invoice_id;
dbms_output.put_line(l_market.brancj || ' '|| l_market.city);
end;
Whatever tool you are using for development, you need to become familiar with how to display compilation errors.
brancj might be a typo for branch.
I've assumed you want a space between branch and city, otherwise the output would be something like TottenhamLondon rather than Tottenham London.
In Oracle a schema belongs to one user, created with the CREATE USER command. An Oracle Database is the entire thing (all users, all data, storage, memory, processes, everything) so you would not normally create one for something like this.

Creating a procedure that inserts into 2 tables with a relationship

I understand that there is a lot of questions like this one but as it is for my school project it needs to follow the same techniques that they have taught us and the other answers aren't quite what i'm looking for.
My code:
CREATE or REPLACE PROCEDURE add_hire1 (hire_no_in IN NUMBER, date_hired_in IN DATE, drop_off_in IN DATE, fk1_customer_id_in IN NUMBER, fk2_charge_no_in IN NUMBER,
charge_no_in, final_cost_in)
AS
BEGIN
INSERT INTO hire(hire_no, date_hired, drop_off, fk1_customer_id, fk2_charge_no)
VALUES (hire_no_in, date_hired_in, drop_off_in, fk1_customer_id_in, fk2_charge_no_in);
INSERT INTO charge(charge_no, final_cost)
VALUES(charge_no_in, final_cost_in);
END add_hire1;
This is the error returned:
ORA-24344: success with compilation error
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_190100", line 590
ORA-06512: at "SYS.DBMS_SYS_SQL", line 1658
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_190100", line 576
ORA-06512: at "APEX_190100.WWV_FLOW_DYNAMIC_EXEC", line 2033
As we have just been taught how to do it with one table I have just added the second table in the same format as the original code so I'm not sure if it's correct or if there's just a few small errors.
Any help appreciated,
Thanks.
ORA-24344 signifies compilation errors. If you are using a tool like SQL Developer it should show you the compilation errors. But you can always find them for yourself like this:
select * from user_errors
where name = 'ADD_HIRE1'
If we had a package which compiled then we changed it and now it doesn't compile we know we need to focus on the changes we made. In this case we can see that the two parameters you've just added …
,
charge_no_in, final_cost_in)
AS
… are not declared in the same way as the other parameters:
, fk1_customer_id_in IN NUMBER, fk2_charge_no_in IN NUMBER
That difference is a big clue as to how you need to fix your code.

ORA-20000: Oracle Text error: DRG-10599: column is not indexed where index exists on select "for update"

I was trying to update a CLOB column but failed with the column was not indexed error.
I tried to drop and recreate the index but still ran into the same error:
create index idx_response_contxt on test (response) indextype is ctxsys.context;
declare
begin
for i in (select response from test
where contains(response,'{"IdType">BANK}') > 0 for update) loop
dbms_lob.write(i.response, 12, 5444, '111111111111');
end loop;
end;
/
ERROR at line 1:
ORA-20000: Oracle Text error:
DRG-10599: column is not indexed
ORA-06512: at line 4
It seemed like the "for update" disabled the index. If I ran without contains function, I didn't get any error but very costly:
declare
begin
for i in (select response from test where response like '%"IdType">BANK%' for update) loop
dbms_lob.write(i.response, 12, 5444, '111111111');
end loop;
end;
/
Any suggestion? Thanks!
You need to use proper parameter while creating index as it will decide when index will be synchronized. It can be real time or periodical.
create index idx_response_contxt on test (response)
indextype is ctxsys.context PARAMETERS ('SYNC (ON COMMIT)'); -- real time synchronization
Above example is real time rebuild index. You can use different clauses in PARAMETER to rebuild at configurable time. Like '(SYNC (EVERY "SYSDATE+1/24")' -- will synch every hour, periodical
Use this as per requirement.
Cheers!!
I rebuilt the index with "PARAMETERS ('SYNC (ON COMMIT)')" and ran the query again, but no use because it still didn't see the index and gave "ORA-20000: Oracle Text error:
DRG-10599: column is not indexed" error.
Any other suggestions? Thanks.

ORA-00604: error occurred at recursive SQL level 1 ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 22

While doing an import in an oracle 10G database using imp, I receive following error:
IMP-00017: following statement failed with ORACLE error 604:
CREATE TABLE DASHBOARD_ADMINISTRATOR
(ID NUMBER(19, 0) NOT NULL ENABLE,
USER_NAME VARCHAR2(20) NOT NULL ENABLE,
NAME VARCHAR2(50), FIRST_NAME VARCHAR2(50));
IMP-00003: ORACLE error 604 encountered
ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 22
When doing the same thing in TOAD, I have the same error even if I only try to create the table with only 1 column specificied, which is even more strange since I only have 2 lines...
Creating a table called DASHBOARD_ADMINISTRATO is possible, DASHBOARD_ADMINISTRATORR gives again the same error.
However, when I switch places of the words in the name, it works fine.
There is no limit set on tablename length because several of the imported tables have more characters.
I used the same dumpfile to import into oracle 11G and there it was successful.
Any ideas, someone?
Thx for your help.
"character string buffer too small" - Mayby try to increase Varchar Tables. And change number(19,0) to number(19) - ID's is just an integer, they don't have coma, period. In importing/exporting various scenarios came out :)

How to deploy Oracle Dimension table for OLAP Cubes

I followed First Example as well as Second Example to create Cubes in Oracle 10g.
I tried to create cube using query rewrite mechanism in Oracle 10g.
(Intailly tried to create using Analystic workspace manager we got error in that too so only we went for query rewrite mechansism)
We succeded in creating table "PRODUCTS"
Also we succedded in creating Dimension for that table "PRODUCTS"
But when we try to create Attribute for the above "PRODUCTS" table like below
BEGIN
cwm_classify.remove_entity_descriptor_use(28, cwm_utility.DIMENSION_TYPE, 'SH', 'PRODUCTS');
COMMIT;
END
we are getting following error.
Note : We have data inside table too
Error starting at line 1 in command:
begin
cwm_classify.remove_entity_descriptor_use(28, cwm_utility.DIMENSION_TYPE, 'SH', 'PRODUCTS');
commit;
end;
Error report:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "OLAPSYS.CWM$OLAP$DIMENSION", line 242
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "OLAPSYS.CWM$UTIL", line 368
ORA-01403: no data found
ORA-06512: at "OLAPSYS.CWM$CLASSIFY", line 322
ORA-06512: at "OLAPSYS.CWM$CLASSIFY", line 1198
ORA-06512: at line 2
06510. 00000 - "PL/SQL: unhandled user-defined exception"
*Cause: A user-defined exception was raised by PL/SQL code, but
not handled.
*Action: Fix the problem causing the exception or write an exception
handler for this condition. Or you may need to contact your
application administrator or DBA.
When i googled i got suggestion like we have to deploy Dimension also before deploying Cubes.
So i'm trying to create OLAP Cubes for this i need to to deploy Dimension Tables in Oracle.
Is there any way to deploy Dimension is that possible actually?
Suggest me how to do this?
Assuming you are using Analytic Workspace Manager, the OLAP documentation would be a good place to start:
http://download.oracle.com/docs/cd/E11882_01/olap.112/e17123/cubes.htm#BGBDJAAG

Resources