Question regarding cursor variables, while using table functions

Hi,
I created a procedure and when i'm try'g to call it. now i'm getting this error.
CREATE OR REPLACE TYPE TAB_EMP_REC IS OBJECT(
EMP_ID NUMBER(9),
EMP_NAME VARCHAR2(30));
CREATE OR REPLACE TYPE T_EMP_TMP IS TABLE OF TAB_EMP_REC ;
CREATE OR REPLACE PROCEDURE USP_CREATE_DATA(
p_Input IN NUMBER,
V_EMP_CUR OUT sys_refcursor) IS
T_EMp T_EMP_TMP := T_EMP_TMP( );
BEGIN
t_emp.extend();
t_emp(1) := TAB_EMP_REC(p_input, 'jack');
OPEN V_EMP_CUR FOR SELECT * from TABLE(t_emp);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR '||SQLERRM);
END USP_CREATE_DATA;
calling procedure::
DECLARE
type O_RESULT_CUR is ref cursor return TAB_EMP_REC;
V_EMP_REC TAB_EMP_REC;
BEGIN
USP_CREATE_DATA(99, O_RESULT_CUR);
LOOP
FETCH O_RESULT_CUR INTO V_EMP_REC;
EXIT WHEN O_RESULT_CUR%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(V_EMP_REC.EMP_ID);
END LOOP;
CLOSE O_RESULT_CUR;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR '||SQLERRM);
END;
Now i'm getting an error PLS-00362: invalid cursor return type; 'TAB_EMP_REC' must be a record type.
My question is i already declared it as a database object. What do i need to do ?
thank you

but t_emp(1) := TAB_EMP_REC(p_input, 'jai');
is correct, since.. i'm passing a record into t_emp(1)(this is the first column in this table)No it is not, since TAB_EMP_REC is just an object, when used as a collection, it can be a VARRAY, a PL/SQL table(associative array), nested table etc. As mentioned in my earlier post, if you want to use a collection of the same structure (with subscript n, as you have done here), then you need to declare a collection of type TAB_EMP_REC.In this case you have already declared a table of type TAB_EMP_REC - +CREATE OR REPLACE TYPE T_EMP_TMP IS TABLE Also, t_emp is of type T_EMP_TMP - T_EMp T_EMP_TMP := T_EMP_TMP( );*
As for the error you are getting, try changing to -
t_emp := T_EMP_TMP(TAB_EMP_REC(p_input, 'jai'));*
Note : Not Tested.

