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

Similar Messages

  • 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;

  • 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

  • Query Hangs while Parsing

    In one of our databases, one of the Select query hangs at the parsing stage. The query was working fine few days back. How and what can be traced to see the cause of this hang. Database is in 10.2.0.3 and statistics has been gathered for all the affected tables.

    Thanks for the info. The SEQ# is not changing in the v$session_waits. I have found a workaround for this problem. If I delete the statistics for CS_MEASUREMENT table, the query gets executed in .35 secs! If i collect stats again and runs, it hangs.
    The session trace below.
    TKPROF: Release 10.2.0.3.0 - Production on Fri May 30 11:43:02 2008
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Trace file: css1cldr_ora_10134.trc
    Sort options: default
    count = number of times OCI procedure was executed
    cpu = cpu time in seconds executing
    elapsed = elapsed time in seconds executing
    disk = number of physical reads of buffers from disk
    query = number of buffers gotten for consistent read
    current = number of buffers gotten in current mode (usually for update)
    rows = number of rows processed by the fetch or execute call
    select i.obj#,i.ts#,i.file#,i.block#,i.intcols,i.type#,i.flags,i.property,
    i.pctfree$,i.initrans,i.maxtrans,i.blevel,i.leafcnt,i.distkey,i.lblkkey,
    i.dblkkey,i.clufac,i.cols,i.analyzetime,i.samplesize,i.dataobj#,
    nvl(i.degree,1),nvl(i.instances,1),i.rowcnt,mod(i.pctthres$,256),
    i.indmethod#,i.trunccnt,nvl(c.unicols,0),nvl(c.deferrable#+c.valid#,0),
    nvl(i.spare1,i.intcols),i.spare4,i.spare2,i.spare6,decode(i.pctthres$,null,
    null,mod(trunc(i.pctthres$/256),256)),ist.cachedblk,ist.cachehit,
    ist.logicalread
    from
    ind$ i, ind_stats$ ist, (select enabled, min(cols) unicols,
    min(to_number(bitand(defer,1))) deferrable#,min(to_number(bitand(defer,4)))
    valid# from cdef$ where obj#=:1 and enabled > 1 group by enabled) c where
    i.obj#=c.enabled(+) and i.obj# = ist.obj#(+) and i.bo#=:1 order by i.obj#
    call count cpu elapsed disk query current rows
    Parse 1 0.01 0.00 0 0 0 0
    Execute 3 0.01 0.01 0 0 0 0
    Fetch 10 0.00 0.00 0 33 0 7
    total 14 0.02 0.02 0 33 0 7
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS (recursive depth: 1)
    Rows Row Source Operation
    2 SORT ORDER BY (cr=10 pr=0 pw=0 time=2852 us)
    2 HASH JOIN OUTER (cr=10 pr=0 pw=0 time=2741 us)
    2 NESTED LOOPS OUTER (cr=7 pr=0 pw=0 time=102 us)
    2 TABLE ACCESS CLUSTER IND$ (cr=5 pr=0 pw=0 time=73 us)
    1 INDEX UNIQUE SCAN I_OBJ# (cr=2 pr=0 pw=0 time=29 us)(object id 3)
    0 TABLE ACCESS BY INDEX ROWID IND_STATS$ (cr=2 pr=0 pw=0 time=22 us)
    0 INDEX UNIQUE SCAN I_IND_STATS$_OBJ# (cr=2 pr=0 pw=0 time=18 us)(object id 711)
    2 VIEW (cr=3 pr=0 pw=0 time=361 us)
    2 SORT GROUP BY (cr=3 pr=0 pw=0 time=356 us)
    2 TABLE ACCESS CLUSTER CDEF$ (cr=3 pr=0 pw=0 time=58 us)
    1 INDEX UNIQUE SCAN I_COBJ# (cr=2 pr=0 pw=0 time=25 us)(object id 30)
    select /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#,
    sample_size, minimum, maximum, distcnt, lowval, hival, density, col#,
    spare1, spare2, avgcln
    from
    hist_head$ where obj#=:1 and intcol#=:2
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 50 0.01 0.00 0 0 0 0
    Fetch 50 0.00 0.00 0 150 0 50
    total 101 0.01 0.01 0 150 0 50
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: RULE
    Parsing user id: SYS (recursive depth: 2)
    Rows Row Source Operation
    1 TABLE ACCESS BY INDEX ROWID HIST_HEAD$ (cr=3 pr=0 pw=0 time=81 us)
    1 INDEX RANGE SCAN I_HH_OBJ#_INTCOL# (cr=2 pr=0 pw=0 time=57 us)(object id 257)
    select /*+ rule */ bucket, endpoint, col#, epvalue
    from
    histgrm$ where obj#=:1 and intcol#=:2 and row#=:3 order by bucket
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 60 0.03 0.01 0 0 0 0
    Fetch 60 0.01 0.00 0 206 0 973
    total 121 0.04 0.02 0 206 0 973
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: RULE
    Parsing user id: SYS (recursive depth: 2)
    Rows Row Source Operation
    3 SORT ORDER BY (cr=3 pr=0 pw=0 time=130 us)
    3 TABLE ACCESS CLUSTER HISTGRM$ (cr=3 pr=0 pw=0 time=66 us)
    1 INDEX UNIQUE SCAN I_OBJ#_INTCOL# (cr=2 pr=0 pw=0 time=27 us)(object id 252)
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net message to client 1 0.00 0.00
    SQL*Net message from client 1 10.13 10.13
    select pos#,intcol#,col#,spare1,bo#,spare2
    from
    icol$ where obj#=:1
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 7 0.01 0.00 0 0 0 0
    Fetch 25 0.00 0.00 0 50 0 18
    total 33 0.01 0.00 0 50 0 18
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS (recursive depth: 1)
    Rows Row Source Operation
    2 TABLE ACCESS BY INDEX ROWID ICOL$ (cr=6 pr=0 pw=0 time=36 us)
    2 INDEX RANGE SCAN I_ICOL1 (cr=4 pr=0 pw=0 time=38 us)(object id 40)
    select name,intcol#,segcol#,type#,length,nvl(precision#,0),decode(type#,2,
    nvl(scale,-127/*MAXSB1MINAL*/),178,scale,179,scale,180,scale,181,scale,182,
    scale,183,scale,231,scale,0),null$,fixedstorage,nvl(deflength,0),default$,
    rowid,col#,property, nvl(charsetid,0),nvl(charsetform,0),spare1,spare2,
    nvl(spare3,0)
    from
    col$ where obj#=:1 order by intcol#
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 3 0.00 0.01 0 0 0 0
    Fetch 87 0.00 0.00 0 11 0 84
    total 91 0.00 0.01 0 11 0 84
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS (recursive depth: 1)
    Rows Row Source Operation
    12 SORT ORDER BY (cr=3 pr=0 pw=0 time=157 us)
    12 TABLE ACCESS CLUSTER COL$ (cr=3 pr=0 pw=0 time=79 us)
    1 INDEX UNIQUE SCAN I_OBJ# (cr=2 pr=0 pw=0 time=24 us)(object id 3)
    select col#, grantee#, privilege#,max(mod(nvl(option$,0),2))
    from
    objauth$ where obj#=:1 and col# is not null group by privilege#, col#,
    grantee# order by col#, grantee#
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 3 0.00 0.00 0 0 0 0
    Fetch 3 0.00 0.00 0 6 0 0
    total 7 0.00 0.00 0 6 0 0
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS (recursive depth: 1)
    Rows Row Source Operation
    0 SORT GROUP BY (cr=2 pr=0 pw=0 time=57 us)
    0 TABLE ACCESS BY INDEX ROWID OBJAUTH$ (cr=2 pr=0 pw=0 time=34 us)
    0 INDEX RANGE SCAN I_OBJAUTH1 (cr=2 pr=0 pw=0 time=31 us)(object id 103)
    select grantee#,privilege#,nvl(col#,0),max(mod(nvl(option$,0),2))
    from
    objauth$ where obj#=:1 group by grantee#,privilege#,nvl(col#,0) order by
    grantee#
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 3 0.00 0.00 0 0 0 0
    Fetch 18 0.00 0.00 0 12 0 15
    total 22 0.00 0.00 0 12 0 15
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS (recursive depth: 1)
    Rows Row Source Operation
    5 SORT GROUP BY (cr=4 pr=0 pw=0 time=107 us)
    5 TABLE ACCESS BY INDEX ROWID OBJAUTH$ (cr=4 pr=0 pw=0 time=43 us)
    5 INDEX RANGE SCAN I_OBJAUTH1 (cr=2 pr=0 pw=0 time=16 us)(object id 103)
    select con#,obj#,rcon#,enabled,nvl(defer,0)
    from
    cdef$ where robj#=:1
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 3 0.01 0.00 0 0 0 0
    Fetch 3 0.00 0.00 0 3 0 0
    total 7 0.01 0.00 0 3 0 0
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS (recursive depth: 1)
    Rows Row Source Operation
    0 TABLE ACCESS BY INDEX ROWID CDEF$ (cr=1 pr=0 pw=0 time=22 us)
    0 INDEX RANGE SCAN I_CDEF3 (cr=1 pr=0 pw=0 time=20 us)(object id 52)
    select con#,type#,condlength,intcols,robj#,rcon#,match#,refact,nvl(enabled,0),
    rowid,cols,nvl(defer,0),mtime,nvl(spare1,0)
    from
    cdef$ where obj#=:1
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 3 0.00 0.00 0 0 0 0
    Fetch 34 0.00 0.00 0 42 0 31
    total 38 0.00 0.00 0 42 0 31
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS (recursive depth: 1)
    Rows Row Source Operation
    5 TABLE ACCESS CLUSTER CDEF$ (cr=9 pr=0 pw=0 time=17 us)
    1 INDEX UNIQUE SCAN I_COBJ# (cr=2 pr=0 pw=0 time=10 us)(object id 30)
    select intcol#,nvl(pos#,0),col#,nvl(spare1,0)
    from
    ccol$ where con#=:1
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 31 0.01 0.00 0 0 0 0
    Fetch 70 0.00 0.00 0 140 0 39
    total 102 0.01 0.00 0 140 0 39
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS (recursive depth: 1)
    Rows Row Source Operation
    2 TABLE ACCESS BY INDEX ROWID CCOL$ (cr=6 pr=0 pw=0 time=49 us)
    2 INDEX RANGE SCAN I_CCOL1 (cr=4 pr=0 pw=0 time=45 us)(object id 54)
    select condition
    from
    cdef$ where rowid=:1
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 1 0.00 0.00 0 2 0 1
    total 3 0.00 0.00 0 2 0 1
    Misses in library cache during parse: 0
    Optimizer mode: CHOOSE
    Parsing user id: SYS (recursive depth: 1)
    Rows Row Source Operation
    1 TABLE ACCESS BY USER ROWID CDEF$ (cr=1 pr=0 pw=0 time=18 us)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call count cpu elapsed disk query current rows
    Parse 0 0.00 0.00 0 0 0 0
    Execute 0 0.00 0.00 0 0 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 0 0.00 0.00 0 0 0 0
    Misses in library cache during parse: 0
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net message to client 1 0.00 0.00
    SQL*Net message from client 1 10.13 10.13
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call count cpu elapsed disk query current rows
    Parse 11 0.01 0.01 0 0 0 0
    Execute 167 0.08 0.07 0 0 0 0
    Fetch 361 0.01 0.01 0 655 0 1218
    total 539 0.10 0.10 0 655 0 1218
    Misses in library cache during parse: 10
    Misses in library cache during execute: 10
    0 user SQL statements in session.
    167 internal SQL statements in session.
    167 SQL statements in session.
    Trace file: css1cldr_ora_10134.trc
    Trace file compatibility: 10.01.00
    Sort options: default
    1 session in tracefile.
    0 user SQL statements in trace file.
    167 internal SQL statements in trace file.
    167 SQL statements in trace file.
    11 unique SQL statements in trace file.
    3548 lines in trace file.
    0 elapsed seconds in trace file.

  • How to find all query elements inside a Query

    Hi,
    I would like to find out all query elements inside my query.
    Is there any table which stores all query elements inside my query ?
    Thanks
    Pratyush

    Hi,
    Query elements are stored in this  follwing table:
    SE11
    Table name : RSZELTXREF [Directory of query element references]
    other query related tables :
    Tables used in  Queries
    RSZELTDIR      Directory of the reporting component elements
    RSZELTTXT    Texts of reporting component elements 
    RSZELTXREF  Directory of query element references 
    RSRREPDIR     Directory of all reports (Query GENUNIID) 
    RSZCOMPDIR  Directory of reporting components 
    RSZRANGE    Selection specification for an element 
    RSZSELECT    Selection properties of an element
    RSZELTDIR     Directory of the reporting component elements 
    RSZCOMPIC    Assignment reuseable component <-> InfoCube
    RSZELTPRIO   Priorities with element collisions
    RSZELTPROP  Element properties (settings)
    RSZELTATTR  Attribute selection per dimension element 
    RSZCALC        Definition of a formula element 
    RSZCEL           Query Designer: Directory of Cells
    RSZGLOBV     Global Variables in Reporting
    RSZCHANGES  Change history of reporting components 
    Hope it will helps you.
    Thanks
    Hemav

  • Ora-04044 error on a Select . . . Into query in a procedure in an Form

    Hi,
    I am getting the following error upon the execution of any select . . . into query in my procedure.
    Ora-04044 procedure, function, package or type is not allow here.
    I am using an Oracle 10g database on Linux with a client/server configuration of Forms 6i.
    Here is the code snippet that is erroring:
    procedure validate_area is
    begin
    if :ib.area_id is not null then
    declare
    s_ds_type varchar2(1);
    begin
    select building, ds_id, ds_allow_issue, ds_emp_id, latitude, longitude, map_num, room, loc_descr, n_area_code, ds_type
    into :ib.building, :ib.ds_id, :ib.allow_issue, :ib.rpt_emp_id, :ib.latitude, :ib.longitude, :ib.map_num, :ib.room, :ib.loc_descr, :n_area_code, s_ds_type
    from area, dosi_subj
    where area.area_id = :ib.area_id and area.ds_id = dosi_subj.id;
    ... more code ....
    end;
    end if;
    end validate_area;
    It is on this select . . . into statement that the above error was thrown.
    Any ideas?

    Ernie,
    Please check all the tables and columns involved in that query if there is a function, package or procedure with that same name.
    I tried myself, but everything seems fine. I included an example of an ORA-04044 at the end, however.
    SQL> create table area
      2  as
      3  select 1 area_id, 1 ds_id from dual
      4  /
    Tabel is aangemaakt.
    SQL> create table dosi_subj
      2  as
      3  select 1 id, 1 building, 1 ds_allow_issue, 1 ds_emp_id, 1 latitude, 1 longitude, 1 map_num
      4       , 1 room, 'z' loc_descr, 'A' n_area_code, 'A' ds_type
      5    from dual
      6  /
    Tabel is aangemaakt.
    SQL> select building, ds_id, ds_allow_issue, ds_emp_id, latitude, longitude, map_num, room, loc_descr, n_area_code, ds_type
      2  from area, dosi_subj
      3  where area.area_id = 1 and area.ds_id = dosi_subj.id
      4  /
      BUILDING      DS_ID DS_ALLOW_ISSUE  DS_EMP_ID   LATITUDE  LONGITUDE    MAP_NUM       ROOM L N D
             1          1              1          1          1          1          1          1 z A A
    1 rij is geselecteerd.
    SQL> create procedure validate_area is
      2    l_ib_building    dosi_subj.building%type;
      3    l_ib_ds_id       area.ds_id%type;
      4    l_ib_allow_issue dosi_subj.ds_allow_issue%type;
      5    l_ib_rpt_emp_id  dosi_subj.ds_emp_id%type;
      6    l_ib_latitude    dosi_subj.latitude%type;
      7    l_ib_longitude   dosi_subj.longitude%type;
      8    l_ib_map_num     dosi_subj.map_num%type;
      9    l_ib_room        dosi_subj.room%type;
    10    l_ib_loc_descr   dosi_subj.loc_descr%type;
    11    l_n_area_code    dosi_subj.n_area_code%type;
    12    c_area_id        number := 1;
    13  begin
    14  if 1 is not null then
    15
    16  declare
    17
    18  s_ds_type varchar2(1);
    19
    20  cursor c1 (c_area_id NUMBER) is
    21  select building, ds_id, ds_allow_issue, ds_emp_id, latitude, longitude, map_num, room, loc_descr, n_area_code, ds_type
    22  from area, dosi_subj
    23  where area.area_id = c_area_id and area.ds_id = dosi_subj.id;
    24
    25  begin
    26  dbms_output.put_line('open c1 cursor to retrieve data');
    27  open c1(1); --code errors when opening the cursor
    28
    29  dbms_output.put_line('fetch area data variables');
    30  fetch c1 into l_ib_building, l_ib_ds_id, l_ib_allow_issue, l_ib_rpt_emp_id, l_ib_latitude, l_ib_longitude, l_ib_map_num
    31  , l_ib_room, l_ib_loc_descr, l_n_area_code, s_ds_type;
    32  dbms_output.put_line('area data has been fetched');
    33  end;
    34  end if;
    35
    36  end validate_area;
    37  /
    Procedure is aangemaakt.
    SQL> exec validate_area
    open c1 cursor to retrieve data
    fetch area data variables
    area data has been fetched
    PL/SQL-procedure is geslaagd.
    SQL> drop table area
      2  /
    Tabel is verwijderd.
    SQL> create procedure area is begin null; end;
      2  /
    Procedure is aangemaakt.
    SQL> select building,ds_emp_id
      2    from dosi_subj, area
      3  /
      from dosi_subj, area
    FOUT in regel 2:
    .ORA-04044: procedure, function, package, or type is not allowed hereRegards,
    Rob.

  • Query a stored procedure that exec's a dynamic query. Error Linked server indicates object has no columns

    I have a stored procedure that dynamically creates a pivot query.  The procedure works and returns the correct data.  Now I have a requirement to show this data in reporting system that can only pull from a table or view.  Since you can not
    create a dynamic query in a view I tried to do a select from using openquery. 
    Example 'Select * from OpenQuery([MyServername], 'Exec Instance.Schema.StoredProcedure')
    I get the error back "the linked server indicates the object has no columns".  I assume this is because of the first select statement that is stuffing the variable with column names. 
    CODE FROM PROCEDURE
    Alter PROCEDURE [dbo].[Procedure1]
    AS
    BEGIN
    SET NOCOUNT ON
    Declare @cols nvarchar(2000),
      @Tcols nvarchar(2000),
      @Sql nvarchar (max)
    select @cols = stuff ((
          Select distinct '], ['+ModelName + '  ' + CombustorName
           from CombustorFuel cf
           join Model m on cf.modelid = m.modelid
           join Combustors cb on cf.CombustorID = cb.CombustorID
           where cf.CombustorID > 0
           for XML Path('')
          ),1,2,'')+']'
    Set @Tcols = replace(@Cols, ']', '] int')
    --Print @Tcols   
    --Print @Cols
    Set @Sql = 'Select GasLiquid, FuelType, '+ @Cols +'
    from
     Select GasLiquid, FuelType, ModelName+ ''  '' +CombustorName ModelCombustor, CombFuelStatus+''- ''+CombFuelNote CombFuelStatusNote
      from Frames f
      join Family fa on f.Frameid = fa.frameid
      join Model m on fa.FamilyID = m.FamilyID
      join CombustorFuel cf on m.Modelid = cf.modelid
      Join Combustors c on cf.CombustorId = c.CombustorID
      join FuelTypes ft on cf.FuelTypeID = ft.FuelTypeID
      where cf.CombustorFuelID > 0
        and CombustorName <> ''''
     ) up
    Pivot
     (max(CombFuelStatusNote) for ModelCombustor in ('+ @Cols +')) as pvt
    order by FuelType'
    exec (@Sql)

    Then again, a good reporting tool should be able to do dynamic pivot on its own, because dynamic pivoting is a presentation feature.
    SSRS Supports dynamic columns: Displaying Dynamic Columns in SSRS Report
    SQL Reporting Services with Dynamic Column Reports
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014
    Displaying and reading are two very different things.
    #1) SSRS Needs a fixed field list on the input side to know what what to make available in the designer.
    #2) SSRS cant read "exec (@Sql)" out of a proc, even if there is a fixed number of columns (at
    least it can't use it to auto build the field list from the proc)
    I use dynamic SQL in my report procs on a fairly regular basis and I've found it easiest to simply dump
    the results of my dynamic sql into a temp table at the end of the procs and then select from the temp table.
    Basically, Erland is correct. Stop trying to pivot in the query and let SSRS (or whatever reporting software you're using) handle it with a Martix.
    Jason Long

  • Oracle 9.2.0.6; query hangs if partition doesn't exist

    Hallo all,
    this is the first time I post on this forum.
    I work in a group of PL\SQL developers in Italy. Few day ago we had a problem with a query and like to find out what the problem is.
    We have an Oracle DB version 9.2.0.6 (old I know) in a production environment. Linux OS.
    The query was made to extract data from a partitined table, on a partioned field, in our casa one Year. By mistake we have serced for the wrong year, 2013. There where no data for that year and therefor no partition.
    So, happened that the query hangs and after 24 hours was terminated.
    What we expected indeed was a zero records retirned in, at the most, few minutes, see that the table, in severa partition contains about 16 million records.
    The we tested the same query but in a different enviroment, Oracle 11gr2, same table structure, same partitioning, without partition 2013, and the query completed in less tha 1 minute with zero records in output.
    At this point we thought of a bug, but can't find any reference.
    Has anyone had a similar experience or can give some indication of possible bug report.
    Thanks for any help.

    Hi Rob,
    thank you for your answer.
    Sorry if this is not the best forum. I am not very practical.
    I try to answer to your questions.
    At a first time we thought the query did a full scan on the table. Yes. But even to full scan 16.000.000 records split in no more than 8 partition (at this time) shouldn't take up to 24 hours and never stop running. I think.
    We don't have a DBA role so we do not have full control over what is running. And take too long time to open a ticket and ask the DBA to check.
    What we did is testing the same query in a pre-prod environment, which is an Oracle 11gr2.
    I understand that it is not very usual to have a pre-production environment with a latest version of oracle but this is the way we have to work.
    Anyway, the test in pre-production worked very well. Without 2013 partition the return was very fast and we had zero records as expected.
    Then we found a workaround for production, ora 9. Call it work around maybe is too much ........
    We created the 2013 partition and run the query. The respons was then succesfull in about the same time than in pre-prod. Less than one minute and zero records.
    And this is fine for us.
    What we don't understand is why this different behavior with two different version of DB. Thats why we think it is due to a bug. We only want to find out whether it is this or if there is a different reason.
    Some other response or help would help.
    Thank you.

  • Sql query hangs close to the end

    Hi:
    I am on 10.2.0.3.
    My rather simple query hangs for a few minutes close to the end. It's supposed to return 288 rows and it immediately returns 285, then hangs for 4-5 min, than returns the remaining 3 rows. Kind of similar behavior to using "First_rows" hint - which I'm not using...
    The table has about 100,000 rows.
    Some relevant info is below.
    Any ides appreciated.
    TIA
    PLAN_TABLE_OUTPUT
    Plan hash value: 2481764356
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 30 | 3 (0)| 00:00:01 |
    |* 1 | INDEX RANGE SCAN| PSACOMBO_DATA_TBL | 1 | 30 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - access("SETID"='GLOBL' AND "PROCESS_GROUP"='100ACDTPRJ' AND
    "COMBINATION"='100ACDTPRJ' AND "VALID_CODE"='V')
    optimizer_dynamic_sampling integer 6
    optimizer_features_enable string 10.2.0.3
    optimizer_index_caching integer 25
    optimizer_index_cost_adj integer 75
    optimizer_mode string ALL_ROWS
    optimizer_secure_view_merging boolean TRUE
    unnestsubquery boolean FALSE

    You said the query is supposed to return 288 rows, but from the explain plan, Oracle "see" only 1 row to be returned. Are the stats up-to-date ? What's the actual query ?
    Please, on the forum side, use tags before and after your code to keep it readable (preserve blanks and tabs).
    Nicolas.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Query hangs on Value Help

    Hi,
    We have created a query in which we are using quantity conversion ( defined in RSUOM ) , the target quantity is to be taken from a variable. The quantity conversions is running fine but when we do a value help for the target quantity variable in Portal, the query hangs. We are not facing any such  issue in Bex Analyzer.
    Please share your ideas on what could be the possible reason for this.
    Thanks and Regards,
    Manish Sharma

    Hello Manish,
    This is clearly a Portal issue.
    Probably an issue with BI Java.
    I recommend you to update your BI Java components to latest patch recommended by Java SP_Patch Matrix.
    If you are using Netweaver 7.0, please check the link below:
    http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/6010addf-e096-2b10-8893-e98586d005f9 [original link is broken]
    If you are using Netweaver 7.0 EHP 1 (7.01), please the this link:
    http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/c098b21c-e56f-2d10-2aad-b13915b396a4 [original link is broken]
    Applying the patches recommended should solve the issue.
    Also, as a recommendation, run the BI Diagnostics - note 937697 - and correct the red alerts.
    Best Regards,
    Edward John

  • 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

  • WMI query hanging

    I have some code (VB Script) that is collecting CPU performance metrics from WMI.  The code works well on all of the servers (identical servers) but after a period of time (8 hours, 30 hours, other random times) on some of the servers the query hangs.
     After several hours (e.g. 8 hours) the query will work again on the server.  I have used WBEMTEST to query the CIMv2 namespace to perform the same query on the server where WMI is having a problem and it also hangs.
    The query eventually times out and does not return a value.
    I have asked the team to rebuild WMI and after they completed the rebuild, the problem still occurs.
    Since the code is only performing a read operation on WMI, I do not see how the query can cause the hang of WMI.
    Any ideas on what I should do next?
    Thanks

    Hi,
    Before going further, would you please let me know whether install all
    necessary Windows Updates on those servers?
    à
    but after a period of time (8 hours, 30 hours, other random times) on some of the servers the query hangs.
    When the
    hang issue occurred, please check if consume high RAM or CPU. Just a confirmation, thanks for your understanding.
    In addition, please use the WMI Diagnosis Utility and check if can help you to analyze this issue. for more
    details, please refer to following articles.
    WMI Diagnosis Utility
    WMIDiag 2.1 is here!
    If any update, please feel free to let me know.
    Hope this helps.
    Best regards,
    Justin Gu

  • Query hangs on 2.4 release

    I was migrating the code from 2.3 to 2.4 and tested the query with a fairly large expression, the query hangs:
    my test query is this:
    "collection('people.dbxml')/people/person[name=$name and (@id!=655 and @id!=660 and @id!=659 and @id!=664 and @id!=663 and @id!=655 and @id!=660 and @id!=663 and @id!=661 and @id!=662 and @id!=657 and @id!=691 and @id!=689 and @id!=692 and @id!=658 and @id!=689 and @id!=654 and @id!=688)]";
    that worked on 2.3, anyone has a solution??
    0x00d3be86 in DbXml::Buffer::reserve (this=0xbfdba0a8, offset=@0xbfdba02c, n=1)
    at Buffer.cpp:157
    157 if (static_cast<char*>(pCursor_) + n >
    (gdb) bt
    #0 0x00d3be86 in DbXml::Buffer::reserve (this=0xbfdba0a8, offset=@0xbfdba02c,
    n=1) at Buffer.cpp:157
    #1 0x00d3c017 in DbXml::Buffer::write (this=0xbfdba0a8, p=0xbfdba06b, n=1)
    at Buffer.cpp:146
    #2 0x00d62c58 in DbXml::Key::marshal (this=0xbfdba228, buffer=@0xbfdba0a8,
    value=0x0, length=0) at Key.cpp:142
    #3 0x00d63394 in DbXml::Key::setDbtFromThis (this=0xbfdba228, dbt=@0xbfdba14c)
    at Key.cpp:345
    #4 0x00d486c9 in DbXml::Container::getKeyStatistics (this=0x8bc0390, txn=0x0,
    key=@0xbfdba228) at Container.cpp:582
    #5 0x00d48c69 in DbXml::Container::getIndexCost (this=0x8bc0390,
    oc=@0x8bf590c, op1=DbXml::DbWrapper::PREFIX, key1=@0xbfdba228,
    op2=DbXml::DbWrapper::NONE, key2=@0xbfdba240) at Container.cpp:2018
    #6 0x00d4600e in DbXml::Container::getDocumentSSCost (this=0x8bc0390,
    oc=@0x8bf590c, cache=@0x8bf58f4) at Container.cpp:1940
    #7 0x00e8a737 in DbXml::SequentialScanQP::cost (this=0x8c5045c,
    context=@0x8bf590c, qec=@0xbfdbb23c) at SequentialScanQP.cpp:169
    #8 0x00e68532 in DbXml::StructuralJoinQP::cost (this=0x8c50a24,
    context=@0x8bf590c, qec=@0xbfdbb23c) at StructuralJoinQP.cpp:60

    The query optimizer in DB XML 2.4 has had a big overhaul, and it's now performing a lot more optimizations than the previous version used to. I've found and fixed your bug now, and it should be being released as a patch soon.
    Please detail any suspected bugs in a thread on the forums - one of the DB XML developers will work with you to find and resolve your problems.
    Jhon, your problems seem to be quite different to the one in this thread.
    John

  • 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.

  • Query functions and procedures of a user schema

    Hai all,
    how can i query functions and procedures of user suppose user scott using sqlplus?
    i created a function as user scott how can i view my function name?
    Thanks

    Hi,
    You can Query from dba_objects of user_objects for View,
    select owner,object_name,object_type,status from dba_objects where owner='SCOTT';
    or
    conn scott/pass
    select object_name,object_type,status from user_objects;HTH

Maybe you are looking for