Dbms_session.set_identifier inside procedure

Hi
How can I to use dbms_session.set_identifier inside procedure ?
thank you

Perhaps I'm just being dense, but what is the question, exactly?
Do you know, in general, how to call procedure A from procedure B? Or are you asking how to do that?
If you do know, in general, how to call one procedure from another, are you asking what parameters DBMS_SESSION.SET_IDENTIFIER takes? If so, it takes a VARCHAR2, but it seems like you'd know that from whatever documentation you consulted to learn that DBMS_SESSION.SET_IDENTIFIER exists?
Or are you asking something else?
Justin

Similar Messages

  • Using dbms_session.reset_package inside procedure

    How to use the line dbms_session.reset_package in a procedure.
    I used execute immediate 'dbms_session.reset_package' , but it is not executing.
    How to execute it
    Plese help me

    What do you think should happen when you execute that package?
    Or have you yet again ignored even bothering to RFTM the Oracle® Database PL/SQL Packages and Types Reference to see just what this call does?
    Quote:
    This procedure de-instantiates all packages in this session. It frees the package state.
    Memory used for caching the execution state is associated with all PL/SQL functions, procedures, and packages that were run in a session.
    For packages, this collection of memory holds the current values of package variables and controls the cache of cursors opened by the respective PL/SQL programs. A call to RESET_PACKAGE frees the memory associated with each of the previously run PL/SQL programs from the session, and, consequently, clears the current values of any package globals and closes any cached cursors.
    If you expect PGA to decrease, it will not. Dynamic memory allocation at o/s kernel does not work in such a simplistic way. Memory malloc'ed by an application (like an Oracle dedicated or shared server process) may only be actually freed by the kernel when the process terminates.
    Billy

  • Dynamic Sql  no execute inside procedure

    Hi
    There are a new table, I give permission for select, update, inser and delete, when I executed query select work fine, but when This query is executed inside procedure with dynamic sql return error: ORA-01031 Insufficient Prvileges
    I try to test out procedure and work fine , see below
    declare
      CCURSOR SYS_REFCURSOR;
      RCURSOR TRITON.TTDSLS992901%ROWTYPE;
      V_SQL  VARCHAR2(2000);
    begin
       V_SQL :='SELECT * FROM TRITON.TTDSLS992'|| '901' || CHR(10);
       V_SQL := V_SQL || ' WHERE  T$CONO$O = 410705'|| CHR(10);
       V_SQL := V_SQL || ' AND    T$PONO$O = 10'|| CHR(10);
       V_SQL := V_SQL || ' AND    T$COND$O = 0'|| CHR(10);
       V_SQL := V_SQL ||'AND    T$ETPA$O = 1 '|| CHR(10);
       V_SQL := V_SQL || ' AND    ROWNUM   = 1'|| CHR(10);
       V_SQL := V_SQL || ' ORDER BY T$CONO$O, T$PONO$O, T$COND$O DESC';
    OPEN CCURSOR FOR V_SQL;
      FETCH CCURSOR INTO RCURSOR;
      IF CCURSOR%FOUND THEN
         NULL;
      ELSE
         NULL;  
      END IF;
      CLOSE CCURSOR;   
    end;the Code 901 is not constant, change when Company change
    Why return error permission inside procedure ?

    Hardcode the value to '901' & check TRITON.TTDSLS992901 has execute permission to schema where you want to call this
    TRITON.TTDSLS992'|| '901' ~Lokanath

  • CAN USE COPY COMMAND INSIDE PROCEDURE BODY

    Hi all
    can we use COPY command inside procedure body like this
    CREATE OR REPLACE procedure USER2.PRO1
    Begin
    execute immediate'copy from hr/hr@ERP to USER21/PASS@DB1 append user2.per_images using select * from hr.per_images';
    commit;
    end;
    YOU ADVICE PLEASE

    My advice is to check the manual.
    SQL*Plus COPY command
    http://download.oracle.com/docs/cd/B28359_01/server.111/b31189/ch12016.htm#i2675035
    SQL manual index
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/index.htm
    PL/SQL manual index
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/index.htm
    CTRL-F on the last two for COPY and it appears not.

  • Out Varaible declaration inside Procedure

    I am having a question taht is ,Inside Stored Procedure what is the difference in seting the OUT Parameter inside Procedure as shown below :
    create or replace PROCEDURE clearing_details(p_file_id in varchar2,_country_code OUT VARCHAR2_)
    IS
    CURSOR PD1 IS
    SELECT COUNTRY_CODE FROM LINK_STATUS WHERE country_code = 'japan';
    BEGIN
    OPEN PD1;
    LOOP
    FETCH PD1 INTO country_code;
    DBMS_OUTPUT.PUT_LINE(country_code);
    EXIT WHEN PD1%NOTFOUND;
    END LOOP;
    CLOSE PD1;
    END ;
    *2nd Approach :*
    Here we use the OUT Variable inside the Declaration section
    create or replace PROCEDURE clearing_details(p_file_id in varchar2)
    IS
    countrycode VARCHAR2(40);_
    CURSOR PD1 IS
    SELECT COUNTRY_CODE FROM LINK_STATUS WHERE country_code = 'pak';
    BEGIN
    OPEN PD1;
    LOOP
    FETCH PD1 INTO country_code;
    DBMS_OUTPUT.PUT_LINE(country_code);
    EXIT WHEN PD1%NOTFOUND;
    END LOOP;
    CLOSE PD1;
    END ;

    Hi,
    An OUT parameter is passed back to the calling routine.
    Use OUT parameters in procedure clearing_details if whoever calls clearing_details needs to do some additional work based on the results of clearing_details (that is, if the calling program needs to see how clearing_details left country_code).
    If clearing_details itself is doing all the work, then there's no need for an OUT parameter.

  • Display results from dynamic query created and executed inside procedure

    Hi;
    I have created this code:
    CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, VAR3 IN VARCHAR2) AS
    -- Do something
    -- That ends up with a variable holding a query.... (just an example)
    MainQuery :='select sysdate from dual';
    end RunDynamicQuery;
    How can I run this procedure and see the result on the dymanic query generated inside it?
    BEGIN
    compare_tables_content('VAR1','VAR2','VAR3');
    END;
    Expected Output for this given example:
    20-05-2009 11:04:44 ( the result of the dymanic query inside the procedure variable MainQuery :='select sysdate from dual';)
    I tested with 'execute immediate':
    CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, filter IN VARCHAR2) AS
    -- Do something
    -- That ends up with a variable holding a query.... (just an example)
    MainQuery :='select sysdate from dual';
    execute immediate (MainQuery );
    end RunDynamicQuery;
    BEGIN
    compare_tables_content('VAR1','VAR2','VAR3');
    END;
    Output:"Statement processed'' (no sysdate displayed ! )
    Please consider that the collums in the query are always dynamic... PIPELINE Table would not work because I would need to define a container, example:
    CREATE OR REPLACE TYPE emp_tabtype AS TABLE OF emp_type;
    FUNCTION RunDynamicQuery (p_cursor IN sys_refcursor)
    RETURN emp_tabtype PIPELINED
    IS
    emp_in emp%ROWTYPE;
    BEGIN
    LOOP
    FETCH p_cursor
    INTO emp_in;
    EXIT WHEN p_cursor%NOTFOUND;
    PIPE ROW (...)

    That would be a nice solution, thanks :)
    ''For now'' I implemented like this:
    My dynamic query now returns a single string ( select col1 || col2 || col3 from bla)
    This way I don't have dynamic collumns issue, and from business side, this ''string'' format works for them.
    This way I can use the pipelines to get the result out...
    OPEN myCursor FOR MainQuery;
    FETCH myCursor
    INTO myRow;
    WHILE (NOT myCursor%notFound) LOOP
    PIPE ROW(myRow);
    FETCH myCursor
    INTO myRow;
    END LOOP;
    CLOSE myCursor;

  • How to compile packge inside procedure which uses this package

    ORACLE 10g, 11g
    CREATE OR REPLACE PACKAGE PKG_TEST_COMMIT
    PROCEDURE Insert_into_table_T1;
    PROCEDURE Update_table_T1;
    END PKG_TEST_COMMIT;
    CREATE OR REPLACE PROCEDURE PROC_TEST_COMMIT As
    Begin
    PKG_TEST_COMMIT. Insert_into_table_T1; --insert data into table T1
    EXECUTE IMMEDIATE 'DROP table T1';
    EXECUTE IMMEDIATE
    'create table T1 as select ''1'', ''d'', ''s' from DUAL'; -- now package PKG_TEST_COMMIT in uncompiled stage
    -- compile package
    DBMS_DDL.alter_compile('PACKAGE', 'OWNER', 'PKG_TEST_COMMIT');
    PKG_TEST_COMMIT. Update_into_table_T1;
    End PROC_TEST_COMMIT;
    When I try to run PKG_TEST_COMMIT I’Ve got an error: can’t lock the package.
    I tried to create separate procedure for compilation, but result is the same.
    If I finish PROC_TEST_COMMIT before compiling, then compile – OK.
    Is there is a way to compile package inside the procedure?

    I need to automate the process which first call some procedure from the package, then invalidate this package by dropping and recreating the table (I didn't create the code, but I can see thepoint init - this is the farstest way to populate huge table) and then call another proc from the same package (using table just cretated).
    Otherwise I need human attention to this process. If it is imposible I can substitude "drop table and create table" for truncate and insert", but I am afraid it will take too long.

  • Finding long running queries inside procedure

    Hi All,
    Without using trace file or not modifying the existing procedure, is there any way to find out the query which is taking longer time (say out of 20) inside oracle procedure?
    Thanks in Advance,
    Geetha

    Hi,
    if you are on your development or test database the best tool (after the sql trace :)) is DBMS_PROFILER. It's easy to use and shows you how long does it take to execute every line of procedure. It helps to find not only slow SQL but also bottlenecks in pl/sql code.
    Another option could be Active Session History that every 1s creates snapshot of active sessions. You have to open new session, run the procedure and use query like this:
    select *
    from v$sql s
        (select sql_id, max(sample_time) - min(sample_time) as duration
        from v$active_session_history
        where sid = sys_context('userenv', 'sid') --SID of the session that executed the procedure
        ) ash
    where s.sql_id = ash.sql_id
    order by duration desc;

  • Query hangs inside procedure

    Hi All,
    I have a weird problem. I have a merge query which is running from sql prompt but hangs when the same is called from pl/sql procedure?
    Any Idea why it is hanging?
    Here is the merge query which is called inside plsql
    MERGE INTO NANP_CarrierRates c
    USING (SELECT MIN(f.EffectiveDate) MinEffectiveDate, f.newdest
    FROM tt_Nanp_Import_Pendingtab f
    JOIN NANP_CarrierRates c_i ON c_i.carrier_id = v_CarrierID
    AND f.carrier_id = c_i.carrier_id
    AND c_i.Dest_ID = f.newdest
    and c_i.mdl_id = f.mdl_id
    AND f.EffectiveDate >
    c_i.EffectiveDate
    AND (f.EffectiveDate < c_i.ExpiryDate OR
    c_i.ExpiryDate IS NULL)
    GROUP BY f.newdest) j
    ON (j.newdest = c.Dest_ID AND j.MinEffectiveDate > c.EffectiveDate AND (j.MinEffectiveDate <
    c.ExpiryDate OR c.ExpiryDate IS NULL))
    WHEN MATCHED THEN
    UPDATE
    SET c.ExpiryDate = j.MinEffectiveDate
    WHERE c.Carrier_ID = v_CarrierID
    AND (c.Tariff_ID = v_systariffID OR v_systariffID = 0);
    With Regards
    Boobathi P

    please provide explain plan o/p for this
    SELECT MIN(f.EffectiveDate) MinEffectiveDate, f.newdest
    FROM tt_Nanp_Import_Pendingtab f
    JOIN NANP_CarrierRates c_i ON c_i.carrier_id = v_CarrierID
    AND f.carrier_id = c_i.carrier_id
    AND c_i.Dest_ID = f.newdest
    and c_i.mdl_id = f.mdl_id
    AND f.EffectiveDate >
    c_i.EffectiveDate
    AND (f.EffectiveDate < c_i.ExpiryDate OR
    c_i.ExpiryDate IS NULL)
    GROUP BY f.newdest

  • Handling errors inside Procedure

    Hi..
    I have created the following procedure.. and the procedure work out well when there are no duplicates in the table.
    If the duplicate arises the errors messages is also displayed..
    CREATE OR REPLACE PROCEDURE P_MC_IPS (lDate IN
    DATE) IS
    PROJ_INV VARCHAR2(50);
    MAC_IP VARCHAR2(100);
    CURSOR M_IP IS
    SELECT DISTINCT A.TITLE TITLE,B.MACHINE_IP MACHINE_IP FROM JOB_LIST A,TD B WHERE A.JOBNUMBER = B.JOBNO AND B.ACT_DATE = TO_CHAR(ldate,'DD-MON-YYYY');
    BEGIN
    OPEN M_IP;
    LOOP
    FETCH M_IP INTO PROJ_INV,MAC_IP;
    EXIT WHEN M_IP%NOTFOUND;
    INSERT INTO NET_ADDRESS(P_INV,MACHINE_IPS) VALUES(PROJ_INV,MAC_IP);
    COMMIT;
    END LOOP;
    CLOSE M_IP;
    EXCEPTION
    WHEN DUP_VAL_ON_INDEX THEN
    DBMS_OUTPUT.PUT_LINE('DUPLICATE RECORDS EXISTS');
    END P_MC_IPS;
    The Problem here is I need to insert other values except the datas that has duplicate index.
    I need to insert the data except the duplicate record when i run the procedure again.
    I need to use the exception type "UP_VAL_ON_INDEX " to handle the exception. Can anyone help out regd. this
    Kindly help me on this issue.
    Thanks
    gayathri

    Use an inner block to handle the exception.
    CREATE OR REPLACE PROCEDURE p_mc_ips
       (lDate IN DATE)
    IS
    BEGIN
       FOR lrec IN (SELECT DISTINCT a.title title,b.machine_ip machine_ip
                    FROM job_list a,td b
                    WHERE a.jobnumber = b.jobno
                    AND b.act_date = TO_CHAR(ldate,'DD-MON-YYYY'))
       LOOP
          BEGIN
             INSERT INTO net_address(p_inv,machine_ips)
             VALUES(lrec.title, lrec.machine_ip);
          EXCEPTION
             WHEN DUP_VAL_ON_INDEX THEN
                DBMS_OUTPUT.PUT_LINE('DUPLICATE RECORDS EXISTS');
          END;
       END LOOP;
       COMMIT;
    END p_mc_ips;You'll have noticed that I've streamlined your code a bit. We'll save using FORALL and anti-joins for another day ;)
    Cheers, APC

  • Alter User Inside procedure

    Hi to all,
    I have a user named dbo and vijay.
    I have a procedure under dbo named as sp_alteruser
    CREATE OR REPLACE PROCEDURE DBO.SP_ALTERUSER
    P_USER_ID IN VARCHAR2,P_PASSWORD IN VARCHAR2,P_MSG OUT VARCHAR2)
    --Declaration of IN parameters
    IS
    E_PASSWORD EXCEPTION;
    E_INVALIDUSER EXCEPTION;
    PRAGMA EXCEPTION_INIT(E_PASSWORD,-00988);
    PRAGMA EXCEPTION_INIT(E_INVALIDUSER,-01918);
    BEGIN
    DECLARE
    V_COUNT NUMBER;
    V_STATEMENT1 VARCHAR2(200);
    BEGIN
    --To check whether the user has been already exists
    SELECT COUNT(*) INTO V_COUNT
    FROM ALL_USERS
    WHERE USERNAME = P_USER_ID;
    IF V_Count = 0 THEN
    --If the count is 0 means that the user does not exist
    DBMS_OUTPUT.PUT_LINE('User Does Not exist');
    END IF;
    IF V_COUNT>0 THEN
    --If the count is greater than 0 then the Alter statement is executed
    V_STATEMENT1:= 'ALTER USER ' ||P_USER_ID||' IDENTIFIED BY '
    ||P_PASSWORD;
         -- EXECUTE IMMEDIATE 'GRANT ALTER USER TO VIJAY';
    -- EXECUTE IMMEDIATE 'ALTER USER ' ||P_USER_ID||' IDENTIFIED BY ' ||P_PASSWORD;
    --EXECUTE IMMEDIATE v_STATEMENT1;
    P_MSG := 'Password Changed Sucessfully';
    END IF;
    END;
    EXCEPTION
    WHEN E_PASSWORD THEN
    P_MSG := 'Missing or Invalid Password';
    WHEN E_INVALIDUSER THEN
    P_MSG := 'User '||P_USER_id||' Does not exist';
    END;
    I have created a synonym with the same name as sp_alteruser and given the execute privilege to the user vijay...
    This procedure works fine when I run as DBO user, when I am trying from the vijay user it is throwing the error as insufficient privilege.
    I tried to give the alter user privilege explicitly but none gone right, when i gave dba privilege and checked with it works fine..
    Please help me in this regard.
    Thanks
    vijay

    Yes, I got it and apologies. Its not there so the error is correct. I am not sure that which priv is letting the dba role change another user, here is a list of privs for some default roles but none of them is there which depicts clearly the option to change another user.
    A very stupid answer, try giving the alter user with the admin option and see what happens. I don't ahve a db here otherwise I would had done it.
    HTH
    Aman....

  • Can not create a sequence inside procedure

    I have a procedure like this:
    CREATE OR REPLACE PROCEDURE P_reset_Sequences AS
    BEGIN
    execute immediate '
    DROP SEQUENCE ADMIN_AUTORESPONSES_SEQ';
    execute immediate '
    CREATE SEQUENCE ADMIN_AUTORESPONSES_SEQ
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    NOCYCLE
    NOCACHE
    ORDER
    END P_reset_Sequences;
    When I execute this procedure to reset sequence ADMIN_AUTORESPONSES_SEQ, there an erro: insufficient privileges. But owner of this procedure has DBA privilege.
    Pls, help me!

    There are two reasons to reset a sequence in code.
    You could run out of numbers or you think you can use sequences as a gap free counter.
    Running out of numbers is a problem every [3,000,000,000,000,000,000,000,000,000 years|Re: What kind of transaction in procedure? or thereabouts.
    Looking at the sequence definition with NOCACHE , ORDER and an INCREMENT by 1 it appears the OP mistakenly believes you can use a sequence as a gap free counter ignoring rollbacks, exceptions and shutdowns amongst other things, when all those setting have really done is [make the sequence as slow as possible|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6393918681776].

  • How to get execution time for a view inside procedure ?

    Hi,
    I want execution time for all the views in my database. I tried "execute immediate" but it does not seem to work.
    It is not waiting to complete the execution of view to go to next step.
    If I am executing the same statement in sqlplus, it is displaying correct time.
    Here is my code:
    Begin
    output_file := UTL_FILE.FOpen ('RECORDING',v_FileName, 'W', 32767);
    Open viewcur;
    Loop
    Fetch viewcur into v_view_name;
         Exit when viewcur%notfound;
         SELECT to_char(systimestamp,'DD-MON-YYYY HH24:MI:SS.FF') into v_start_time from dual;
         v_stmt := 'Select * from ' ||v_view_name ;
         Execute Immediate v_stmt;
    SELECT to_char(systimestamp,'DD-MON-YYYY HH24:MI:SS.FF') into v_end_time from dual;
    v_record_str := v_start_time||','||v_view_name||','||v_end_time;
         UTL_FILE.PUT_LINE(output_file, v_record_str);
    End Loop;
    Close viewcur;
    utl_file.fClose(output_file);
    End ;
    Oracle version: 11.1.0.6.0

    Hi,
    Running with a user with dba privileges:
    DECLARE
        CURSOR viewcur IS
            SELECT table_name
            FROM   dictionary d
            WHERE  d.table_name LIKE 'ALL_A%';
        output_file UTL_FILE.file_type;
        v_FileName  VARCHAR2(30) := 'TEST_VIEW_TIME.TXT';
        v_view_name dictionary.table_name%TYPE;
        v_start_time varchar2(30);
        v_end_time varchar2(30);
        v_record_str varchar2(200);
        v_stmt varchar2(200);
    BEGIN
        output_file := UTL_FILE.FOpen('EXT_FILES', v_FileName, 'W', 32767);
        OPEN viewcur;
        LOOP
            FETCH viewcur
                INTO v_view_name;
            EXIT WHEN viewcur%NOTFOUND;
            SELECT TO_CHAR(systimestamp, 'DD-MON-YYYY HH24:MI:SS.FF')
            INTO   v_start_time
            FROM   dual;
            v_stmt := 'Select * from ' || v_view_name;
            EXECUTE IMMEDIATE v_stmt;
            SELECT TO_CHAR(systimestamp, 'DD-MON-YYYY HH24:MI:SS.FF')
            INTO   v_end_time
            FROM   dual;
            v_record_str := v_start_time || ',' || v_view_name || ',' || v_end_time;
            UTL_FILE.PUT_LINE(output_file, v_record_str);
        END LOOP;
        CLOSE viewcur;
        utl_file.fClose(output_file);
    END;
    /TEST_VIEW_TIME.TXT:
    02-JUL-2009 11:48:47.953000,ALL_ARGUMENTS,02-JUL-2009 11:48:47.953000
    02-JUL-2009 11:48:47.953000,ALL_ALL_TABLES,02-JUL-2009 11:48:47.953000
    02-JUL-2009 11:48:47.953000,ALL_ASSOCIATIONS,02-JUL-2009 11:48:47.953000
    02-JUL-2009 11:48:47.953000,ALL_AUDIT_POLICIES,02-JUL-2009 11:48:47.999000
    02-JUL-2009 11:48:47.999000,ALL_AUDIT_POLICY_COLUMNS,02-JUL-2009 11:48:48.093000
    02-JUL-2009 11:48:48.093000,ALL_AWS,02-JUL-2009 11:48:48.187000
    02-JUL-2009 11:48:48.187000,ALL_AW_PS,02-JUL-2009 11:48:48.187000
    02-JUL-2009 11:48:48.187000,ALL_APPLY,02-JUL-2009 11:48:48.343000
    02-JUL-2009 11:48:48.343000,ALL_APPLY_PARAMETERS,02-JUL-2009 11:48:48.421000
    02-JUL-2009 11:48:48.421000,ALL_APPLY_KEY_COLUMNS,02-JUL-2009 11:48:48.437000
    02-JUL-2009 11:48:48.437000,ALL_APPLY_CONFLICT_COLUMNS,02-JUL-2009 11:48:48.781000
    02-JUL-2009 11:48:48.781000,ALL_APPLY_TABLE_COLUMNS,02-JUL-2009 11:48:48.828000
    02-JUL-2009 11:48:48.828000,ALL_APPLY_DML_HANDLERS,02-JUL-2009 11:48:48.890000
    02-JUL-2009 11:48:48.890000,ALL_APPLY_PROGRESS,02-JUL-2009 11:48:48.968000
    02-JUL-2009 11:48:48.968000,ALL_APPLY_ERROR,02-JUL-2009 11:48:49.015000
    02-JUL-2009 11:48:49.015000,ALL_APPLY_ENQUEUE,02-JUL-2009 11:48:49.234000
    02-JUL-2009 11:48:49.234000,ALL_APPLY_EXECUTE,02-JUL-2009 11:48:49.281000
    02-JUL-2009 11:48:49.281000,ALL_AW_PROP,02-JUL-2009 11:48:49.531000
    02-JUL-2009 11:48:49.546000,ALL_AW_OBJ,02-JUL-2009 11:48:49.578000
    02-JUL-2009 11:48:49.578000,ALL_AW_PROP_NAME,02-JUL-2009 11:48:49.609000
    02-JUL-2009 11:48:49.609000,ALL_AW_AC,02-JUL-2009 11:48:49.624000
    02-JUL-2009 11:48:49.624000,ALL_AW_AC_10G,02-JUL-2009 11:48:49.640000Regards,

  • HELP!! SDO_RELATE inside Oracle procedure - ORA-13207: incorrect use of the

    Hello,
    I need help !
    I have a problem with queries inside procedures/packages.
    When execute sql
    SQL> SELECT LOC_OBJ_ID
    2 FROM VORO_LOC X, LBS_OZ_AREAS OZ
    3 WHERE MDSYS.SDO_RELATE(X.SHAPE, OZ.GEOLOC, 'MASK=ANYINTERACT') = 'TRUE'
    4 AND OZ.OZ_NAME='PTK' AND OZ.OZ_GROUP='GORCZEWSKA';
    LOC_OBJ_ID
    2211379
    i have results - it's OK
    The next sql is same, but with agregation
    SQL> SELECT COUNT(*) ILOSC
    2 FROM VORO_LOC X, LBS_OZ_AREAS OZ
    3 WHERE MDSYS.SDO_RELATE(X.SHAPE, OZ.GEOLOC, 'MASK=ANYINTERACT') = 'TRUE'
    4 AND OZ.OZ_NAME='PTK' AND OZ.OZ_GROUP='GORCZEWSKA';
    ILOSC
    1
    it's OK
    But when i want use this SQL inside proedurees in store result in variable i have problem
    SQL> declare
    2 V_NUMBER_NEI_LOC number;
    3 begin
    4 SELECT COUNT(*) ILOSC
    5 INTO V_NUMBER_NEI_LOC
    6 FROM VORO_LOC X, LBS_OZ_AREAS OZ
    7 WHERE MDSYS.SDO_RELATE(X.SHAPE, OZ.GEOLOC, 'MASK=ANYINTERACT') = 'TRUE'
    8 AND OZ.OZ_NAME='PTK' AND OZ.OZ_GROUP='GORCZEWSKA';
    9 end;
    10 /
    declare
    ORA-13207: incorrect use of the [SDO_RELATE] operator
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_9I", line 259
    ORA-06512: at line 4
    ORA-06512: at line 4
    Please help!

    This might be some issue with SQL in PL/SQL. We will check into this.
    In the meantime, can you try the dynamic SQL to execute that
    sdo_relate query to see if it works?
    Here is the example with dynamic SQL:
    declare
    V_NUMBER_NEI_LOC number;
    begin
    EXECUTE IMMEDIATE
    ' SELECT COUNT(*) ILOSC ' ||
    ' FROM VORO_LOC X, LBS_OZ_AREAS OZ ' ||
    ' WHERE MDSYS.SDO_RELATE(X.SHAPE, OZ.GEOLOC, ' ||
    ' ''MASK=ANYINTERACT'') = ''TRUE'' ' ||
    ' AND OZ.OZ_NAME=''PTK'' AND OZ.OZ_GROUP=''GORCZEWSKA'' '
    INTO V_NUMBER_NEI_LOC;
    end;
    /

  • Calling Oracle Stored Procedure from Weblogic.

    Hi All,
    I am using Oracle 11g R2 and weblogic 10.3.5.0
    Do you know if it is possible to call a stored procedure from Weblogic.
    Basically, what I would like to do is to call the following procedure : EXEC DBMS_SESSION.SET_IDENTIFIER('provider_a') when my application connects to my database, "provider_a" being the user used to connect to the oracle schema.
    Thanks.

    Up !
    Thanks.

Maybe you are looking for