Using table function in JDBC

Hi All,
im Oracle 9i R2 :
there are package with table function and JDBC client .
In client code :
Statement st = con.createStatement() ;
ResultSet rs = st.executeQuery("select * from table(pkg.func)") ;
while (rs.next())
System.out.println(rs.getString(1)) ;
- and that not work ...
What is wrong ? :)
With best regards, Slava

Can you define "not work" here... Do you get an error? If so, what is the error number you are getting (ORA-xxxxx)?
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • 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

  • 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

  • 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

  • Getting ORA-00600 when using table functions

    Hello,
    I am trying to use simple table function:
    create or replace type StatCall AS OBJECT (
    dial_number varchar2(255),
    start_date date,
    duration number(20)
    create or replace type StatCallSet AS TABLE OF StatCall;
    create or replace package ref IS
    type refcall_t IS REF CURSOR RETURN calls%ROWTYPE;
    end ref;
    create or replace function GetStats(p ref.refcall_t) return StatCallSet pipelined is
    out_rec StatCall;
    in_rec p%ROWTYPE;
    BEGIN
    LOOP
    FETCH p INTO in_rec;
    EXIT WHEN p%NOTFOUND;
    out_rec.dial_number := in_rec.dial_number;
    out_rec.start_date := in_rec.start_date;
    out_rec.duration := in_rec.duration;
    PIPE ROW(out_rec);
    END LOOP;
    CLOSE p;
    RETURN;
    END;
    select * from TABLE(GetStats(CURSOR(select * from call)));
    And I get:
    ORA-00600: internal error code, arguments: [17285], [0xFFFFFFFF7C4900A8], [1], [0x3943BA5E0], [], [], [], []
    Oracle 9.2.0.2
    Are there any ideas about how to fix this?

    What version of the database?
    Which flavor of Disco (Plus, Desktop, Viewer)?
    Standars EUL or Apps EUL?
    Can you post the code for the calculation?
    ORA-600 errors, as you mentioned, are internal, and may require opening a dialog with Oracle support. Then again, it could be something else in the calculation that is causing the sky to fall.

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

  • Using Table Functions

    Hi all,
    For some reports, I cannot precompute some values and I need user input. For this I want to use table funcitons but I need to be able to get paramter values from user. Is it at all possible to prompt the parameters, or there can be a workaround using variables

    Unfortunately, you can't update repository variable via prompt.
    And in addition to mma, an easy way, if you don't need to use the Business Model of OBIEE, is to
    use the direct database request :
    http://gerardnico.com/wiki/dat/obiee/presentation_service/obiee_direct_database_request#database_request_in_dashboard

  • How to use todate function in JDBC adapter

    Hi All,
    How can we use the todate function to update a date field in Oracle database. I am getting a
    java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
    Exception, when I am mapping the date fields with  to_date('03/28/2009 18/43/19','MM/DD/YYYY HH24/MI/SS').
    Thanks,
    Yomesh

    The following is standard SAP document regarding this attribute, this attribute used to compose your SQL clause for string or non-string, for string, you need to put the "YES". in your case, you need to set set the value "NO"
    so create an attribute, pass a constant value "NO" to it, that is it.
    hasQuot= YES|NO During construction of the WHERE condition of the SQL statement, the table column type determines whether the default is to set the values in quotation marks (text column types) or not (numerical column types). In a few cases (for example, when using functions), it may be necessary to override this. This attribute enables you to do this. If YES, quotation marks are always set round the values for which this attribute is set in the SQL syntax. If NO, quotation marks are never set. Only use this attribute in individual cases.
    Regards.
    Liang

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

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

  • How to use the Table Function defined  in package in OWB?

    Hi,
    I defined a table function in a package. I am trying to use that in owb using Table function operator. But I came to know that, owb R1 supports only standalone table functions.
    Is there any other way to use the table function defined in a package. As like we create synonyms for functions, is there any other way to do this.
    I tryed to create synonyms, it is created. But it is showing compilation error. Finally I found that, we can't create synonyms for functions which are defined in packages.
    Any one can explain it, how to resolve this problem.
    Thank you,
    Regards
    Gowtham Sen.

    Hi Marcos,
    Thank you for reply.
    OWB R1 supports stand alone table functions. Here what I mean is, the table fucntion which is not inculded in any package is a stand alone table function.
    for example say sample_tbl_fn is a table function. It is defined as a function.It is a stand alone function. We call this fucntion as "samp_tbl_fn()";
    For exampe say sample_pkg is a package. say a function is defined in a package.
    then we call that function as sample_pkg.functionname(); This is not a stand alone function.
    I hope you understand it.
    owb supports stand alone functions.
    Here I would like to know, is there any other way to use the functions which are defined in package. While I am trying to use those functions (which are defined in package -- giving the name as packagename.functionname) it is throwing an error "Invalid object name."
    Here I would like know, is there any other way to use the table functions which are defined in a package.
    Thank you,
    Regards,
    Gowtham Sen.

  • Table function on a collection in Dynamic SQL

    Hello,
    I am trying to create a refcursor by selecting from a collection using table function.
    If I use the Select statement the query executes, but if I put the Select statement in a string
    the collection variable does not get resolved. The resaon I am putiing it in a string is because the
    WHERE clause will be passed a parameter. The code below is an anonymous block but will be changed to a
    procedure once I get it to work.
    I have tried many different ways but was unsuccessful.
    Please see if anybody cann assist or what I am trying to achive is not possible, so provide an alternative.
    The error I am getting is
    ORA-00904: "V_ALARM_REC_TABLE": invalid identifier
    ORA-06512: at line 50
    Thanks.
    Bimal
    DECLARE
    TYPE c_refcurtype IS REF CURSOR;
    x c_refcurtype;
    p_recordset c_refcurtype;
    v_rec mc2_dev2.mc2_alarm_rec_type := mc2_dev2.mc2_alarm_rec_type(null,null,null,null,null,null,null,null,
    null,null,null,null,null,null,null,null,
    null,null,null,null,null,null,null);
    v_alarm_rec_table mc2_dev2.mc2_alarm_rec_table := mc2_dev2.mc2_alarm_rec_table();
    v_select varchar2(200) := 'select a.* from ';
    v_table varchar2(200) := 'table(v_alarm_rec_table) a ';
    v_where varchar2(200) := 'where a.alarm_rule_def_uid = 9';
    v_query varchar2(32000);
    BEGIN
    MC2_ALARM.create_mc2_alarm(x, 1); --- ( X is a refcursor, which I will use to populate v_alarm_rec_table a (nested table collection)
    LOOP
    FETCH x INTO v_rec.record_cnt,
    v_rec.rn,
    v_rec.alarm_precision_order,
    v_rec.alarm_rule_def_uid,
    v_rec.alarm_type_def_uid,
    v_rec.alarm_rule_scope_uid,
    v_rec.trigger_tpl_master_uid,
    v_rec.alarm_scope_def_uid,
    v_rec.alarm_object_uid,
    v_rec.error_type,
    v_rec.all_error_codes,
    v_rec.enabled,
    v_rec.start_hour,
    v_rec.end_hour,
    v_rec.day_type,
    v_rec.alarm_severity_def_uid,
    v_rec.on_watch_duration,
    v_rec.update_on_status_change,
    v_rec.log_ind,
    v_rec.email_to,
    v_rec.email_from,
    v_rec.send_email,
    v_rec.stale_period;
    EXIT WHEN x%NOTFOUND;
    v_alarm_rec_table.extend;
    v_alarm_rec_table(v_alarm_rec_table.last) := v_rec;
    END LOOP;
    CLOSE x;
    v_query := v_select||v_table||v_where; -- ERROR OCCURS AT THIS LINE as it cannot resolve the TABLE name  v_alarm_rec_table)
    dbms_output.put_line('sql: '||v_query);
    OPEN p_recordset FOR v_query;
    LOOP
    FETCH p_recordset INTO v_rec.record_cnt,
    v_rec.rn,
    v_rec.alarm_precision_order,
    v_rec.alarm_rule_def_uid,
    v_rec.alarm_type_def_uid,
    v_rec.alarm_rule_scope_uid,
    v_rec.trigger_tpl_master_uid,
    v_rec.alarm_scope_def_uid,
    v_rec.alarm_object_uid,
    v_rec.error_type,
    v_rec.all_error_codes,
    v_rec.enabled,
    v_rec.start_hour,
    v_rec.end_hour,
    v_rec.day_type,
    v_rec.alarm_severity_def_uid,
    v_rec.on_watch_duration,
    v_rec.update_on_status_change,
    v_rec.log_ind,
    v_rec.email_to,
    v_rec.email_from,
    v_rec.send_email,
    v_rec.stale_period;
    EXIT WHEN p_recordset%NOTFOUND;
    some dbms_output statements...
    END LOOP;
    END;
    The error I am getting is
    ORA-00904: "V_ALARM_REC_TABLE": invalid identifier
    ORA-06512: at line 50

    Thanks Timur/Solomon,
    mc2_dev2 is the schema name.
    mc2_alarm_rec_table is a SQL type.
    Here are the scripts:
    CREATE OR REPLACE TYPE MC2_DEV2.mc2_alarm_rec_type IS OBJECT
    ( record_cnt NUMBER,
    rn number,
    alarm_precision_order NUMBER(6),
    alarm_rule_def_uid NUMBER(6),
    alarm_type_def_uid NUMBER(6),
    alarm_rule_scope_uid NUMBER(6),
    trigger_tpl_master_uid NUMBER(6),
    alarm_scope_def_uid NUMBER(6),
    alarm_object_uid NUMBER(6),
    error_type VARCHAR2(1),
    all_error_codes VARCHAR2(1),
    enabled VARCHAR2(1),
    start_hour NUMBER(2),
    end_hour NUMBER(2),
    day_type NUMBER(2),
    alarm_severity_def_uid NUMBER(6),
    on_watch_duration NUMBER(6),
    update_on_status_change VARCHAR2(1),
    log_ind VARCHAR2(1),
    email_to VARCHAR2(128),
    email_from VARCHAR2(128),
    send_email VARCHAR2(1),
    stale_period          NUMBER(6)
    CREATE OR REPLACE TYPE MC2_DEV2.MC2_ALARM_REC_TABLE IS TABLE OF MC2_DEV2.mc2_alarm_rec_type;
    If I popoulate the cursor with the following code:
    OPEN p_recordset FOR
    select a.* from table (v_alarm_rec_table) a where a.alarm_rule_def_uid = 9;
    there is no issue it works just fine.
    But when when I use
    OPEN p_recordset FOR v_query; ---- where v_query := v_select||v_table||v_where;
    the variable v_alarm_rec_table does not get resolved.
    Regards,
    Bimal

  • Usage of TAble Functions in OBIEE

    Hello All,
    I have created a table function in the database.
    Is it possible to use/call table functions in obiee.Please let me know how to use table functions in OBIEE.
    Thanks in advance.

    Hi,
    Thanks for your reply.
    I want to use this table function to generate answers report.
    In the query i am using unions,bind variables.I can not create a database view on this query.The best solution would be creating a table function.
    But,i do not know how to access/use/call this table function to create answers report.
    Thanks in advance.

  • TABLE function to simulate parameterized view

    Hi all,
    Since view can not have parameters, I tried to used stored procedure to return ref cursor then used TABLE function in select statement to simulate a view with parameters, since it's easy to pass parameters to a stored procedure.
    The idea is like this
    function foo (p1 int, p2 int)
    return sys_ref_cursor
    c sys_ref_cursor -- sorry, i forgot the buildin ref cursor name, just used
    this as pseudo code
    is
    open c for select * from table_a where col1=:p1 and col2=p2 using p1, p2;
    return c;
    end;
    select * from table(foo(1,2)) does not work, I know that I can iterate throught
    the cursor and pipe it out to a SQL type in function foo, then use TABLE
    function in SELECT statement. However, it seems so much coding work. Is it the
    only way or do you have better idea?
    Thanks in advance.

    It is just not correct that you cannot parameterize views.
    Nicolas gave you a link above which has an example using a context.
    Even before Oracle supported contexts you could have parameterize views using package variables.
    SQL> create or replace package pkg_vars as
      2    function get_job return emp.job%type;
      3    procedure set_job (p_job in emp.job%type)
      4  end pkg_vars;
      5  /
    Package created.
    SQL>
    SQL> create or replace package body pkg_vars as
      2    g_job emp.job%type;
      3
      4    function get_job return emp.job%type)
      5    is
      6    begin
      7      return g_job;
      8    end get_job;
      9
    10    procedure set_job (p_job in emp.job%type
    11    is
    12    begin
    13      g_job := p_job;
    14    end set_job;
    15  end pkg_vars;
    16  /
    Package body created.
    SQL>
    SQL> create or replace view view_emp1 as
      2  select deptno, count(empno) cnt
      3  from emp
      4  where job = pkg_vars.get_job
      5  group by deptno
      6  ;
    View created.
    SQL> select distinct job from emp;
    JOB
    CLERK
    SALESMAN
    PRESIDENT
    MANAGER
    ANALYST
    5 rows selected.
    SQL> exec pkg_vars.set_job('CLERK');
    PL/SQL procedure successfully completed.
    SQL> select * from view_emp1;
        DEPTNO        CNT
            30          1
            20          2
            10          1
    SQL> exec pkg_vars.set_job('MANAGER');
    PL/SQL procedure successfully completed.
    SQL> select * from view_emp1;
        DEPTNO        CNT
            30          1
            20          1
            10          1
    SQL>

Maybe you are looking for