Using contains in a PLSQL procedure?

This works
select
index_words, ctxsys.score( 1) scr
from
cryo_distinct_index_words2
where
ctxsys.contains(index_words ,'test',1) > 0
order
by ctxsys.score( 1) desc
This does not:
CREATE OR REPLACE PROCEDURE Assign_Catagory2 IS
Cursor select_titles is
select title from cryo_titles
order by title;
t_score number(5);
t_title varchar2(1000);
t_category varchar2(1000);
query_phrase varchar2(1000);
BEGIN
open select_titles;
loop
fetch select_titles into t_title;
exit when select_titles%notfound;
query_phrase := t_title;
for c1 in (select index_words, ctxsys.score(1) scr
from cryo_distinct_index_words2
where ctxsys.contains(index_words,t_title,1) > 0
order by ctxsys.score(1) desc)
loop
insert into cryo_title_category values (t_title, t_category);
end loop;
end loop;
END Assign_Catagory2;
PLS-00320: the declaration of the type of this expression is incomplete or malformed
I've tried to use:
where ctxsys.contains(index_words,''t_title'',1) > 0
or
where ctxsys.contains(index_words,'''||t_title||''',1) > 0
but nothing seems to work.
Any ideas?

If there are any null values in ct.title, that will produce the error. Try adding "and ct.title is not null". Please see the demonstration below. Also, there is another more appropriate discussion group on these forums that is devoted exclusively to text.
scott@ORA92> CREATE TABLE cryo_distinct_index_words2
  2    (INDEX_WORDS VARCHAR2(1000))
  3  /
Table created.
scott@ORA92> INSERT ALL
  2  INTO  cryo_distinct_index_words2 VALUES (NULL)
  3  INTO  cryo_distinct_index_words2 VALUES ('test')
  4  SELECT * FROM DUAL
  5  /
2 rows created.
scott@ORA92> CREATE TABLE cryo_titles
  2    (TITLE         VARCHAR2(1000),
  3       SELECTED    VARCHAR2(1))
  4  /
Table created.
scott@ORA92> INSERT ALL
  2  INTO cryo_titles VALUES (NULL, NULL)
  3  INTO cryo_titles VALUES ('test', NULL)
  4  SELECT * FROM DUAL
  5  /
2 rows created.
scott@ORA92> CREATE TABLE cryo_title_category
  2    (title         VARCHAR2(1000),
  3       category    VARCHAR2(1000),
  4       score         NUMBER)
  5  /
Table created.
scott@ORA92> CREATE INDEX cdiw_iw_idx
  2  ON cryo_distinct_index_words2 (index_words)
  3  INDEXTYPE IS CTXSYS.CONTEXT
  4  /
Index created.
scott@ORA92> -- reproduction of error:
scott@ORA92> insert into cryo_title_category (TITLE, CATEGORY, SCORE)
  2  select title title, index_words index_words, ctxsys.score(1) scr
  3  from   cryo_distinct_index_words2 cdiw, cryo_titles ct
  4  where  ctxsys.contains(cdiw.index_words,ct.title,1) > 0
  5  /
insert into cryo_title_category (TITLE, CATEGORY, SCORE)
ERROR at line 1:
ORA-29902: error in executing ODCIIndexStart() routine
ORA-20000: Oracle Text error:
DRG-50901: text query parser syntax error on line 1, column 1
scott@ORA92> -- correction:
scott@ORA92> insert into cryo_title_category (TITLE, CATEGORY, SCORE)
  2  select title title, index_words index_words, ctxsys.score(1) scr
  3  from   cryo_distinct_index_words2 cdiw, cryo_titles ct
  4  where  ctxsys.contains(cdiw.index_words,ct.title,1) > 0
  5  and    ct.title is not null
  6  /
1 row created.
scott@ORA92> SELECT * FROM cryo_title_category
  2  /
TITLE
CATEGORY
     SCORE
test
test
         4
scott@ORA92>

