Call a procedure in a function to create an Index

Hi,
i want to doing a text search and have to create some index
to doing that. I have to choose between create two index according to
what a search i want to doing.
The function, which call the sql-statement to search the text is:
CREATE OR REPLACE FUNCTION SEARCHTEXT(textToSearch IN VARCHAR2)
RETURN utilities.resultset_ft PIPELINED AS
BEGIN
BEGIN
INDEXTEST;
END;
DBMS_OUTPUT.PUT_LINE('get the data');
-- search the Text in the database Documents
FOR i in
(SELECT extract(Document, '/*/*/*/*/location[1]/uri/text()').getStringVal() as location, score(1) as score_nbr
FROM Mydocuments
WHERE contains(Document, textTosearch, 1) > 0
ORDER BY score_nbr)
LOOP
PIPE ROW(i);
END LOOP;
RETURN;
END ;
This function call the procedure "INDEXTEST", which create the index.
CREATE OR REPLACE PROCEDURE INDEXTEST
AS
BEGIN
EXECUTE IMMEDIATE 'CREATE INDEX FTS_INDEX ON Mydocuments (DOCUMENT)' || ' ' ||
'INDEXTYPE IS CTXSYS.CONTEXT' || ' ' ||
'PARAMETERS (''' || 'stoplist Doc_stoplist' || ' ' ||
'section group CTXSYS.PATH_SECTION_GROUP'')';
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(sqlerrm);
END INDEXTEST;
I call the statement:
select *
from TABLE(searchtext('%Let%'))
and i get this error:
Error starting at line 1 in command:
select *
from TABLE(searchtext('%Let%'))
Error report:
SQL Error: ORA-14552: DDL-, Commit- oder Rollback-Vorgang kann innerhalb einer Abfrage oder DML nicht durchgeführt werden
ORA-06512: in "INDEXTEST", Zeile 5
ORA-06512: in "SEARCHTEXT", Zeile 15
14552. 00000 - "cannot perform a DDL, commit or rollback inside a query or DML "
Cause:    DDL operations like creation tables, views etc. and transaction<br /><br />control statements such as commit/rollback cannot be performed<br /><br />inside a query or a DML statement.<br /><br />Action: Ensure that the offending operation is not performed or
use autonomous transactions to perform the operation within
the query/DML operation.
<p>
Can someone help me?
</p>
Thanks for help

So, in answer to your question, how to do this....
Create the necessary indexes before you issue the query to do the search.
Yes, that means you need to have some intermediate steps to do it, but you should be able to control that from your application level.
e.g.
1. User enters search criteria
2. Application processes criteria and creates necessary indexes
3. Application queries the results
4. Application drops the indexes.
Or, alternatively, it may be an idea to have a look at your overall design and solve the issue why you are actually having to try and create indexes on the fly. If the database structure was correct in the first place then you shouldn't have to create any more indexes than the permanent ones you will have already determined.