Similar Messages

  • Internal Error while using Table Functions

    Here is the query
    select * from table (cast(sf_frontend.SF_STDDEV(2002,'Q','1',20,'N') as
    NDeviation))
    It gives this error
    ORA-00600: internal error code, arguments: [17274], [4], [], [], [], [], [], []
    Can anyone help me out... Any help will be appreciated
    [email protected]

    1. Have the screen open where you have the Shift F2, you can manually run the query of the formatted search, it will sometimes give you more meaningful message.
    Eg:
    You have a formatted search query 'Query 1'  which is saved in Tools> User Query> Query 1 attached to field DocTotal.
    So, what you do is, instead of pressing Shift F2, you go to tools > User Query.> Query 1 to run it.
    2. Another thing could be the field you used in the formula do not have the focus when you run it.
    Eg: you use $[4.0.0] in the query.
    When you press Shift F2,  the field represents $[$4.0.0] do not have focus.

  • Regardin handling exception in a function, while using that function in sql

    Hi gurus,
    I have a question regarding logging exceptions while using functions.
    I wrote a separate package to handle errors, where i have a procedure.
    In this proc i'm logging my error into a table and then raise the error to the front end.
    Ex:
    proc_log_and_raise    -- this proc... inserts my error into a table and then raisenow i included this error procedure in all functions and procedures.
    consider an example with a sample procedure and function.
    function func_1(( v_var   varchar2) return varchar2 is
    begin
         select   column2
         from     table2
        where col1 = v_var;
    exception
        when others then
             proc_log_and_raise;
    end;  
    procedure proc_1( v_var   varchar2) is
    begin
        select   func_1(v_var)  -- error occurs here..
        from     table_a
        where   col1 = v_var;
    exception
        when others then
             proc_log_and_raise;
    end;    now i do
    exec  proc_1( v_var );but now my problem is, when an error occurs in func_1, i'm getting an error with DML operation ( as we are inserting into error table)
    ORA-14551: cannot perform a DML operation inside a query.
    so what i want to do is, log both function and procedure where error occured.
    So is there any other better way, we can write our exception handling, so that i can log error and use function in a select statement.
    thank you.

    I changed my procedure a little, to make it simple.
    FUNCTION        PKG_WEEKLY.FUNC_1
                RETURN NUMBER IS 
                exc exception;
    BEGIN                         
                raise exc;
                RETURN           v_provr_rcoupt;
    EXCEPTION
                when exc then
                            PKG.PKG_ERROR.USP_LOG_AND_RAISE(
                                        'batch_1',
                                        'func_1',
                                        SQLCODE,
                                        DBMS_UTILITY.FORMAT_ERROR_STACK || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE()); 
    END FUNC_1;     
    PROCEDURE    PKG_WEEKLY.PROC_1(
                cur_details                                OUT      sys_refcursor) IS
    BEGIN
                OPEN cur_details FOR
                SELECT            NVL(PKG.PKG_WEEKLY.FUNC_1,0))    FROM DUAL;
    EXCEPTION
                WHEN OTHERS THEN
                            REPORT_APP_PKG.PKG_REPORT_ERROR.USP_LOG_AND_RAISE(
                                        'batch_1',
                                        'PROC_1',
                                        SQLCODE,
                                        DBMS_UTILITY.FORMAT_ERROR_STACK || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE());  
    END PROC_1; Now i execute it.
    exec PKG_WEEKLY.PROC_1(:cursor); Error logged into the table:
    242 batch_1 func_1 ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "REPORT_APP_PKG.PKG_REPORT_WEEKLY_CAO", line 230
    04/14/2009 16:09:25
    ERRORS displayed to the front end:
    ORA-20156: ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "PKG.PKG_WEEKLY", line 230
    ORA-06512: at "PKG.PKG_ERROR", line 48
    ORA-06512: at "PKG.PKG_ERROR", line 226
    ORA-06512: at "PKG.PKG_WEEKLY", line 261
    thank you

  • ORA-00902: invalid datatype comile error while using CAST function

    Hi everyone,
    I'm getting ORA-00902: invalid datatype compilation error while using CAST function.
    open ref_cursor_list for select empName from TABLE(CAST(part_t AS partnumberlist));
    The partnumberlist and ref_cursor_list is declared in the Package spec as given below.
    TYPE ref_cursor_list IS REF CURSOR;
    TYPE partnumberlist IS TABLE OF emp.empName%TYPE;
    The error points the partnumberlist as invalid datatype in TOAD because of this i'm unable to compile the package.
    Any suggestion
    Thanks and regards
    Sathish Gopal

    Here is my code for
    package Spec
    CREATE OR REPLACE PACKAGE "HISTORICAL_COMMENTZ" AS
    TYPE prior_part_data_record IS RECORD (
    prior_part_row_id PGM_RPLCMNT_PART.PR_PART_ROW_S_ID%TYPE,
    prior_pgm_chng_s_id PGM_RPLCMNT_PART.PR_PGM_CHNG_S_ID%TYPE
    TYPE parts_list IS TABLE OF prior_part_data_record;
    --TYPE parts_list IS TABLE OF NUMBER;
    TYPE partnumberlist IS TABLE OF PGM_RPLCMNT_PART.PR_PART_ROW_S_ID%TYPE;
    TYPE partnumber_cursor IS REF CURSOR;
    TYPE comment_record IS RECORD (
    pgm_s_id                     PGM_PART_CMNT.PGM_S_ID%TYPE,
    part_row_s_id                PGM_PART_CMNT.PART_ROW_S_ID%TYPE,
    pgm_chng_s_id                PGM_PART_CMNT.PGM_CHNG_S_ID%TYPE,
    cmnt_txt                     PGM_PART_CMNT.CMNT_TXT%TYPE,
    cmnt_dt                     PGM_PART_CMNT.CMNT_DT%TYPE,
    updt_rsrc_id                PGM_PART_CMNT.UPDT_RSRC_ID%TYPE
    TYPE comment_list IS TABLE OF comment_record;
    global_pgm_s_id INTEGER := 0;
    global_part_row_s_id INTEGER := 0;
    err_num NUMBER := 999999;
    err_msg VARCHAR2 (250);
    PROCEDURE getComments (
    pgm_s_id IN NUMBER,
    part_row_s_id IN NUMBER,
    partnumber_cursorlist out partnumber_cursor);
    END;
    Package Body
    CREATE OR REPLACE PACKAGE BODY HISTORICAL_COMMENTZ
    AS
    FUNCTION getPriorPart
    (param_prior_pgm_chng_s_id IN PGM_RPLCMNT_PART.PR_PGM_CHNG_S_ID%TYPE,
    return_prior_part_data_record IN OUT prior_part_data_record
    RETURN INTEGER
    IS
    retVal INTEGER;
    prior_part_row_id INTEGER;
    prior_pgm_chng_s_id INTEGER;
    local_prior_part_data_record prior_part_data_record;
    BEGIN
    SELECT PR_PART_ROW_S_ID AS prior_part_row_id, PR_PGM_CHNG_S_ID AS prior_pgm_chng_s_id
    INTO local_prior_part_data_record
    --SELECT PR_PART_ROW_S_ID INTO retVal
    FROM PGM_RPLCMNT_PART
    WHERE PGM_S_ID = global_pgm_s_id AND CUR_PGM_CHNG_S_ID = param_prior_pgm_chng_s_id;
    return_prior_part_data_record := local_prior_part_data_record;
    retVal := 0;
    RETURN retVal;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    retVal := -1;
    RETURN retVal;
    WHEN OTHERS
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    retVal := -1;
    RETURN retVal;
    END getPriorPart;
    FUNCTION getComment (found_parts_list IN parts_list, comments OUT comment_list)
    RETURN INTEGER
    IS
    CURSOR init_cursor
    IS
    SELECT PGM_S_ID,PART_ROW_S_ID,PGM_CHNG_S_ID,CMNT_TXT,CMNT_DT,UPDT_RSRC_ID
    FROM PGM_PART_CMNT WHERE 1 = 2;
    retVal INTEGER;
    indexNum PLS_INTEGER;
    local_part_record prior_part_data_record;
    local_comment_record comment_record;
    local_part_row_s_id NUMBER;
    i PLS_INTEGER;
    BEGIN
    OPEN init_cursor;
    FETCH init_cursor
    BULK COLLECT INTO comments;
    i := 0;
    indexNum := found_parts_list.FIRST;
    WHILE indexNum IS NOT NULL
    LOOP
    local_part_record := found_parts_list(indexnum);
    local_part_row_s_id := local_part_record.prior_part_row_id;
    SELECT PGM_S_ID,PART_ROW_S_ID,PGM_CHNG_S_ID,CMNT_TXT,CMNT_DT,UPDT_RSRC_ID
    INTO local_comment_record FROM PGM_PART_CMNT
    WHERE PGM_S_ID = global_pgm_s_id
    AND PART_ROW_S_ID = local_part_row_s_id;
    comments(i) := local_comment_record;
    i := i + 1;
    END LOOP;
    RETURN retval;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    RETURN retval;
    WHEN OTHERS
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    RETURN retval;
    END getComment;
    PROCEDURE getComments
    pgm_s_id IN NUMBER,
    part_row_s_id IN NUMBER,
    partnumber_cursorlist OUT partnumber_cursor)
    IS
    comment_recordlist comment_record;
    retPartnumberlist partnumberlist;
    found_parts_list parts_list;
    local_part_record prior_part_data_record;
    is_more_parts BOOLEAN;
    driver_chng_s_id NUMBER;
    num_parts NUMBER;
    retVal NUMBER;
    comments comment_list;
    returnPartnumberlist partnumberlist;
    iloopCounter PLS_INTEGER;
    inx1 PLS_INTEGER;
    part_t partnumberlist :=partnumberlist(100,200,300);
    CURSOR part_list_init_cursor
    IS
    SELECT PR_PART_ROW_S_ID,PR_PGM_CHNG_S_ID FROM PGM_RPLCMNT_PART WHERE 1 = 2;
    CURSOR inIt_cursor
    IS
    SELECT 0 FROM DUAL WHERE 1 = 2;
    BEGIN
    DBMS_OUTPUT.ENABLE (5000000);
    global_pgm_s_id := pgm_s_id;
    global_part_row_s_id := part_row_s_id;
    SELECT PART_ROW_S_ID AS prior_part_row_id, PR_PGM_CHNG_S_ID AS prior_pgm_chng_s_id
    INTO local_part_record
    FROM PGM_RPLCMNT_PART
    WHERE PGM_S_ID = global_pgm_s_id AND PART_ROW_S_ID = global_part_row_s_id AND
    CUR_PGM_CHNG_S_ID IN (SELECT MAX(CUR_PGM_CHNG_S_ID) FROM PGM_RPLCMNT_PART WHERE
    PGM_S_ID = global_pgm_s_id AND PART_ROW_S_ID = global_part_row_s_id
    GROUP BY PART_ROW_S_ID);
    OPEN part_list_init_cursor;
    FETCH part_list_init_cursor
    BULK COLLECT INTO found_parts_list;
    -- Add the existing part to the found list
    found_parts_list.EXTEND;
    found_parts_list(1) := local_part_record;
    driver_chng_s_id := local_part_record.prior_pgm_chng_s_id;
    num_parts := 1;
    is_more_parts := TRUE;
    WHILE (is_more_parts) LOOP
    retVal := getPriorPart(driver_chng_s_id,local_part_record);
    IF (retVal != -1) THEN
    found_parts_list.EXTEND;
    num_parts := num_parts + 1;
    found_parts_list(num_parts) := local_part_record;
    driver_chng_s_id := local_part_record.prior_pgm_chng_s_id;
    ELSE
    is_more_parts := FALSE;
    END IF;
    END LOOP;
    --num_parts := getComment(found_parts_list,comments);
    OPEN init_cursor;
    FETCH init_cursor
    BULK COLLECT INTO returnPartnumberlist;
    num_parts := found_parts_list.COUNT;
    FOR iloopCounter IN 1 .. num_parts
    LOOP
    returnPartnumberlist.EXTEND;
    returnPartnumberlist(iloopCounter) := found_parts_list(iloopCounter).prior_part_row_id;
    END LOOP;
    retPartnumberlist := returnPartnumberlist;
    open
    *          partnumber_cursorlist for select PR_PART_ROW_S_ID from TABLE(CAST(retPartnumberlist AS historical_commentz.partnumberlist));*                              
    DBMS_OUTPUT.put_line('Done....!');
    EXCEPTION
    some code..............................
    END getComments;
    END HISTORICAL_COMMENTZ;
    /

  • Ora-600 using table function over db link

    Hi,
    I have a table function n my target schema (OWB 9.2.0.4 on Oracle 9.2.0.5) with the following signature:
    function uii_get_exchange_data_tf(
    p_input_values in sys_refcursor
    ) return uii_exchange_table_t pipelined
    When I try to use this with a remote table over a db link, e.g.:
    =============
    select * from table(uii_get_exchange_data_tf(cursor (select sub_zone || '/' || exch_grp_cd exchange_id,
    exch_name exchange_name FROM cds_exchange_test@uiid1@uiidraconn order by exchange_id)))
    ==============
    I get this:
    ================
    ORA-00600: internal error code, arguments: [kokbnp2], [942], [], [], [], [], [],
    ORA-06512: at "UII_ODS_OWNER_DEV.UII_GET_EXCHANGE_DATA_TF", line 21
    =================
    However, if I create a local view with the same remote select like this:
    ===================
    CREATE OR REPLACE FORCE VIEW UII_CDS_EXCHANGE_RV
    AS SELECT sub_zone || '/' || exch_grp_cd exchange_id,
    exch_name exchange_name
    FROM cds_css_exch_detail@uiid1@uiidraconn;
    ====================
    Then everything works fine.
    Can someone help ? I'm sure I'm dooing something silly, since so many people seem to be using table functions from OWB just fine; but I can't figure out what :-(
    Thanks in advance.
    Regards,
    Biswa.

    Hello,
    Is this query works fine without creating mview
    SELECT COL1,COL2, CASE when COL3 = Y then (select X from MASTER2@DBLINK) FROM MASTER1@DBLINK.
    try something like this
    SELECT col1, col2, CASE
                          WHEN col3 = y
                          THEN
                             (SELECT x
                              FROM master2@dblink)
                       END
                          my
    FROM master1@dblinkregards

  • Error while using the function module..pack_handling_unit_dlvry

    Hi all...
    while using the function module pack_handling_unit_dlvry,
    we need to pass the handling unit number as per the functionality we require.
    but the mandatory field for the function module is the handling unit number in the form of bar code..
    so how to use this function module..
    All the useful answers will be regarded..
    Regards,
    Saroja.

    Have you tried using BAPI BAPI_HU_CREATE. Also view Function Module Documentation on its usage.

  • Using table function with merge

    I wanna use table function on a table type in a merger statement inside a procedure .
    1 create or replace procedure fnd_proc as
    2          cursor fnd_c is
                        select * from fnd_columns;
    3          type test_t is table of fnd_columns%rowtype;
    4          fnd_t test_t;
    5 begin
    6          merge into sample s using (select * from table  (fnd_pkg1.get_records(cursor(select * from fnd_columns)))) f
    7          on (s.application_id = f.application_id)
    8          when matched then
    9                  update set last_update_date=sysdate
    10          when not matched then
    11                 insert(APPLICATION_ID,TABLE_ID,COLUMN_ID) values(f.APPLICATION_ID,f.TABLE_ID,f.COLUMN_ID);
    12 end;
    create or replace package fnd_pkg1 as
         type fnd_type is table of fnd_columns%rowtype;
         function get_records(p_cursor IN  SYS_REFCURSOR) return fnd_type;
    end;
    create or replace package body fnd_pkg1 as
            function get_records(p_cursor IN  SYS_REFCURSOR) return fnd_type is
                    fnd_data fnd_type;
            begin
                    fetch p_cursor bulk collect into fnd_data;
                    return fnd_data;
            end;
    end;
    /When i compile the procedure fnd_proc I get the following error
    LINE/COL ERROR
    6/11 PL/SQL: SQL Statement ignored
    6/52 PL/SQL: ORA-22905: cannot access rows from a non-nested table
    item
    6/67 PLS-00642: local collection types not allowed in SQL statements
    Let me know what has to be done

    michaels>  CREATE TABLE fnd_columns (application_id ,table_id ,column_id ,last_update_date )
    AS SELECT object_id,data_object_id,ROWNUM,created FROM all_objects
    Table created.
    michaels>  CREATE TABLE SAMPLE (application_id INTEGER,table_id INTEGER,column_id INTEGER,last_update_date DATE)
    Table created.
    michaels>  CREATE OR REPLACE TYPE fnd_obj AS OBJECT (
       application_id     INTEGER,
       table_id           INTEGER,
       column_id          INTEGER,
       last_update_date   DATE
    Type created.
    michaels>  CREATE OR REPLACE TYPE fnd_type AS TABLE OF fnd_obj
    Type created.
    michaels>  CREATE OR REPLACE PACKAGE fnd_pkg1
    AS
       FUNCTION get_records (p_cursor IN sys_refcursor)
          RETURN fnd_type;
       PROCEDURE fnd_proc;
    END fnd_pkg1;
    Package created.
    michaels>  CREATE OR REPLACE PACKAGE BODY fnd_pkg1
    AS
       FUNCTION get_records (p_cursor IN sys_refcursor)
          RETURN fnd_type
       IS
          fnd_data   fnd_type;
       BEGIN
          FETCH p_cursor
          BULK COLLECT INTO fnd_data;
          RETURN fnd_data;
       END get_records;
       PROCEDURE fnd_proc
       AS
          CURSOR fnd_c
          IS
             SELECT *
               FROM fnd_columns;
          TYPE test_t IS TABLE OF fnd_columns%ROWTYPE;
          fnd_t   test_t;
       BEGIN
          MERGE INTO SAMPLE s
             USING (SELECT *
                      FROM TABLE
                              (fnd_pkg1.get_records
                                         (CURSOR (SELECT fnd_obj (application_id,
                                                                  table_id,
                                                                  column_id,
                                                                  last_update_date
                                                    FROM fnd_columns
                              )) f
             ON (s.application_id = f.application_id)
             WHEN MATCHED THEN
                UPDATE
                   SET last_update_date = SYSDATE
             WHEN NOT MATCHED THEN
                INSERT (application_id, table_id, column_id)
                VALUES (f.application_id, f.table_id, f.column_id);
       END fnd_proc;
    END fnd_pkg1;
    Package body created.
    michaels>  BEGIN
       fnd_pkg1.fnd_proc;
    END;
    PL/SQL procedure successfully completed.
    michaels>  SELECT COUNT (*)
      FROM SAMPLE
      COUNT(*)
         47469Now I'd like to see the stats and the ferrari too ;-)

  • Returning Collection using table function

    Hi,
    I'm trying to return a collection with record type using table function but facing some issues.
    Could someone help me with it.
    SUNNY@11gR1> create or replace package test_pack as
      2  type rec_typ is record (
      3  empname varchar2(30),
      4  empage number(2),
      5  empsal number(10));
      6  type nest_typ is table of rec_typ;
      7  function list_emp return nest_typ;
      8  end;
      9  /
    Package created.
    Elapsed: 00:00:00.01
    SUNNY@11gR1> create or replace package body test_pack is
      2  function list_emp return nest_typ is
      3  nest_var nest_typ := nest_typ();
      4  begin
      5  nest_var.extend;
      6  nest_var(nest_var.last).empname := 'KING';
      7  nest_var(nest_var.last).empage := 25;
      8  nest_var(nest_var.last).empsal := 2500;
      9  nest_var.extend;
    10  nest_var(nest_var.last).empname := 'SCOTT';
    11  nest_var(nest_var.last).empage := 22;
    12  nest_var(nest_var.last).empsal := 3500;
    13  nest_var.extend;
    14  nest_var(nest_var.last).empname := 'BLAKE';
    15  nest_var(nest_var.last).empage := 1;
    16  return nest_var;
    17  end;
    18  end;
    19  /
    Package body created.
    Elapsed: 00:00:00.01
    SUNNY@11gR1> select * from table(test_pack.list_emp);
    select * from table(test_pack.list_emp)
    ERROR at line 1:
    ORA-00902: invalid datatype
    Elapsed: 00:00:00.01
    SUNNY@11gR1>Regards,
    Sunny

    But if I use pipelined function instead then I'm able to retrieve the records
    SUNNY@11gR1> create or replace package test_pack as
      2  type rec_typ is record (
      3  empname varchar2(30),
      4  empage number(2),
      5  empsal number(10));
      6  type nest_typ is table of rec_typ;
      7  function list_emp return nest_typ pipelined;
      8  end;
      9  /
    Package created.
    SUNNY@11gR1> ed
    Wrote file afiedt.buf
      1  create or replace package body test_pack as
      2  function list_emp return nest_typ pipelined is
      3  rec_var rec_typ;
      4  begin
      5  rec_var.empname := 'KING';
      6  rec_var.empage := 24;
      7  rec_var.empsal := 10000;
      8  pipe row(rec_var);
      9  rec_var.empname:='SCOTT';
    10  rec_var.empage:=22;
    11  rec_var.empsal:=2000;
    12  pipe row(rec_var);
    13  rec_var.empname:='BLAKE';
    14  rec_var.empage:='1';
    15  pipe row(rec_var);
    16  return;
    17  end;
    18* end;
    SUNNY@11gR1> /
    Package body created.
    Elapsed: 00:00:00.01
    SUNNY@11gR1> select * from table(test_pack.list_emp);
    EMPNAME                            EMPAGE     EMPSAL
    KING                                   24      10000
    SCOTT                                  22       2000
    BLAKE                                   1       2000
    Elapsed: 00:00:00.00Why is that?
    Regards,
    Sunny

  • Error in XSLT mapping while using string functions

    Hi All,
    While using tokenize() and substring-before() functions in XSLT mapping,we are getting an error.The error message is Unexpected symbol "" So while using string functions in XSLT mapping do we have to use any header functions.
    Please through light on syntax etc.,of string functions in XSLT.
    Thanx in advance,
    Lokesh Dhulipudi
    Edited by: LOKESH DHULIPUDI on Dec 27, 2007 7:32 AM

    Hi,
    Hope you have gone thru this help:
    http://w3schools.com/xsl/default.asp
    Rgds, Moorthy

  • Can I use table function inside Dynamic query ?

    Dear Gurus,
    I have following code
    DECLARE
    TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
    OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
    QUERY_STRING VARCHAR2(4000);
    BEGIN
    OtherNoList := CRITERIA_LIST_TABLE();
    SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
    FROM DUAL
    CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
    QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
    'SELECT C1,'||
    'C2 '||
    'FROM TAB1 ,'||
    'TABLE( '||
              'CAST (OtherNoList AS CRITERIA_LIST_TABLE) '||
                   ') OTHRNOS '||
    'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
    DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
    EXECUTE IMMEDIATE QUERY_STRING;
    END;
    Can I use Table function inside dynamic query.
    Thanking in advance
    Sanjeev

    Try:
    DECLARE
    TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
    OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
    QUERY_STRING VARCHAR2(4000);
    BEGIN
    OtherNoList := CRITERIA_LIST_TABLE();
    SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
    FROM DUAL
    CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
    QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
    'SELECT C1,'||
    'C2 '||
    'FROM TAB1 ,'||
    'TABLE( '||
    'CAST (:OtherNoList AS CRITERIA_LIST_TABLE) '||
    ') OTHRNOS '||
    'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
    DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
    EXECUTE IMMEDIATE QUERY_STRING using OtherNoList;
    END;p.s. not tested
    Amiel Davis

  • Error while using row_num function in forms6i

    Oracle forms6i
    Hai
    While using row num function in my forms i had a error.
    My coding is
    declare
    pin_no varchar2(16);
    pin_date date;
    pin_time varchar2(25);
    mstr varchar2(200);
    m_file TEXT_IO.FILE_TYPE;
    m_file_path varchar2(100) := :global.filename;
    line_count number;
    M_BARCODE VARCHAR2(16);
    M_BARDATE DATE;
    M_BARTIME varchar2(25);
    M_No number;
    Cursor c1 is
    select barcode,bardate,bartime,
    row_number() over (partition barcode order by bartime) as RN-------------------the error at this line
    from temp_attendance
    group by barcode,bardate,bartime
    order by bardate;
    begin
    If m_file_path is not null then
    m_file:= TEXT_IO.fopen(m_file_path, 'r');
    --DELETE FROM temp_attendance;     
    Loop
    begin
    TEXT_IO.get_line(m_file,mstr);
    mstr := ltrim(rtrim(mstr));
    M_barcode :=substr(mstr,1,16);
    M_bardate := to_date(substr(mstr,17,8),'DD/MM/YYYY');
    M_bartime := (substr(mstr,25,4));
    INSERT INTO temp_attendance(BARCODE,BARDATE,BARTIME,RN) VALUES(M_BARCODE,M_BARDATE,M_BARTIME,M_No);
    Exception
    when no_data_found then
    text_io.fclose(m_file);
    exit;
    End;
    End loop;
    go_block('TEST_MS1');
    clear_block(no_validate);
    For r1 in c1 loop
         :barcode := r1.barcode;
         :bardate := r1.bardate;
         :bartime := r1.bartime;
         next_Record;
    end loop;
    first_record;
    end if;
    exception
    when others then
    forms_ddl('ROLLBACK');
    message (sqlerrm);
    end;
    Thanks & Regards
    Srikkanth.M

    Hi,
    Try using:
    row_number() over (partition BY barcode order by bartime) as RN
    If that wasn't the problem, what is the error you are getting?
    Regards.

  • Error while using group function

    Oracle forms6i
    Hai
    While i am compile my coding it compile successfully, but when i tried to executes i shows error in group function
    my coding is
    if (cnt<>0 ) then
    select BARCODE,INTIME,OUTTIME into today_bar,today_in,today_out from dail_att where BARCODE= :Barcode
    and ATTEND_DATE = :bardate;
    update dail_att set outtime = max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate;
    else
    if (cnt2<>0 ) then
    select INTIME,OUTTIME into yest_in,yest_out from dail_att where BARCODE= :Barcode
    and ATTEND_DATE = :bardate-1;
    if(yest_in is not null and yest_out is null) then
    update dail_att set outtime =max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate-1;
    else
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,min(:bartime),:bardate);
    end if;
    else
    if :bartime between 0100 and 0630 then
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,min(:bartime),:bardate-1);
    update dail_att set outtime = max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate-1;
    else
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,:min(bartime),:bardate);
    end if;     
    end if;
    end if;
    while i am trying to this groupfunction it throws error while i use having tell me how to use group function and where
    to use
    Regadrs
    Srikkanth.M

    Hai sir
    I had a table that contain fields
    EMPCODE NUMBER
    EMPNAME VARCHAR2(25)
    BARCODE VARCHAR2(25)
    INTIME VARCHAR2(25)
    OUTTIME VARCHAR2(25)
    INTRTIMEIN VARCHAR2(25)
    INTROUTTIME VARCHAR2(25)
    PERTIMEIN VARCHAR2(25);
    PERTIMEOUT VARCHAR2(25);
    ATTEND_DATE DATE ;
    Consider that a table with 6 fields ie timein,intrtimein,pertimein,pertimeout,intrtimeout,timeout
    I have generating a attendance table and a table contain 6 various times for an employees and we need to arrange it in order
    0815,0816,1230,1250,1645,1646
    If 0815 is the starting time then timein ie mintime
    0816 stored to be in intrtime
    then1250 then it stored in pertimein
    then 1230 then it stored in pertimeout
    then 1645 stored in intrtimeout
    then 1646 stored in timeout
    I tried with max and min function but its not working properly pls tell me some solutions
    Thanks & Regards
    Srikkanth.M

  • Question Regarding Cursor

    I need to create a Cursor where in the SELECT clause I am using Replace function. The replace value is coming from a variable.
    declare
    cursor csr is select replace(col1,'{DATE}',v_date) from tab1;
    begin
    v_date := fun_get_date();
    for c in csr
    loop
    end loop;
    end;
    can i use variables in select clause?

    Hmm..
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:01.02
    satyaki>
    satyaki>
    satyaki>select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO JOB1      DOB
          7521 WARD       SALESMAN        7698 22-FEB-81       1815        500         30 SALESMAN
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1815       1400         30 SALESMAN
          7788 SCOTT      ANALYST         7566 19-APR-87     4791.6                    20 ANALYST
          7839 KING       PRESIDENT            17-NOV-81       7260                    10 PRESIDENT
          7844 TURNER     SALESMAN        7698 08-SEP-81       2178          0         30 SALESMAN
          7876 ADAMS      CLERK           7788 23-MAY-87     159.72                    20 CLERK
          7900 JAMES      CLERK           7698 03-DEC-81     1379.4                    30 CLERK
          7902 FORD       ANALYST         7566 03-DEC-81    5270.76                    20 ANALYST
          7934 MILLER     CLERK           7782 23-JAN-82     1887.6                    10 CLERK
          7566 Smith      Manager         7839 23-JAN-82       1848          0         10 Manager   23-JAN-89
          7698 Glen       Manager         7839 23-JAN-82       1848          0         10 Manager   23-JAN-89
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO JOB1      DOB
             1 boock
    12 rows selected.
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>declare
      2    cursor c1(var in varchar2)
      3    is
      4      select ename,replace(ename,'E',var) mod_ename
      5      from emp;
      6     
      7    r1 c1%rowtype;
      8   
      9    str varchar2(20);
    10  begin
    11   
    12    str:= '&supp';
    13   
    14    for r1 in c1(str)
    15    loop
    16      dbms_output.put_line('Original :'||r1.ename);
    17      dbms_output.put_line('Modified :'||r1.mod_ename);
    18    end loop;
    19  end;
    20  /
    Enter value for supp: T
    old  12:   str:= '&supp';
    new  12:   str:= 'T';
    Original :WARD
    Modified :WARD
    Original :MARTIN
    Modified :MARTIN
    Original :SCOTT
    Modified :SCOTT
    Original :KING
    Modified :KING
    Original :TURNER
    Modified :TURNTR
    Original :ADAMS
    Modified :ADAMS
    Original :JAMES
    Modified :JAMTS
    Original :FORD
    Modified :FORD
    Original :MILLER
    Modified :MILLTR
    Original :Smith
    Modified :Smith
    Original :Glen
    Modified :Glen
    Original :boock
    Modified :boock
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.03
    satyaki>Regards.
    Satyaki De.

  • Does using TABLE FUNCTIONS degrades performance

    Hi,
    I am using a TABLE Function TABLE(TABLEA)
    I am using a SQL Statement where I am joing TABLE FUNCTION :TABLE(TABLEA) and Normal table:TABLEB
    i.e
    SELECT CODE,SUD FROM TABLEB,TABLE(TABLEA)
    WHERE CODE=CODE1 (CODE1 is a Object Type variable).

    user598986 wrote:
    I am using a TABLE Function TABLE(TABLEA)
    I am using a SQL Statement where I am joing TABLE FUNCTION :TABLE(TABLEA) and Normal table:TABLEB
    i.e
    SELECT CODE,SUD FROM TABLEB,TABLE(TABLEA)
    WHERE CODE=CODE1 (CODE1 is a Object Type variable).One particular issue with table functions and joins is that the optimizer doesn't have a clue about the cardinality, i.e. the number of rows returned by the table function and therefore applies defaults which might be way off. If you somehow know roughly how many rows are going to be returned (may be a quite constant number of rows or your process know the number of rows in a collection etc.) then you can help the optimizer by using the (undocumented) "CARDINALITY" hint, e.g.
    SELECT /*+ CARDINALITY (A, 100) */ CODE,SUD FROM TABLEB B,TABLE(TABLEA) A...
    tells the optimizer that the table function is going to return 100 rows. Note the usage of the alias in the hint.
    But bear in mind that this only helps partially, some other basic information like column statistics are still missing and therefore the estimates of the optimizer still might be inaccurate.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Problem while using aggregate functions in EJB QL 2.1

    Hai all,
       I am using aggregate function as follows
       select max(c.id) from customer as c
      for this iam selected check box EJB QL 2.1 in persistent.xml
      this is validated by nwds, but while deploying server raising error like ejb ql syntax error.
      Actually according to EJB QL 2.1 this is a valid query, what i need to do for run this same query .
      Anybody please help me in this regard
    Regards
    Somaraju

    Beevin
      Both two are not even validated,
      but with the first one as select max(c.id) from customer as c , in this case it is validated but while deploying it is error as , object must be return
      But when i saw  the ejb2.1 specification we can write this type of queries also ?
      Is it problem with was any thing
    Regards
    Somaraju

Maybe you are looking for

  • Weblogic portal 10.3.1 framework and  UCM 10gR3 code works in Jdeveloper

    Hi All, We are using weblogic portal 10.3.1 framework and UCM 10gR3. Now we want to use Jdeveloper (because we can integrate site studio using plugin) instead of weblogic workshop. So my question is does the existing code works in Jdeveloper (because

  • Distribution agent failed to create temporary files in

    Hello, we are configured transnational replication in sql server 2005 location, all replication jobs are running fine, while we checking sql server errorlog showing below error : Distribution agent failed to create temporary files in  'C:\Program Fil

  • How can I save my contact sheets in Photoshop Lightroom?

    How can I save my contact sheets in Photoshop Lightroom? I see that you create the sheets under the Print tab but how can I save them as jpgs to my desktop?

  • Video card issue on Qosmio G30

    About 2 years ago I have bought my Qosmio from Germany with 3500 Euro and first problem occur about 1 month ago when I start playing games. Notebook is equipped with the nv 7600 gt mobile video card. Problem with vertical lines on display from boot u

  • Software installation for Leopard 10.5

    I will probably be getting a couple of Mac Pros and was wondering if anyone has run into problems with installing and/or running Office 2004 or any Adobe products pre CS3. Thanks for any info