Similar Messages

  • Remote debugging plsql procedures in jdeveloper using J2EE container

    I have a J2EE application which is connected to an oracle database .For debugging purposes ,can i remotely debug my plsql stored procedures when an action comes from the J2EE server . That is, can i control a call from the server by using breakpoints in my plsql stored procedures so that i can see the run time parameters to the plsql procedures and so

    Yes you can. See : http://blogs.oracle.com/shay/2005/12/20#a58

  • Update a table using plsql procedure

    Can any one help me to write a plsql procedure to update a table with new records and changes;
    Table rtest1 contains following records:
    deptno(number) deptname(varchar2(10)
    10 EWP
    20 PWD
    30 EPF
    Table rtest2 contains follwing records:
    deptno(number) deptname(varchar2(10)
    10 prod
    40 ops
    how to write a plsql procedure to to update table rtest2 using rtest1 data .

    use a merge statement, like this:
    SQL> create table rtest1
      2  as
      3  select 10 deptno, 'EWP' deptname from dual union all
      4  select 20, 'PWD' from dual union all
      5  select 30, 'EPF' from dual
      6  /
    Tabel is aangemaakt.
    SQL> create table rtest2
      2  as
      3  select 10 deptno, 'prod' deptname from dual union all
      4  select 40, 'ops' from dual
      5  /
    Tabel is aangemaakt.
    SQL> create procedure my_merge
      2  is
      3  begin
      4    merge into rtest2 r2
      5    using (select deptno, deptname from rtest1) r1
      6       on (r2.deptno = r1.deptno)
      7     when matched then
      8          update set deptname = r1.deptname
      9     when not matched then
    10          insert (deptno,deptname) values (r1.deptno,r1.deptname)
    11    ;
    12  end;
    13  /
    Procedure is aangemaakt.
    SQL> exec my_merge
    PL/SQL-procedure is geslaagd.
    SQL> select * from rtest2 order by deptno
      2  /
                                    DEPTNO DEPT
                                        10 EWP
                                        20 PWD
                                        30 EPF
                                        40 ops
    4 rijen zijn geselecteerd.Regards,
    Rob.

  • Redirect pages using plsql procedures

    Hi,
    I've a page with some portlets ( Forms and reports). One of the reports calls a procedure using a URL reference based on a DAD Gateway.
    This is working fine.
    The problem is: i want that the procedure call back the page that contains the report, doing Reload to the page, because the procedure change the information present in the page.
    Is any way, that i could use to, after execute the procedure, call another page, using plsql Code.
    Here is the scenario
    -> my page has two portlets
    -> One is a Form - do inserts in a table
    -> the other is a report. This report contains the objects that has been inserted by the form.
    -> The report also contains a link for every element of the report
    --> This link is a procedure that deletes the element from table.
    -> That works fine.
    -> Now i want to do the refresh of the page, but using plsql code in a procedure in a Database.
    i could write a new page
    Ex
    Htp.print('Delete successful');
    and Portal show me another page where i can read 'Delete successful.
    I want to get back to the same page without any action of the user?
    How could i do it. This must be done using PLSQL code.
    Here is the url of the page
    http://ptdos96.pt.oracle.com/servlet/page?_pageid=80&_dad=portal30&_schema=PORTAL30&_mode=3
    Thanks for your cooperation
    Pedro Ribeiro

    You can use
    owa_util.redirect_url( <url> );
    to redirect to any url.

  • Help Required :Excel Upload Into Oracle Table Using PLSQL Procedure/Package

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    I also Tried to Use This
    But How can i Use SQLLDR Command In Stored Procedure.
    Well IN SQL*PlUS it is successfull but in Stored Procedure /Package ,PL/SQL does not recognise the OS commands.
    So now my Question How can I recognise the SQLLDR Commnad in Stored Procedure.

  • Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
    If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
    If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
    Justin

  • Plsql procedure containing select statement to fill page items

    I would like to fill items :P200_A and :P200_B and so on
    with the result of a SELECT which depends on the different values of many select lists.
    E.G. :P200_list_alpha with the list of values
    STATIC:less than 10;less,equal than 10;equal,above 10;above,indifferent;indiff
    :P200_list_beta with the list of values
    STATIC:active;active,passiv;passiv,excluded;excluded
    How do I write the select statement ? I think it has to be executed in an anonymous PLSQL Procedure (after submit).
    What is a convenient way to write the select statement ?
    I could imagine to use lots of IF , ELSIF, ELSE statements and in each branch (here 12 ) the whole/complet SELECT statement is written.
    How to solve this problem in an elegant way ?
    In my opinion the CASE statement could be helpful, but how to use it in the WHERE clause with this nested conditions ?

    I think I got it:
    SELECT col1, col2, col3, ...
    INTO :P200_A , :P200_B , ....
    FROM mytable_1, mytable_2
    WHERE mytable_1.col1 = mytable_2.col1
    AND (
    CASE
    WHEN :P200_LIST_ALPHA = 'less' AND NVL(TO_COL_WITH_ALPHA, 0) < 10 THEN 1
    WHEN :P200_LIST_ALPHA = 'equal' AND NVL(TO_COL_WITH_ALPHA, 0) = 10 THEN 1
    WHEN :P200_LIST_ALPHA = 'above' AND NVL(TO_COL_WITH_ALPHA, 0) > 10 THEN 1
    WHEN :P200_LIST_ALPHA = 'indiff' THEN 1
    ELSE 0
    END = 1 )
    AND
    ( CASE
    WHEN :P200_LIST_BETA = 'active' AND TO_COL_WITH_BETA IN ( 'a', 'A', 'akt', 'AKT' ) THEN 1
    WHEN :P200_LIST_BETA = 'passive' AND TO_COL_WITH_BETA IN ( 'p', 'P' ) THEN 1
    WHEN :P200_LIST_BETA = 'excluded' AND TO_COL_WITH_BETA = 'X' THEN 1
    ELSE 0
    END = 1 )
    ;Edited by: wucis on Oct 24, 2011 4:09 PM

  • Using PLSQL procedure with parameter in AQ

    hi,
    we need to run a PLSQL procedure(asynchronously) with in parameters using oracle AQ.
    can someone give me simple example/hint?
    Many thanks

    Since you mention dbms_job, can you use dbms_scheduler since you can pass in parms? You can schedule the job to run "now" and while it may have a slight delay starting up due to available processes for the scheduler and system load, it will run as soon as it can.
    What are you trying to accomplish in your environment? I'm not following why you want to allow a user to schedule any DB procedure. A certain set yes, all, no.
    You could create a generic AQ structure where it is passed some information regarding what procedure needs to run and what/where the parms are. This driver procedure would then be responsible for calling a random procedure via dynamic SQL. I've never tried passing parms to a procedure via dynamic SQL but recall reading you could do it. I wouldn't recommend this approach unless you have no better options though.

  • How to use dynamically column_name and column_name value in plsql procedure

    hi,
    how to use dynamically column_name and column_name value in plsql procedure.
    for example, i have one table with column col1.i want write plsql code with dynamically execute the insert one schema to another schema.
    by
    siva

    DECLARE
    CURSOR C
    IS
    SELECT cc_cd
    FROM TEMP1 WHERE s_flg ='A' AND b_num IN('826114');--,'709537','715484');
    CURSOR D
    IS
    SELECT * FROM cONSTRAINTS_test ORDER BY SRL_NUM;
    STMT VARCHAR2(4000);
    p_target_schema VARCHAR2(30):='schema1';
    p_source_schema VARCHAR2(30):='schema2';
    BEGIN
    FOR REC IN C
    LOOP
    FOR REC1 IN D
    LOOP
    STMT := 'INSERT INTO '||p_target_schema||''||'.'||''||REC1.CHILD_TABLE||' SELECT * FROM '||p_source_schema||''||'.'||''||REC1.CHILD_TABLE||' where '||REC1.COLUMN_NAME||'='||REC.cntrct_cd||'';
    Dbms_Output.Put_Line('THE VALUE STMT:'||STMT);
    END LOOP;
    END LOOP;
    END;
    cc_cd='434se22442ss3433';
    cc_t_ms is parent table-----------------------pk_cc_cd is primary key
    cc_cd is column name
    CONSTRAINTS_test table
    CHILD_TABLE NOT NULL VARCHAR2(30)
    CONSTRAINT_NAME NOT NULL VARCHAR2(30)
    COLUMN_NAME NOT NULL VARCHAR2(400)
    R_CONSTRAINT_NAME VARCHAR2(30)
    CONSTRAINT_TYPE VARCHAR2(1)
    PARENT_TABLE NOT NULL VARCHAR2(30)
    SRL_NUM NUMBER(4)
    CHILD_TABLE     CONSTRAINT_NAME     COLUMN_NAME     R_CONSTRAINT_NAME     CONSTRAINT_TYPE     PARENT_TABLE     SRL_NUM
    a aaa cc_CD     pk_cc_CD     R     cc_t_MS     1
    bb     bbb      Cc_CD     PK_CC_CD     R     cc_t_MS     2
    bb_v     bb_vsr     S_NUM     PK_S_NUM      R     bb_v      3
    cC_HS_MS     cc_hs_CD     cc_CD     PK_CC_CD     R     cc_t_MS     4
    cC_HS_LNK cc_HIS_LNK_CD     H_CD     PK_HS_HCD     R     cC_hs_ms 5
    cC_D_EMP     cc_d_EMP     Cc_CD     PK_CC_CD      R     cc_t_MS     6
    i want insert schema1 to schema2 with run time of column_name and column value.the column_name and values should dynamically generated
    with refential integrity.is it possible?
    can any please quick solution.its urgent
    by
    siva

  • When I start firefox browser an erroe message appear that contain this text "the procedure entry point_except_handler4_common could not be located in the dynamic link library msvcrt.dll" I am using windows XP

    when I start firefox browser an erroe message appear that contain this text "the procedure entry point_except_handler4_common could not be located in the dynamic link library msvcrt.dll" I am using windows XP in English
    == This happened ==
    Every time Firefox opened
    == start mozila firefox

    This issue can be caused by a problem with the file c:\windows\system32\dwmapi.dll
    The file dwmapi.dll is a Vista file and should not be present in Windows XP.
    See also [tiki-view_forum_thread.php?forumId=1&comments_parentId=417674]

  • Running Plsql procedure using shell script

    Dear All,
    Dear All,
    I have to generate reports weekly by using a plsql procedure.
    For Exapmle : My Proc name is Weekly_report(i number).
    Here i is the argument for which i need to run the proc 7 times as follows
    exec weekly_report(1)
    exec weekly_report(2)
    exec weekly_report(3)
    exec weekly_report(4)
    exec weekly_report(5)
    exec weekly_report(6)
    exec weekly_report(7)
    I need to run them parallely at a time so that time taken will be less. Is there any way doing this through shell script.
    Thanks in asdvance.

    damorgan wrote:
    I can't think of anything in the Oracle world left in the dustbin of history I miss less than shell scripts.
    Why work in another language, why work in a tool that is non-portable, why have to deal with SysAdmins when dbms_scheduler is many times more capable?
    Definitely DBMS_SCHEDULER. Shell scripting is obsolete with perhaps only a few very rare exceptions.+1: shell scripts suck.
    DBMS_Scheduler allows you to setup the report procedures as programs that are executed at the same time in a single job (as steps in a scheduler chain). you can also setup email confirmation based on them successfully completing. All good stuff and not difficult to do.

  • Help with truncating a table using plsql procedure in different schema

    I have a plsql procedure in schema A that truncates a table that is given in as parameter.
    create or replace procedure truncate_table(schema, table_name)
    EXECUTE IMMEDIATE 'TRUNCATE TABLE '||schema||'.'||table_name;
    end;
    The above procedure has public execute grant.
    I need to truncate a table in schema B. I have a plsql procedure in schema B that calls the truncate_table procedure and passes in the schema B table name.
    Since the table is in schema B, should the delete grant on the table be given to user A or user B to truncate the table in schema B?
    Thanks in advance.

    Procedure created in schema A
    create or replace
    procedure truncate_table(l_schema varchar2, table_name varchar2) authid current_user
    as
    begin
    EXECUTE IMMEDIATE 'TRUNCATE TABLE '||l_schema||'.'||table_name;
    end;from schema B
    grant delete on table1 to Schema_A
    from schema A
    exec truncate_table('Schema_B','Table1');
    Hope this helps.
    Alvinder

  • How to use of variable sized parameter in plsql procedures

    Hello,
    We will write a procedure which has a fixed parameter and which has other variable count parameters. How can we implement with this in pl - sql., which structure(varray, nested table, collections vb) should we use?
    For example:
    I want to use it like below:
    create procedure TestProc
    paramId Number,
    paramOthers
    IS
    -- variable declarations
    vOthers
    begin
    select paramOthers
    into vOthers from table1;
    -- some other sqls
    dbms_output.putline( vOthers[0] || ' some message ' || vOthers[1] || ' some other message' || vOthers[3] || ' anoother message... ' || vOthers[n] );
    end TestProc;
    /

    I also tried but I am taking errors:
    My simple code is:
    ( I have not to try to use values in array as column names in select statement yet )
    /* Formatted on 2008/09/26 10:35 (Formatter Plus v4.8.8) */
    CREATE OR REPLACE PACKAGE TEST_PACKAGE
    AS
    TYPE VARCHAR2_ARR IS TABLE OF VARCHAR2 (50);
    FUNCTION TEST_FUNC (S IN NUMBER, MY_PARAM_ARR IN VARCHAR2_ARR)
    RETURN VARCHAR2;
    END TEST_PACKAGE;
    CREATE OR REPLACE PACKAGE BODY TEST_PACKAGE
    IS
    FUNCTION TEST_FUNC (S IN NUMBER, MY_PARAM_ARR IN VARCHAR2_ARR)
    RETURN VARCHAR2
    IS
    V_COUNT NUMBER;
    VSTRING VARCHAR2 (10000);
    BEGIN
    VSTRING := '';
    V_COUNT := MY_PARAM_ARR.COUNT;
    FOR TEMP_VAR IN 1 .. V_COUNT
    LOOP
    VSTRING := VSTRING || MY_PARAM_ARR (TEMP_VAR);
    END LOOP;
    RETURN VSTRING;
    END TEST_FUNC;
    END TEST_PACKAGE;
    DECLARE
    MY_ARR TEST_PACKAGE.VARCHAR2_ARR;
    RETVAL VARCHAR2 (20000);
    BEGIN
    MY_ARR (1) := 'Test1';
    MY_ARR (2) := 'Test2';
    MY_ARR (3) := 'Test3';
    MY_ARR (4) := 'Test4';
    SELECT TEST_PACKAGE.TEST_FUNC (3, MY_ARR)
    INTO RETVAL
    FROM DUAL;
    DBMS_OUTPUT.PUT_LINE (RETVAL);
    END;
    I take the error message below:
    ORA-06550: line 10, column 38:
    PLS-00642: local collection types not allowed in SQL statements
    ORA-06550: line 10, column 24:
    PLS-00306: wrong number or types of arguments in call to 'TEST_FUNC'
    ORA-06550: line 10, column 11:
    PL/SQL: ORA-00904: "TEST_PACKAGE"."TEST_FUNC": invalid identifier
    ORA-06550: line 10, column 4:
    PL/SQL: SQL Statement ignored

  • Calling PLSQL Procedure with CLOB input parameter from JDBC

    Hi..
    I've got a PLSQL procedure with a CLOB object as input parameter:
    function saveProject (xmldoc CLOB) RETURN varchar IS
    I want to call that procedure from my JDBC Application as...
    String data = "..."
    CallableStatement proc = conn.prepareCall
              ("begin ? := saveProject (?); end;");
    neither
    proc.setCharacterStream(2, new StringReader(data, data.length());
    nor
    proc.setString(2, data);
    will work.
    The Application throws java.sql.Exception: ... PLS-00306 wrong
    number or types of arguments in call 'SAVEPROJECT'
    How can I use set setClob method?
    The Problem is: with Oracles CLOB implementation I can't create
    an Instance, and from the CallableStatement a can't get a
    Locator for a CLOB-Object.
    This CLOB stuff makes me really nuts!
    please somebody help me.. thanks
    Alex

    Hi All,
    You can not make it like that.
    You can not make clob as input parameter.
    Do you want an easy way?
    This is the easy way.
    sample:
    function myFunction(S varchar2(40))
    return integer as
    begin
    insert into TableAAA values(S)
    --TableAAA only contains 1 column of clob type
    end;
    This will work the problem with this is the parameter is in
    varchar2 right? so there will be limited length for it.
    You can do this to call that function:
    nyFunction('My String that will be input into clob field');
    There's another slight difficult way, I understand that you have
    installed Oracle client/server in your system, try to look at
    jdbc folder and try to find demo.zip in that folder, you can
    find several ways of doing thing with jdbc.
    Have a nice day,
    Evan

  • Passing multidimensional array to plsql procedure

    hi ,
    is there any way to pass a two dimensional array of different data types to plsql procedure as a parameter?
    In other words, is it possible to pass a set or records or a datatable as a single parameter to plsql procedure?
    Because I am using a dataset selected with odp.net in my client and I am modifying the data in different datatables contained in the dataset.At the moment, the modified datatables are saved by seperating each column as a sepearate array and passing each column array as a seperate parameter to a stored procedure. But, I would like to change it in a way to pass each datatable as a single parameter to the stored procedure.
    I would appreciate any solution/suggestion/hint in regard to this problem
    thanks in advance,
    Prabhakar.

    If your Java array is of a base type (String, int, etc.) and you are using the OCI driver, you can use OracleCallableStatement.setPlSqlTable(). (I'm doing this from memory so the method name may be slightly different.)
    The method takes a Java array and converts it to a PL/SQL table before passing it to the stored procedure.

Maybe you are looking for