Similar Messages

  • Calling a Procedure inside a Function

    How to call procedure within the function. please help

    I called the procedure as u said but it is firing.. please help me out.. here is the code.
    This code is to generate the SEquence ids.
    *********** Procedure ***************
    create or replace procedure ExecImmd
    is
    Begin
         EXECUTE IMMEDIATE 'DROP SEQUENCE emplseqid';
         EXECUTE IMMEDIATE 'CREATE SEQUENCE emplseqid START WITH 1001 INCREMENT BY 1';
    END;
    CREATE OR REPLACE FUNCTION GenCustId RETURN VARCHAR2
    IS
    VEMPID VARCHAR2(6);
    ISEQID NUMBER(5);
    P1 VARCHAR2(10);
    P2 VARCHAR2(10);
    BIND2 VARCHAR2(10);
    BEGIN
         SELECT MAX(SUBSTR(EMPID,1,2)) INTO P1 FROM EMPL;     
         SELECT EMPLSEQID.NEXTVAL INTO ISEQID FROM DUAL;
         IF ASCII(SUBSTR(P1,2,1)) < ASCII('Z') THEN
              IF ISEQID <= 9999 THEN
              bind2 := SUBSTR(P1,1,2) || ISEQID;
              ELSE
              /* here i am calling a procedure.
              ExecImmd();
              SELECT EMPLSEQID.NEXTVAL INTO ISEQID FROM DUAL;
              bind2 := SUBSTR(P1,1,1) || CHR(ASCII(SUBSTR(P1,2,1))+1) || ISEQID;
              END IF;
         ELSE
              if p1 is null then
                   bind2 := 'AA' || ISEQID;          
              else
                   IF ISEQID <= 9999 THEN
                   bind2 := SUBSTR(P1,1,2) || ISEQID;
                   Else
                   bind2 := CHR(ASCII(SUBSTR(P1,1,1))+1) || 'A' || ISEQID;          
                   End If;
              End If;
         END IF;
         return bind2;
         END;

  • Calling packaged procedure from a function

    Hi all,
    I am using Oracle database 10.2.0
    I have a packaged procedure , there are two IN parameters(Varchar, Date) and an OUT parameter(REF CURSOR). The out parameter sends a result set from a query(multiple records of a table). I was asked to create a function which can use this procedure and returns the same resultset. Can u please suggest how to proceed?
    Thanks & Regards,
    Naveen.

    Is it something like this you're after:
    SQL> create or replace function test_f (p_In1 in number, p_In2 in varchar2) return sys_refcursor as
      2    r sys_refcursor;
      3    begin
      4      open r for 'select ' || to_char(p_In1) || ',''' || p_In2 || ''' from dual';
      5      return  r;
      6  end test_f;
      7  /
    Function created.
    SQL> declare
      2    r sys_refcursor;
      3   
      4    l_no number;
      5    l_Greet varchar2(30);
      6  begin
      7    r := test_f(1, 'Hello');
      8   
      9    fetch r into l_no, l_Greet;
    10    if (r%found) then
    11      dbms_output.put_line(l_No || ' ' || l_Greet);
    12    end if;
    13   
    14    close r;
    15   
    16    exception
    17      when others then
    18        dbms_output.put_line('Err ' || sqlerrm);
    19        if (r%isopen) then
    20          close r;
    21        end if;
    22 
    23  end;
    24  /
    1 Hello
    PL/SQL procedure successfully completed.P;
    Edited by: bluefrog on Mar 4, 2010 3:16 PM

  • Funtion calling a procedure (getting errors)

    HI,
    I am calling a procedure inside a function(see code below).
    Please see my second post for the code:
    Message was edited by:
    SeshuGiri

    Ok here's a working example, though it doesn't use your data:
    set echo on
    drop table data1
    drop table data1 succeeded.
    create table data1 (id number,
                        sel number,
                        col1 varchar2(15),
                        col2 varchar2(15),
                        col3 varchar2(15))
    create table succeeded.
    insert into data1
    select 1, 1, 'one-1','two-1','three-1' from dual union all
    select 1, 1, 'one-2','two-2','three-2' from dual union all
    select 1, 1, 'one-3','two-3','three-3' from dual union all
    select 2, 2, 'one-4','two-4','three-4' from dual union all
    select 2, 2, 'one-5','two-5','three-5' from dual union all
    select 3, 1, 'one-6','two-6','three-6' from dual
    6 rows inserted
    drop type temp_data_tt
    drop type temp_data_tt succeeded.
    create or replace type temp_data as object (
      id number,
      col1 varchar2(15),
      col2 varchar2(15),
      col3 varchar2(15));
    type temp_data Compiled.
    create type temp_data_tt as table of temp_data;
    type temp_data_tt Compiled.
    create or replace procedure get_recs(criteria number, recs out sys_refcursor) is
    begin
      open recs for select id, col1, col2, col3 from data1 where id=criteria;
    end;
    procedure get_recs(criteria Compiled.
    create or replace function get_data(criteria number) return temp_data_tt pipelined is
      l_id number;
      col1 varchar2(15);
      col2 varchar2(15);
      col3 varchar2(15);
      rs sys_refcursor;
    begin
      for drv in (select distinct id from data1 where sel=criteria) loop
        get_recs(drv.id, rs);
        loop
          fetch rs into l_id, col1, col2, col3;
          exit when rs%notfound;
          pipe row(temp_data(l_id, col1,col2,col3));
        end loop;
        close rs;
      end loop;
      return;
    end;
    function get_data(criteria Compiled.
    select * from table(get_data(1))
    ID                     COL1            COL2            COL3           
    1                      one-1           two-1           three-1        
    1                      one-2           two-2           three-2        
    1                      one-3           two-3           three-3        
    3                      one-6           two-6           three-6        
    4 rows selected
    select * from table(get_data(2))
    ID                     COL1            COL2            COL3           
    2                      one-4           two-4           three-4        
    2                      one-5           two-5           three-5        
    2 rows selected
    select * from data1
    ID                     SEL                    COL1            COL2            COL3           
    1                      1                      one-1           two-1           three-1        
    1                      1                      one-2           two-2           three-2        
    1                      1                      one-3           two-3           three-3        
    2                      2                      one-4           two-4           three-4        
    2                      2                      one-5           two-5           three-5        
    3                      1                      one-6           two-6           three-6        
    6 rows selected

  • Calling Stored procedure from Forms 6i

    Dear all,
    I have a stored procedure having INand INOUT parameters. I need to call it from Forms 6i triggers. Will you please tell me the syntax for calling stored procedure and stored function from Forms 6i and report 6i.
    Saibaldas
    [email protected]

    Just the same as for a local procedure, the only restrictions concern package public variables which are not visible from client side PL/SQL, and you probly want to keep the interfaces simple as client side PL/SQL (e.g. the Forms and Reports engines) don't support the same range of datatypes that the database does.

  • How to call a procedure in place of a SQL

    Hi
    Can any one tell me how to call a procedure in place of a SQL from Bi publisher
    Thanks
    Ranga
    Edited by: user13274784 on Jul 22, 2010 9:47 AM

    One way would be to use pipelined table functions. Call the procedure within a function and return data in the form of a table.
    Search the forum.
    Check this out: http://winrichman.blogspot.com/search/label/pipelined
    http://bipublisher.blogspot.com/2007/09/plsql-taking-it-to-next-level.html
    BI publisher to use Stored Procedure
    Edited by: BIPuser on Jul 22, 2010 10:22 AM

  • Unable to call a procedure from another procedure

    Hi there,
    I have created two procedures under my user login. Both of them have the same parameters.
    I was trying to call the other procedure from one procedure and am getting error message.
    Both the procedures are saved in different files. I am using LINUX command editor.
    Precedure1:
    CREATE PROCEDURE remove_emp (emp_no number) as
    BEGIN
    delete from sailors s where s.s_no = remove_emp.emp_no;
    END;
    Procedure2:
    CREATE PROCEDURE u_table (del_emp number) as
    BEGIN
    exec remove_emp(del_emp);
    END;
    /While am calling, this is what I am getting
    SQL> exec u_table(1003);
    BEGIN u_table(1003); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00905: object RAJIV.U_TABLE is invalid
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignoredPlease help me with this.
    Thanks
    Rajiv
    Message was edited by:
    RajivTx

    First thing..
    PLS-00905: object RAJIV.U_TABLE is invalidMeans..the procedure is not valid...meaning not compiled properly...because...u were using "exec remove_emp(del_emp);".... reason being is exec is valid in Sql*Plus... and u cant use it in a procedure ..with the same syntax ( dont ask me why..) unless u use dynamic sql.. u can directly call the procedure like...
    CREATE PROCEDURE u_table (del_emp number) as
    BEGIN
    remove_emp(del_emp);
    END;
    delete from sailors s where s.s_no = remove_emp.emp_no;Secondly ... (Just a suggestion).... aliases are better used when u have multiple tables and complex queries..or may be sometimes the table name is too long and confusing... avoid them when not neccessary

  • Problem in creating text index

    While creating index on XMLType column
    i am getting this error
    ERROR at line 1:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-20000: Oracle Text error:
    DRG-50857: oracle error in driddl.policycreate
    ORA-01400: cannot insert NULL into ("CTXSYS"."DR$INDEX"."IDX_TEXT_NAME")
    ORA-06512: at "CTXSYS.DRUE", line 157
    ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 186
    Can anybody help me out to figure whats the problem
    regards
    - Shweta.

    Hi Shweta,
    Can you tell me the type of index you are creating? Give the query you are using to create the index.
    We have written a sample called 'Survey Sample Application' in which we created CTXXPATH index on a XMLType column.
    You can download the sample from
    http://otn.oracle.com/sample_code/tech/xml/survey/content.html
    Document on the index used is present at
    http://otn.oracle.com/sample_code/tech/xml/survey/docs/AboutOracleXMLDB.html
    I hope this helps you in solving the problem.
    Regards,
    Anupama Majety

  • Error while using DB Adapter in BPEL[Calling a procedure or function]

    Hi
    I am getting Error while executing the BPEL Process.
    1) I created a BPEL Process which uses a DB Adapter. I am using call a procedure or function. My Procedure is shown below. It takes a string a s input parameter and executes that string. I have used an assign activity to assign the input string.
    Procedure
    create or replace
    PROCEDURE SP_QUERY(s_string in varchar2)
    AS
    l_sql_stmt varchar2(1000);
    BEGIN
    l_sql_stmt := s_string;
    -- dbms_output.put_line( l_sql_stmt );
    EXECute immediate l_sql_stmt;
    commit;
    dbms_output.put_line('Executed' );
    -- if SQLCODE = 0 then
    --retCodeString := 'OK';
    --end if;
    END;
    I gave input string as "select * from tab", I have also tried a insert statement to a table in which its present in this database. But i am getting the following error.
    <3 Jun, 2013 9:42:25 AM IST> <Error> <oracle.webservices.service> <OWS-04115>
    Whats the Issue? Is the issue with the procedure or the BPEL process? Please help me out. I am stuck in this

    Hi,
    According to your message you have selected your procedure, but looks like the procedure is not having any reply or response parameter with it.
    Have you executed the procedure separately from SQL editor and see whether you are able to get the response or not ?
    If you get response, then how many columns are you getting ?
    Check the column names are matching with the schema file generated by adapter and see whether those column names are available as elements in .xsd file.
    Example provided below..
    In the below link, check the section "9.7 Stored Procedure and Function Support"
    http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_db.htm#CHDFBBCD
    Thanks,
    Vijay

  • Function call in procedure within Package Body

    I am a novice in PL/SQL so that I can't find out where the problem is. I am testing a function call in procedure within a Package Body.
    But the PL/SQL Complier doesn't compile the package body but I don't know what I do wrong. Plz let me know how to call a function in procedure within a Package Body?
    Here are the Packaget test programs..
    CREATE OR REPLACE PACKAGE manage_students
    IS
    PROCEDURE find_sname;
    PROCEDURE find_test;
    PROCEDURE find_test_called;
    FUNCTION GET_LASTMT
    RETURN SEQUENCE_TEST.SEQ_NO%TYPE;
    END manage_students;
    CREATE OR REPLACE PACKAGE BODY manage_students AS
    v_max_nbr SEQUENCE_TEST.SEQ_NO%TYPE;
    PROCEDURE find_sname
    IS
    BEGIN
    BEGIN
    SELECT MAX(SEQ_NO)
    INTO v_max_nbr
    from SEQUENCE_TEST;
    DBMS_OUTPUT.PUT_LINE('MAX NUMBER is : '||v_max_nbr);
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    RETURN;
    END;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    END find_sname;
    PROCEDURE find_test
    IS
    BEGIN
    BEGIN
    DBMS_OUTPUT.PUT_LINE('MAX NUMBER Called from another procedure : '||v_max_nbr);
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    RETURN;
    END;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    END find_test;
    FUNCTION GET_LASTMT
    RETURN SEQUENCE_TEST.SEQ_NO%TYPE
    IS
    v_max_nbr SEQUENCE_TEST.SEQ_NO%TYPE;
    BEGIN
    SELECT MAX(SEQ_NO)
    INTO v_max_nbr
    from SEQUENCE_TEST;
    RETURN v_max_nbr;
    EXCEPTION
    WHEN OTHERS
    THEN
    DECLARE
    v_sqlerrm VARCHAR2(250) :=
    SUBSTR(SQLERRM,1,250);
    BEGIN
    RAISE_APPLICATION_ERROR(-20003,
    'Error in instructor_id: '||v_sqlerrm);
    END;
    END GET_LASTMT;
    PROCEDURE find_test_called
    IS
    BEGIN
    BEGIN
    V_max := Manage_students.GET_LASTMT;
    DBMS_OUTPUT.PUT_LINE('MAX_NUMBER :'|| V_max);
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    RETURN NULL;
    END;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    END find_test_called;
    END manage_students;
    DECLARE
    v_max SEQUENCE_TEST.SEQ_NO%TYPE;
    BEGIN
    manage_students.find_sname;
    DBMS_OUTPUT.PUT_LINE ('Student ID: Execute.');
    manage_students.find_test;
    manage_students.find_test_called;
    END;
    -----------------------------------------------------------------------------------------------

    Hi,
    Welcome to the forum!
    You'll find that there are a lot of people willing to help you.
    Are you willing to help them? Whenever you have a problem, post enough for people to re-create the problem themselves. That includes CREATE TABLE and INSERT statements for all the tables you use.
    Error messages are very helpful. Post the complete error message you're getting, including line number. (It looks like your EXCEPTION sections aren't doing much, except hiding the real errors. That's a bad programming practice, but probably not causing your present problem - just a future one.)
    Never post unformatted code. Indent the code to show the extent of each procedure, and the blocks within each one.
    When posting formatted text on this site, type these 6 characters:
    \(all small letters, inside curly brackets) before and after each section of formatted test, to preserve the spacing.
    For example, the procedure find_test_called would be a lot easier to read like this:PROCEDURE find_test_called
    IS
    BEGIN
         BEGIN
              V_max := Manage_students.GET_LASTMT;
              DBMS_OUTPUT.PUT_LINE ('MAX_NUMBER :' || V_max);
         EXCEPTION
              WHEN OTHERS
              THEN
                   DBMS_OUTPUT.PUT_LINE ('Error in finding student_id: ');
                   RETURN      NULL;
         END;
         COMMIT;
    EXCEPTION
         WHEN OTHERS
         THEN
              DBMS_OUTPUT.PUT_LINE ('Error in finding student_id: ');
    END find_test_called;
    It's much easier to tell from the code above that you're trying to return NULL from a procedure.  Only functions can return anything (counting NULL); procedures can have RETURN statements, but that single word"RETURN;" is the entire statement.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to call plsql procedure or function and getting back the string?

    Hi Everyone,
    i am using Jdev 11.1.1.5.0.
    i have a requirement to call plsql procedure or function from my backing bean java file and get back the returned value from the procedure or function.
    what piece of simple code i need to write in my backing bean?
    please suggest.
    Thanks.

    As always you write the method to call he pl/sql in the application module, expose this method to the client (so you see it in the datacontroll) then create a operation binding to the method and call this operation from the bean. The result you get by operation.getResult();
    You should never call pl/sql from the bean directly!
    The doc shows how to call the procedure from an application module: http://docs.oracle.com/cd/E21764_01/web.1111/b31974/bcadvgen.htm#sm0297
    Timo

  • Calling SQL Stored procedure from PLSQL function

    Hi,
    I have created a simple function to return a value that is pulled back from SQL server.
    FUNCTION
    FUNCTION CALC_PASS_FAIL
    i_lidded_sn IN TMP_CHIP_ATTR.LIDDED_SN%TYPE
    RETURN NUMBER
    IS
    tmp_result NUMBER;
    BEGIN
    [email protected](i_lidded_sn,'OadmBarActive',tmp_result);
    RETURN tmp_result;
    END CALC_PASS_FAIL;
    OUTPUT
    --When executed as a procedure, i get the required output:
    DECLARE
    x INT;
    BEGIN
    x:=EQDAS_MISC.CALC_PASS_FAIL('OADM004548');
    dbms_output.put_line(x);
    END;
    0 <------ expected output
    PL/SQL procedure successfully completed.
    When executed as a simple function call, i don't get any output:
    SELECT CALC_PASS_FAIL ('OADM004505') FROM dual;
    Any input will be greately appretiated.
    Thanks,
    Shashi
    PS: I am using the DB Link setup usign DG4MSQL

    just wondering it works as procedure as the function misses double quotes:
    dbo.GetChipPareto
    should be
    "dbo"."GetChipPareto"
    Message was edited by:
    kgronau
    Tested a small example using a function like:
    create or replace function test(
    v_ut1 in varchar2)
    RETURN varchar2
    IS
    v_ut2 varchar2(255);
    BEGIN
    "dbo".OTG_TEST3@dg4msql( v_ut1, v_ut2);
    RETURN v_ut2;
    END test;
    The function calls a SQL Server procedure OTG_TEST3 just returning the passed string and it guarantees data integrity.
    Result using a stored procedure:
    SQL> DECLARE
    2 ret integer;
    3 v_ut1 varchar2(255);
    4 v_ut2 varchar2(255);
    5 BEGIN
    6 v_ut1 :='Hello World';
    7 v_ut2 :='';
    8 "dbo".OTG_TEST3@dg4msql( v_ut1, v_ut2);
    9 dbms_output.put_line('Input value: ' ||v_ut1||' - Output value: '
    ||v_ut2);
    10 END;
    11
    12 /
    Input value: Hello World - Output value: Hello World
    And calling now the function:
    select test('Hello') from dual;
    returns Hello

  • Calling a Procedure and Function over a db link

    I am experiencing some errors with the following and would greatly appreciate the advice of some experts here.
    My use-case is to insert some records into a table via a database link. The records to be inserted will be queried from an identical table in the local data dictionary. Everything works, but occasionally I will get a unique constraint violation if I try to insert a duplicate record so I wrote a simple function to check for the scenario. My issue is that I can run my procedure using the db link and I can run my function using the db link, but I can't use them both together without getting errors.
    My test case just uses the standard emp table:
    create or replace procedure test_insert(p_instance varchar2)
    IS
    l_sql varchar2(4000);
    begin
        l_sql := 'insert into EMP@'||p_instance||' (EMPNO, ENAME, JOB, MGR, SAL, DEPTNO) (Select EMPNO, ENAME, JOB, MGR, SAL, DEPTNO from EMP)';
    execute immediate l_sql;
    END;
    BEGIN
    test_insert('myLink');
    END;
    This works fine and the insert occurs without any issues.
    If I run the same procedure a second time I get:
    00001. 00000 -  "unique constraint (%s.%s) violated" which is what I expect since EMPNO has a unique constraint. So far so good.
    Now I create a function to test whether the record exists:
    create or replace function record_exists(p_empno IN NUMBER, p_instance IN varchar2) return number
    IS
    l_sql varchar2(4000);
    l_count number;
    BEGIN
    l_sql := 'select count(*) from EMP@'||p_instance||' where empno = '||p_empno;
    execute immediate l_sql into l_count;
    IF
    l_count > 0
    THEN return 1;
    ELSE
    return 0;
    END IF;
    END;
    I test this as follows:
    select record_exists(8020, 'myLink') from dual;
    RECORD_EXISTS(8020,'myLink')
                                              1
    That works ok, so now I will add that function to my procedure:
    create or replace procedure test_insert(p_instance varchar2)
    IS
    l_sql varchar2(4000);
    begin
        l_sql := 'insert into EMP@'||p_instance||' (EMPNO, ENAME, JOB, MGR, SAL, DEPTNO) (Select EMPNO, ENAME, JOB, MGR, SAL, DEPTNO from EMP WHERE record_exists( EMPNO, '''||p_instance||''') = 0)';
    execute immediate l_sql;
    END;
    I test this as follows:
    BEGIN
    test_insert('myLink');
    END;
    Result is:
    Error report:
    ORA-02069: global_names parameter must be set to TRUE for this operation
    ORA-06512: at "FUSION.TEST_INSERT", line 6
    ORA-06512: at line 2
    02069. 00000 -  "global_names parameter must be set to TRUE for this operation"
    *Cause:    A remote mapping of the statement is required but cannot be achieved
               because global_names should be set to TRUE for it to be achieved
    *Action:   Issue alter session set global_names = true if possible
    I don't know why I am getting this. The function works, the procedure works, but when I combine them I get an error. If I set the global names parameter to true and then rerun this I get:
    02085. 00000 -  "database link %s connects to %s"
    *Cause:    a database link connected to a database with a different name.
               The connection is rejected.
    *Action:   create a database link with the same name as the database it
               connects to, or set global_names=false.
    Any advice is much appreciated. I don't understand why I can run the procedure and the function each separately over the db link but they don't work together.
    thank you,
    john

    The proper procedure depends on what how you define failure and what it should mean - error back to caller, log and continue, just continue. Constraints are created to ensure invalid data does not get into a table. Generally they provide the most efficient mechanism for checking for invalid data, and return useful exceptions which the caller can handle. You are also doubling the work load of the uniqueness check by adding in your own check.
    In general I'd say use Exceptions, they are your friend

  • Calling a procedure/function in forms personalization

    Hi,
    Can any one please help me in calling a procedure/function from the forms personalization? The requirement is to create an attachment when ever a new order line is created in R12. So for this, I created a procedure which calls attachment creation API. And in the forms personalization, I am doing the following.
    Trigger Event: WHEN-VALIDATE-RECORD
    Trigger Object: LINE
    Condition: :LINE.INVENTORY_ITEM_ID is not null
    Action Type: Builtin
    Builtin Type: Execute a Procedure
    Argument: =xx_test_attachment_new(:LINE.LINE_ID,20,'OE_ORDER_LINES',1,'test123')
    This procedure works individually if I call it from TOAD.
    Help is really appreciated?
    Thanks,
    Sri.

    A question for the Forms ?
    Nicolas.

  • Creating parameters dynamically and calling a procedure but strange issue

    Okay I have the following program that is calling a procedure(data_compare_utility)[pasted below] and data_compare_table_setup table definition and data(isert scripts) are pasted below :
    DECLARE
    --FP_OLD_TABLE VARCHAR2(200);
    --FP_NEW_TABLE VARCHAR2(200);
    --FP_DATA_COMPARE_ID NUMBER(10) := 1;
    --FP_RESTRICTION_CLAUSE VARCHAR2(500) := 'WHERE W_INSERT_DT >= TO_DATE(''01/JAN/2012'',''DD/MON/YYYY'') OR W_UPDATE_DT >= TO_DATE(''01/JAN/2012'',''DD/MON/YYYY'')';
    --FP_RESTRICTION_CLAUSE_4_INS VARCHAR2(500) := 'WHERE W_INSERT_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''') OR W_UPDATE_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''')';
    cursor c_data_compare_table_setup
    is
    select table_name, old_schema_name, new_schema_name, data_compare_id, restriction_clause, restriction_clause_ins from DATA_COMPARE_TABLE_SETUP;
    r_of_data_compare_table_setup c_data_compare_table_setup%rowtype;
    Lv_args_4_data_compare_utility varchar2(500);
    BEGIN
    --FP_OLD_TABLE := 'BIAPPS_11.RAHUL_EMPLOYEES';
    --FP_NEW_TABLE := 'RAHULKALRA.RAHUL_EMPLOYEES';
    open c_data_compare_table_setup;
    Loop
    fetch c_data_compare_table_setup into r_of_data_compare_table_setup;
    exit when c_data_compare_table_setup%NOTFOUND;
    --exec RAHULKALRA.P_COMPARE_DATA_UTILITY
    Lv_args_4_data_compare_utility := ''''||r_of_data_compare_table_setup.OLD_SCHEMA_NAME||'.'||r_of_data_compare_table_setup.TABLE_NAME||''','''||r_of_data_compare_table_setup.NEW_SCHEMA_NAME||'.'||r_of_data_compare_table_setup.TABLE_NAME||''','||r_of_data_compare_table_setup.DATA_COMPARE_ID||','''||r_of_data_compare_table_setup.RESTRICTION_CLAUSE||''','''||r_of_data_compare_table_setup.RESTRICTION_CLAUSE_INS||'''';
    P_COMPARE_DATA_UTILITY(Lv_args_4_data_compare_utility);
    commit;
    End Loop;
    dbms_output.put_line('rahul');
    dbms_output.put_line(''''||r_of_data_compare_table_setup.OLD_SCHEMA_NAME||'.'||r_of_data_compare_table_setup.TABLE_NAME||''','''||r_of_data_compare_table_setup.NEW_SCHEMA_NAME||'.'||r_of_data_compare_table_setup.TABLE_NAME||''','||r_of_data_compare_table_setup.DATA_COMPARE_ID||','''||r_of_data_compare_table_setup.RESTRICTION_CLAUSE||''','''||r_of_data_compare_table_setup.RESTRICTION_CLAUSE_INS||'''');
    --P_COMPARE_DATA_UTILITY('BIAPPS_11.RAHUL_EMPLOYEES','RAHULKALRA.RAHUL_EMPLOYEES',1,'WHERE W_INSERT_DT >= TO_DATE(''01/JAN/2012'',''DD/MON/YYYY'') OR W_UPDATE_DT >= TO_DATE(''01/JAN/2012'',''DD/MON/YYYY'')','WHERE W_INSERT_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''') OR W_UPDATE_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''')');
    --P_COMPARE_DATA_UTILITY('BIAPPS_11.RAHUL_EMPLOYEES','RAHULKALRA.RAHUL_EMPLOYEES',1,'WHERE W_INSERT_DT >= TO_DATE(''01/JAN/2012'',''DD/MON/YYYY'') OR W_UPDATE_DT >= TO_DATE(''01/JAN/2012'',''DD/MON/YYYY'')','WHERE W_INSERT_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''') OR W_UPDATE_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''')');
    close c_data_compare_table_setup;
    END;
    Procedure : compare_data_utility:
    CREATE OR REPLACE procedure RAHULKALRA.p_compare_data_utility(fp1_old_table in varchar2, fp2_new_table in varchar2, fp3_data_compare_id in number, fp4_restriction_clause in varchar2, fp5_recrtiction_clause_4_ins in varchar2)
    as
    Lv_common_column_names varchar2(2000);
    Lv_primary_column_name varchar2(50);
    Lv_insert_data_compare_log varchar2(2000);
    --Lv_counter number(10);
    Lv_row_id_for_data_compare_log number(10);
    Lv_old_table_record_count number(10);
    Lv_old_table_rec_cnt_query varchar2(200);
    Lv_new_table_record_count number(10);
    Lv_new_table_rec_cnt_query varchar2(200);
    begin
    select max(row_id) into Lv_row_id_for_data_compare_log from data_compare_log;
    Lv_old_table_rec_cnt_query := 'Select count(*) from '||fp1_old_table||' '||fp4_restriction_clause;
    dbms_output.put_line(Lv_old_table_rec_cnt_query);
    execute immediate Lv_old_table_rec_cnt_query into Lv_old_table_record_count;
    Lv_new_table_rec_cnt_query := 'Select count(*) from '||fp2_new_table||' '||fp4_restriction_clause;
    execute immediate Lv_new_table_rec_cnt_query into Lv_new_table_record_count;
    dbms_output.put_line(fp5_recrtiction_clause_4_ins);
    if (Lv_row_id_for_data_compare_log is null)
    then
    Lv_row_id_for_data_compare_log := 1;
    else
    Lv_row_id_for_data_compare_log := Lv_row_id_for_data_compare_log + 1;
    end if;
    Lv_insert_data_compare_log := 'insert into data_compare_log values('||Lv_row_id_for_data_compare_log||',''comparing data for '||fp1_old_table||' and '||fp2_new_table||''','''||fp1_old_table||''','''||fp2_new_table||''',TO_DATE('''||to_char(sysdate,'DD-MON-YY HH24:MI:SS')||''',''DD-MON-YY HH24:MI:SS''),'||fp3_data_compare_id||','||Lv_old_table_record_count||','''||'Select count(*) from '||fp1_old_table||' '||fp5_recrtiction_clause_4_ins||''','||Lv_new_table_record_count||','''||'Select count(*) from '||fp2_new_table||' '||fp5_recrtiction_clause_4_ins||''')';
    dbms_output.put_line(Lv_insert_data_compare_log);
    execute immediate Lv_insert_data_compare_log;
    commit;
    -- tested : dbms_output.put_line(Lv_insert_data_compare_log);
    Lv_common_column_names := f_fetch_common_column_names(fp1_old_table,fp2_new_table,fp3_data_compare_id);
    -- tested : dbms_output.put_line(Lv_common_column_names);
    Lv_primary_column_name := f_extract_pkey_column_names(fp1_old_table, fp2_new_table);
    dbms_output.put_line(Lv_primary_column_name);
    p_compare_data(fp1_old_table,fp2_new_table,Lv_common_column_names,Lv_primary_column_name,fp4_restriction_clause,fp3_data_compare_id);
    end;
    CREATE TABLE RAHULKALRA.DATA_COMPARE_TABLE_SETUP
    TABLE_ID NUMBER(10),
    TABLE_NAME VARCHAR2(100 BYTE),
    OLD_SCHEMA_NAME VARCHAR2(100 BYTE),
    NEW_SCHEMA_NAME VARCHAR2(100 BYTE),
    RESTRICTION_CLAUSE VARCHAR2(500 BYTE),
    RESTRICTION_CLAUSE_INS VARCHAR2(500 BYTE),
    DATA_COMPARE_ID NUMBER(10)
    Insert into DATA_COMPARE_TABLE_SETUP
    (TABLE_NAME, OLD_SCHEMA_NAME, NEW_SCHEMA_NAME, DATA_COMPARE_ID, RESTRICTION_CLAUSE, RESTRICTION_CLAUSE_INS)
    Values
    ('W_CHNL_TYPE_D', 'BIAPPS_11', 'RAHULKALRA', 1, 'WHERE W_INSERT_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''') OR W_UPDATE_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''')', 'WHERE W_INSERT_DT >= TO_DATE(''''''''01/JAN/2012'''''''',''''''''DD/MON/YYYY'''''''') OR W_UPDATE_DT >= TO_DATE(''''''''01/JAN/2012'''''''',''''''''DD/MON/YYYY'''''''')');
    Insert into DATA_COMPARE_TABLE_SETUP
    (TABLE_NAME, OLD_SCHEMA_NAME, NEW_SCHEMA_NAME, DATA_COMPARE_ID, RESTRICTION_CLAUSE, RESTRICTION_CLAUSE_INS)
    Values
    ('RAHUL_EMPLOYEES', 'BIAPPS_11', 'RAHULKALRA', 1, 'WHERE W_INSERT_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''') OR W_UPDATE_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''')', 'WHERE W_INSERT_DT >= TO_DATE(''''''''01/JAN/2012'''''''',''''''''DD/MON/YYYY'''''''') OR W_UPDATE_DT >= TO_DATE(''''''''01/JAN/2012'''''''',''''''''DD/MON/YYYY'''''''')');
    I am facing the following error for this command when I call P_compre_data_utility procedure from my anonymous block:
    P_COMPARE_DATA_UTILITY(Lv_args_4_data_compare_utility); -- the error is pasted below
    if I do a dbms_output.put_line(Lv_args_4_data_compare_utility) and then copy paste its output and call P_COMPARE_DATA_UTILITY, the procedure is getting executed, here is that command :
    P_COMPARE_DATA_UTILITY('BIAPPS_11.RAHUL_EMPLOYEES','RAHULKALRA.RAHUL_EMPLOYEES',1,'WHERE W_INSERT_DT >= TO_DATE(''01/JAN/2012'',''DD/MON/YYYY'') OR W_UPDATE_DT >= TO_DATE(''01/JAN/2012'',''DD/MON/YYYY'')','WHERE W_INSERT_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''') OR W_UPDATE_DT >= TO_DATE(''''01/JAN/2012'''',''''DD/MON/YYYY'''')');
    Error:
    ORA-06550: line 27, column 7:
    PLS-00306: wrong number or types of arguments in call to 'P_COMPARE_DATA_UTILITY'
    ORA-06550: line 27, column 7:
    PL/SQL: Statement ignored
    Question : just want to know whats wrong with : P_COMPARE_DATA_UTILITY(Lv_args_4_data_compare_utility);
    please help me.
    Regards
    Rahul

    Mac_Freak_Rahul wrote:
    Hi All,
    I am really sorry, my head is so aching since I am not a regular plsql coder and to save my life I need to write this code for data comparison between 2 tables .. further sorry about calling p_data_compare utility stupidly : P_COMPARE_DATA_UTILITY(Lv_args_4_data_compare_utility);
    I am calling it now using :
    execute immediate 'exec P_COMPARE_DATA_UTILITY('||Lv_args_4_data_compare_utility||')';If you are sure the call works then, exec would not work since it is a SQLPLUS command.
    try
    execute immediate 'BEGIN P_COMPARE_DATA_UTILITY(''||Lv_args_4_data_compare_utility||''); END;';
    PS: I can manually give table names to my utility , just need 60 tables to compare but would be great if I can work it out this eay.
    2) I can sound very stupid since my head is aching I am not a regular plsql coder but from now on I would be one, please helpJust for your sake, to Compare 60 tables (Supposing you just want to verify count of records), you are writing an entire procedure; You might have completed this activity by now doing the manual way. By taking this way, you are investing time to generate a correct code (as you just mentioned not being a regular plsql developer) you are stuck with some un-identifiable issues.
    As an alternate way, I would suggest you to export the data, after ordering, into a spreadsheet and then validate. Also, since it looks like you are comparing the data in the same database between schemas, you can also use the SQL Navigators Data Compare utility and there are many more readily available in market.
    I would wish you the best if you still prefer taking the approach.

Maybe you are looking for

  • Can there be more than one initiator in a shared review?

    We use Acrobat X Pro to do shared reviews of pdf documents. At times, the initiator will be out of the office when someone needs to take action on the document and it would make it more convenient if there was more than one person with access. Is it

  • E3000 Media Server not seen by Windows Media Player (v 12.0) on Win 7

    I've enabled the Media Server on my E3000 router.  My PS3 can see the server and play media from it by my PCs can't! I'm using Windows Media Player v 12.0 on Windows 7 and some older version on Windows XP and it's my understanding that the Media Serv

  • Problem in executing BAPI_DOCUMENT_CREATE2 in background

    Hello SAP Gurus, My requirement is to upload documents from application server(AL11) / presentation server (PC) to DMS. For the above requirement I'am using BAPI "BAPI_DOCUMENT_CREATE2". When i execute the program in foreground i have no issues , but

  • How to change colors of designs

    I would love to be able to change colors of designs I make in Printshop. On my PC I could just highlight an object and choose a color and change it. The Mac is supposed to be the great "artistic" machine, yet it can't seem to do half the stuff my PC

  • HTML comments not showing up in snippets in RH9?

    I want to be able to add some HTML comments sometimes when I enter content. For example, let's say I want a pair of HTML comments like so, with a place for text between them. <!-- begin info pulled from the v3 P & P manual --> and <!-- end info pulle