Find data where data not in ref cursor

CREATE OR REPLACE PACKAGE types AS
TYPE weak_ref_cursor IS REF CURSOR;
END types;
CREATE OR REPLACE PROCEDURE procedure_name
(p_getname OUT types.weak_ref_cursor,
p_tablename IN VARCHAR2, p_salary IN NUMBER)
AS
v_tem VARCHAR2 (4000);
BEGIN
v_tem := 'SELECT ENAME FROM ' || UPPER (p_tablename) || ' WHERE sal > :b_salary';
OPEN p_getname FOR v_tem USING p_salary;
END procedure_name;
SQL> EXECUTE procedure_name (:g_getname, 'EMP', 2000);
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
SQL> print g_getname;
ENAME
ALLEN
WARD
MARTIN
BLAKE
babu
JOHN
TURNER
7 rows selected.
Now i want to select data from emp table where ename not in ouput of g_getname
Please help me

You cannot select that data from using a query(since the program unit is procedure), instead you can write a code (anonymous pl/sql block) and retrive the records and print them using dbms_output.put_line on console.

Similar Messages

  • Retrieve the records based on date where date is not stored

    Hi,
    I have one table in Oracle.
    I want to retrieve the records which are added or modified after a particular date & time.(but the table does not contain any column for date & time )
    For example: Product table(pid number,pname varchar2)
    i am entering 10 records on date 21/07/2005
    i am entering 20 records on date 22/07/2005
    i am entering 15 records on date 23/07/2005
    i am entering 30 records on date 24/07/2005
    If i want to retrieve the records added after 22/7/2005
    (ie.) last 45 records
    But the table does not contain any date field.
    How will you know date & time of each record updated in the table.
    If any one knows, help me.
    bye.

    for 9iR2: check out online document of Oracle9i Application Developer's Guide - Fundamentals and search flash back query
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg08sql.htm#10851
    for 10G, flash back feature is enhenced to whole database level, you can still use flash back query though.

  • Using a strongly typed ref cursor doesn't enforce data type

    I am trying to enforce the datatypes of the fields coming back from an oracle reference cursor by making it strongly typed. However, there seems to be no warning at compile time on the oracle side or exception in ODP.NET if the datatype coming back in the cursor does not match. For example here is my cursor and proc
    create or replace
    PACKAGE THIRDPARTY AS
    type pricing_record is record
    BaseIndexRate     number(6,5),
    BaseIndexRateType     VARCHAR2(1 BYTE)
    type cur_pricing2 IS ref CURSOR return pricing_record;
    PROCEDURE getpricingbyappidtest(appid IN application.intid%TYPE, pricing OUT cur_pricing2);
    END THIRDPARTY;
    create or replace
    PACKAGE BODY THIRDPARTY AS
    PROCEDURE getpricingbyappidtest(appid IN application.appid%TYPE, pricing OUT cur_pricing2)
    AS
    BEGIN
         OPEN pricing FOR
         SELECT      somevarcharfield, someothervarcharfield
    FROM application
    WHERE A.appid = appid;
    END getpricingbyappidtest;
    I would expect this wouldn't compile since i am putting a varchar into a number field. But it does. Also if i check the datatype in the reader on the .net side it also is a string. So odp doesn't seem to care what type the cursor is
    here is that code and output
    var schemaTable = reader.GetSchemaTable();
    using (var file = new System.IO.StreamWriter("c:\\_DefinitionMap_" + cursorName + ".txt"))
    file.WriteLine("COLUMN" + "\t" + "DATATYPE");
    foreach (DataRow myField in schemaTable.Rows)
    file.WriteLine(myField["ColumnName"] + "\t" + myField["DataType"]);
    COLUMN     DATATYPE
    BaseIndexRate     System.String
    BaseIndexRateType     System.String
    Does anyone have an approach for enforcing datatypes in a ref cursor? Am I doing something wrong when defining the ref cursor?

    Hello,
    By using a ref cursor you are really using a pointer to a cursor. There is no way I know of to make a compile check of the cursor check unless you want to create a SQL type and cast the cursor to this type and even this wouldn't work in all cases. For instance, I could have function call within my cursor select which could return a varchar (with a number always in the varchar) which would be horribly sloppy but legal and you would expect Oracle to compile it.
    If you are worried about this I would suggest not using ref cursors and go to UDT instead, where there will be more checking (because of a C# equivalence generated object). Oh and BTW, yes the cursor will throw an exception if the data is incorrect, but only at runtime - just like normal Oracle PLSQL.
    Cheers
    Rob.
    http://www.scnet.com.au

  • How to find out where R/3 report data are stored

    Hy,
    I am new in BW.
    I have SAP R/3 report, I need to transfer that report data (all table data) to BW.
    Could You explain me step by step how i can do it?
    How to find out where data are stored?
    Thank you very much!
    Regards,
    Arunas

    Hi Arunas,
    This topic has been discusssed here earlier. Check these links:
    BW solution for ABAP Reports
    BW reports
    Bye
    Dinesh

  • Data Set with multiple ref cursors

    Hi ,
    I need to design an integrated report , i created my data set with a oracle procedure which returns "multiple ref cursors" . In this case birt is displaying all output columns together and it is difficult to identify which column belongs to which ref cursor and if there are any columns with same name in both output cursors , it displays only one. Is there any way to handle this ? or how we handle a data set which contains multiple ref cursors in output ??

    Having to ref cursors return mutiple recordsets in an Oracle package is like haveng two resultsets return from a MS SQL Server sparc.
    The link may point you in the right direction.
    http://www.codeproject.com/Articles/675933/Returning-Multiple-Result-Sets-from-an-Entity-Fram

  • How to give ref cursor in VB procedure call

    This is my Oracle Sp
    CREATE OR REPLACE PROCEDURE CRD_DMAN.infy_usp_trades_by_broker_bkr
    ** Procedure name: CRD_DMAN.USP_TRADES_BY_BROKER
    ** Author's name: Infosys
    ** Date written: 04/11/07
    ** Description: Compliance Trade by Borker
    ** Maintenance history:
    ** Date Chg req# Name Remarks
    ** 04/11/07 Infosys Created
    p_ordercursor IN OUT infy_pkg_compliance_transact.cur_compliancetrade,
    p_startdate IN VARCHAR,
    p_enddate IN VARCHAR,
    p_fundcode IN cs_fund_config.parent_acct_cd%TYPE,
    p_clientcode IN ts_order_alloc.acct_cd%TYPE,
    p_brokercode IN ts_order_alloc.exec_broker%TYPE,
    p_reportname IN report_log.report_name%TYPE,
    p_callingapplication IN report_log.calling_application%TYPE,
    p_callinguser IN report_log.calling_user%TYPE
    IS
    --Declaring Local Variables
    v_owner VARCHAR2 (30);
    v_startdate VARCHAR2 (10);
    v_enddate VARCHAR2 (10);
    v_rowcount NUMBER:=0;
    v_logrec base_util_pkg.crd_log_record;
    exp_error EXCEPTION;
    v_fundcodevalue NUMBER;
    BEGIN
    BEGIN
    /*checking if the start date and end date are null and
    assigning the sysdate accordingly*/
    IF (TRIM(p_startdate) IS NULL )
    THEN
    v_startdate := TO_CHAR (SYSDATE, 'mm/dd/yy');
    ELSE
    v_startdate := p_startdate;
    END IF;
    IF (TRIM(p_enddate) IS NULL )
    THEN
    v_enddate := TO_CHAR (SYSDATE, 'mm/dd/yy');
    ELSE
    v_enddate := p_enddate;
    END IF;
    /*checking if fund code is null and assigning value accordingly*/
    IF TRIM (p_fundcode) IS NULL
    THEN
    v_fundcodevalue := 0;
    ELSE
    v_fundcodevalue := 1;
    END IF;
    /*checking if the reportname or calling user or calling
    application name*/
    IF (p_reportname IS NULL OR p_callinguser IS NULL
    OR p_callingapplication IS NULL)
    THEN
    RAISE exp_error;
    END IF;
    END;
    --opening and fetching the data into cursor
    v_logrec.start_time := SYSDATE;
    BEGIN
    OPEN p_ordercursor
    FOR
    SELECT
    oa.exec_broker EXEC_BROKER_CODE,
    b.bkr_name          EXEC_BROKER_NAME,
    oa.acct_cd CLIENT_CODE,
    f.acct_name               CLIENT_NAME,
    CASE WHEN (Exists (SELECT 1
                                       FROM cs_fund_broker fb
    WHERE rel_typ_cd IN('P','M')
    AND oa.exec_broker=fb.BKR_CD
                                       AND oa.acct_cd =fb.acct_cd))
                   THEN 'Y'
    ELSE 'N' END          DIRECTED_BROKER,
    COUNT ( distinct o.order_id) COUNT_TICKNUM,
    MAX (o.trade_date) TRADE_DATE,
    SUM (oa.exec_amt)               BASE_COST,
    SUM (oa.commision_amt)          TOTAL_COMMISSION,
         (SELECT ab.bkr_typ_cd FROM au_broker ab
         WHERE ab.au_change_date =(SELECT TO_TIMESTAMP(MAX(ab.au_change_date))
         FROM au_broker ab WHERE b.bkr_typ_cd != ab.bkr_typ_cd AND b.bkr_cd = ab.bkr_cd))
                                  BROKER_HISTORY
    FROM
    ts_order o
    JOIN ts_order_alloc oa ON (o.order_id = oa.order_id)
    JOIN cs_broker b ON(oa.exec_broker = b.bkr_cd)
    JOIN cs_fund f ON(oa.acct_cd = f.acct_cd)
    WHERE
    o.status = 'ACCT'
    AND oa.exec_broker = CASE WHEN TRIM (p_brokercode) IS NULL
              THEN oa.exec_broker
              ELSE TRIM(p_brokercode) END
    AND oa.acct_cd = CASE WHEN TRIM(p_clientcode) IS NULL
    THEN oa.acct_cd
    ELSE TRIM(p_clientcode) END
         AND ((0 = v_fundcodevalue) OR EXISTS (SELECT 1 FROM crd.cs_fund_config cf
              WHERE cf.parent_acct_cd =TRIM (p_fundcode)
         AND oa.acct_cd = cf.child_acct_cd))
         AND o.trade_date BETWEEN TO_DATE (v_startdate, 'mm/dd/yy')
    AND TO_DATE (v_enddate, 'mm/dd/yy')
    GROUP BY oa.exec_broker, b.bkr_name ,oa.acct_cd ,f.acct_name,oa.directed_broker,b.bkr_typ_cd,b.bkr_cd;
    END;
    BEGIN
    SELECT
    owner
    INTO
    v_owner
    FROM
    all_objects
    WHERE
    object_name = 'INFY_USP_TRADES_BY_BROKER_BKR';
    v_logrec.end_time := SYSDATE;
    v_logrec.user_code := v_owner;
    v_logrec.input_param_values := 'INFY_USP_TRADES_BY_BROKER_BKR,'
    || v_startdate
    || ','
    || v_enddate
    || ','
    || p_fundcode
    || ','
    || p_clientcode
    || ','
    || p_brokercode;
    v_logrec.report_name := p_reportname;
    v_logrec.object_name := 'INFY_USP_TRADES_BY_BROKER_BKR';
    v_logrec.rows_returned := v_rowcount;
    v_logrec.calling_application := p_callingapplication;
    v_logrec.calling_user := p_callinguser;
    END;
    BEGIN
    --calling the procedure to insert values into the report_log table
    COMMIT;
    SET TRANSACTION READ WRITE;
    base_util_pkg.crd_base_util_proc (v_logrec);
    SET TRANSACTION READ ONLY;
    END;
    EXCEPTION
    WHEN exp_error
    THEN
    DBMS_OUTPUT.put_line ('ERROR');
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line ('ERROR OCCURED' || SQLCODE);
    DBMS_OUTPUT.put_line (SQLERRM);
    END infy_usp_trades_by_broker_bkr;
    END OF CRD_DMAN.USP_TRADES_BY_BROKER
    This is my Pakage from where i am using ref cursor
    CREATE OR REPLACE PACKAGE CRD_DMAN.infy_pkg_compliance_transact
    AS
    ** Package name : CRD.INFY_PKG_COMPLIANCE_TRANSACTIONS
    ** Author's name : Infosys
    ** Date written : 06/11/07
    ** Project/System : CRD
    ** Description : Compliance Trades By Borker Package
    ** Maintenance history:
    ** Date Chg req# Name Remarks
    ** 06/11/07 CRD Infosys Created
    --Defining The ComplianceTrade Record DataType
    TYPE rec_compliancetrade IS RECORD (
    exec_broker_code crd.ts_order_alloc.exec_broker%TYPE,
    exec_broker_name crd.cs_broker.bkr_name%TYPE,
    client_code crd.ts_order_alloc.acct_cd%TYPE,
    client_name crd.cs_fund.acct_name%TYPE,
    directed_broker crd.ts_order_alloc.directed_broker%TYPE,
    count_ticknum crd.ts_order.order_id%TYPE,
    trade_date crd.ts_order.trade_date%TYPE,
    base_cost crd.ts_order_alloc.cur_base_mkt_val%TYPE,
    total_commission crd.ts_order_alloc.commision_amt%TYPE,
    broker_history     crd.au_broker.bkr_typ_cd%TYPE
    --Declaring a variable of rec_auditdata data type
    TYPE cur_compliancetrade IS REF CURSOR
    RETURN rec_compliancetrade;
    END infy_pkg_compliance_transact;
    END OF CRD.INFY_PKG_COMPLIANCE_TRANSACTIONS
    How to call this SP from VB code with ref cursor parameter?

    I'm fairly sure that's not possible, since there's nothing in the ODBC spec to allow for ref cursors. The driver has built in support to check for ref cursors that are returned via a stored procedure call, but there's nothing built into the driver to pass one IN. Since a ref cursor can't be constructed on the client side, you'd have to have some sort of structure that allowed you to reference the ref cursor directly in order to be able to pass one back to the database.
    Since you're using VB.NET anyway, the better solution is probably just to use ODP.NET instead, which DOES allow you to reference a ref cursor directly, and there are samples that install with ODP.NET that show you how to do that.
    Greg

  • Ref cursor question

    Hi,
    I have stored proc that takes pl/sql table as IN parameter and returns a ref cursor.
    Data from pl/sql table is separated into two table type objects ... oType1 and oType2 based on some condition.
    following works fine...
    If oType1.Count > 0 then
         OPEN list_out FOR
         select col1, col2, col3, col4 ..... col20
         from TABLE(CAST(oType1 AS obj_table_t)) a,
         t1,
         t2
         where a.colvalue = t1.colvalue
         and etc....
    UNION ALL
         select col1, col2, col3, col4 ..... col20
         from TABLE(CAST(oType1 AS obj_table_t)) a,
         t3,
         t4
         where a.colvalue = t3.colvalue
         and different conditions etc....
    I have 4 UNION ALL's. Had to use this because of different where coditions.
    end if..
    The problem is with oType2......
    If oType2.Count > 0 then
    -- getting data from different database using dblink along with values from present database.
    -- resultset columns will be same as above
    -- Question is how to send these results in same refcursor.
    end if;
    Thanks for your time.

    Hi,
    I think that a plsql table is what you want and not a ref cursor. If you have a plsql table based on your user defined type you can keep assigning all the values you want to it and then pass it out of your procedure.
    null

  • 64bit OraOLEDB failed when calling stored procedure with Ref Cursor

    Hi everyone,
    I used the ADO VB sample provided with the Oracle 10g provider installation.
    But I compiled it in 64bit Visual Studio 2005 and ran on Windows 2003 x64 server.
    The function call "cmd.Execute" when it is trying to call a stored procedure which has an Out Ref Cursor parameter. The exception is
    "PLS-00306: wrong number or types arguments in call"
    I already set the property "PLSQLRSet" to true. But it doesn't help.
    The same code works if I compiled in 32 bit.
    It also works if the stored procedure does not have Ref Cursor parameter.
    I am guessing this is a bug in the 64bit Oracle provider. Anyone can confirm this please? or am I missing anything?
    Wilson

    It appears to work with 11.1.0.6.20 OLEDB provider but only for ExecuteNonQuery, I'm not able to work with Fill, and yes... in x86 works perfectly, but in x64 we are still having the ORA-06550 and PLS-00306 error.
    Our Connection string is as follows:
    "Provider=OraOLEDB.Oracle.1;OLEDB.NET=true;Password=xxxxx;Persist Security Info=True;User ID=exxxxx;Data Source=ECOR; PLSQLRSet=True"
    We are not using ODP.NET.
    Can you confirm that Fill method works with such update?

  • Ref Cursors to write to xml file

    Hi,
    I am relatively new and i am looking at what other professionals have to comment.
    I am retriveing a ref cursor in Oracle and would like to store this information in an xml file along with another variable, as it would be easier to read/edit from an xml file rather than firing the stored procedure and picking/saving the ref cursor on every occassion that is required.
    Looking for what the experts have to say about this way.
    Also, i am looking at trying to implement this.
    How does one write to an xml document from a ref cursor in Oracle 9i
    Thank You
    Any help will be appreciated.

    You can not write REF Cursors directly to an XML file. One way to write REF Cursor data to an XML file would be to popoulate the Dataset using the REF Cursor and then use the XML functionality on Dataset to generate an XML file. Another way would be create an OracleDataReader and populate the XML file yourself.

  • Is BC4J a viabl option for database with stored procedure (ref cursor) API?

    I'm about to begin a Web application development project. As foundation, we have a (Oracle) database of certain complexity that have a data access API developed with PL/SQL packages.
    This API is designed to get data through stored procedures/functions that return REF CURSOR.
    Personally I have been investigating about Oracle ADF/JSF, and a number of others J2EE technologies, and at this moment I am doubting if ADF BC are a viable option to my development team.
    I think this because I have noticed that one of the great drawback in ADF BC is the lack of simplicity to get data through stored procedures/functions that returns REF CURSORS.
    I have been looking for documentation and the only thing that I have found are two examples:
    1.- One that really do not work (fails in get data from ref cursor): ADF BC StoredProcedure Sample application.
    2.- And other published by Steve Muench in
    http://radio.weblogs.com/0118231/stories/2003/03/03/gettingAViewObjectsResultRowsFromARefCursor.html. This sample works fine.
    But, the problem with the approach of this last article is the amount (and complexity) of the code necessary to make so basic and recurrent operation as is "obtain data through a stored procedure (ref cursor)".
    Below it is the code that I have constructed to call a function that returns a ref cursor (based on steve's article).
    If this is the only way to make this (historically so basic and simple) task, then it is obvious that BC is not a viable technology to my (or I am in a mistake?), since we have about 50 stored procedures/functions to access the underlying data; that stored procedures/functions are key to development of the new application (and, still more, currently are used to anothers apps ).
    By all this, I would like consult to Oracle's people:
    1.- I really must reject BC as technology to implement this project ?
    2.- It is possible to access stored procedures in a simpler way using BC?
    3.- If the answer to 2 is NOT: in near future, the BC team has plans to give more support to the simple access to stored procedures?
    4.- If the answer to 3 is NOT: what another technology you recommend to construct my data access/business tier and still be able to using the others characteristics of ADF?
    Thank you very much for your guidelines.
    Regards, RL.
    ** And the code!!!
    ** ###   I am forced to do this for each call to a procedure???? ###
    package myrefcursor.model;
    import java.math.BigDecimal;
    import java.sql.CallableStatement;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.sql.Types;
    import oracle.jbo.JboException;
    import oracle.jbo.domain.NullValue;
    import oracle.jbo.domain.Number;
    import oracle.jbo.server.DBTransaction;
    import oracle.jbo.server.ViewObjectImpl;
    import oracle.jbo.server.ViewRowImpl;
    import oracle.jbo.server.ViewRowSetImpl;
    import oracle.jdbc.driver.OracleCallableStatement;
    import oracle.jdbc.driver.OracleTypes;
    public class TraePolizasViewImpl extends ViewObjectImpl {
        private static final String SQL = "begin ? := PKG_PRUEBA.trae_polizas(?);end;";
        private static final String COUNTSQL = "begin ? := PKG_PRUEBA.count_trae_polizas(?);end;";
        public TraePolizasViewImpl() {
        protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
            BigDecimal rut_contratante = null;
            Object[] theUserParam = null;
            System.out.println(params);
            System.out.println(params[0]);
            if (params != null)
                theUserParam = (Object[]) params[0];
            //if (theUserParam != null && theUserParam.length > 0 )
            if (! (theUserParam[1]   instanceof NullValue) )
                rut_contratante = (BigDecimal)theUserParam[1];
            storeNewResultSet(qc ,retrieveRefCursor(qc, rut_contratante));
            super.executeQueryForCollection(qc, params, numUserParams);
        protected void create() {
          getViewDef().setQuery(null);
          getViewDef().setSelectClause(null);
          setQuery(null);
        protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
          rs = getResultSet(qc);
          ViewRowImpl r = createNewRowForCollection(qc);
          try {
            populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
            populateAttributeForRow(r,1, rs.getString(2));
          catch (SQLException s) {
           throw new JboException(s);
          return r;
        protected boolean hasNextForCollection(Object qc) {
          ResultSet rs = getResultSet(qc);
          boolean nextOne = false;
          try {
            nextOne = rs.next();
            if (!nextOne) {
              setFetchCompleteForCollection(qc, true);
              rs.close();
          catch (SQLException s) {
           throw new JboException(s);
          return nextOne;
        protected void releaseUserDataForCollection(Object qc, Object rs) {
           ResultSet userDataRS = getResultSet(qc);
           if (userDataRS != null) {
            try {    userDataRS.close();    }
            catch (SQLException s) { ; }  
          super.releaseUserDataForCollection(qc, rs);
        public long getQueryHitCount(ViewRowSetImpl viewRowSet) {
          return viewRowSet.getRowCount();
        private ResultSet retrieveRefCursor(Object qc, BigDecimal rut_contratante) {
          CallableStatement st = null;
          try {
            st = getDBTransaction().createCallableStatement(SQL, DBTransaction.DEFAULT);
            st.registerOutParameter(1,OracleTypes.CURSOR);
            if (rut_contratante == null)
                st.setNull(2, Types.NUMERIC);
            else
                st.setBigDecimal(2, rut_contratante);
            st.execute();
            ResultSet rs = ((OracleCallableStatement)st).getCursor(1);
            rs.setFetchSize(getFetchSize());
            return rs ;
          catch (SQLException s) {
            throw new JboException(s);
          finally {try {st.close();} catch (SQLException s) {;}}
        private void storeNewResultSet(Object qc, ResultSet rs) {
          ResultSet existingRs = getResultSet(qc);
          if (existingRs != null) {
            try {existingRs.close();} catch (SQLException s) {;}  
          setUserDataForCollection(qc,rs);
          hasNextForCollection(qc); // Prime the pump with the first row.
        private ResultSet getResultSet(Object qc) {
            return (ResultSet)getUserDataForCollection(qc);
        private static Number nullOrNewNumber(BigDecimal b) {
             try {
               return b != null ? new Number(b) : null;
             catch (SQLException s) { ; }
             return null;
        public BigDecimal getprutcontratante() {
            return (BigDecimal)getNamedWhereClauseParam("prutcontratante");
        public void setprutcontratante(BigDecimal value) {
            setNamedWhereClauseParam("prutcontratante", value);
    }

    no?

  • Bind Variables in ref cursor

    Version details
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - ProductionBelow is the procedure where I'm using ref cursor
    CREATE OR REPLACE PROCEDURE ref_sample
    p_account_nbr     in     varchar2,
    p_ref_out          out     sys_refcursor
    IS
    BEGIN
         OPEN p_ref_out FOR
         SELECT     account_nbr,status,(
                                            CASE
                                                 WHEN status = 'Pending' THEN
                                                      req_mail_date
                                                 WHEN status IN ('Rejected','Approved') THEN
                                                      NVL(verified_mail_date,req_mail_date)
                                            END
                                            )req_mail_date ,
                                                 CASE
                                                      WHEN status = 'Pending' THEN
                                                           NULL
                                                      WHEN status IN ('Rejected','Approved') THEN
                                                           NVL(verified_user_id,req_user_id)
                                                 END
                                            )req_user_id
         FROM     X_tbl
         WHERE     account_nbr IN p_account_nbr
                   AND TRUNC(upload_date) = TRUNC(SYSDATE)
         ORDER BY upload_date DESC ;
    END;
    /My input parameter p_account_nbr looks like ('a1','a2','a3')
    Now,after knowing the importance of bind variables I'd like to make use of them in the above ref cursor.
    But,here my input parameter is a string of varying length..either I've to go for the approach suggested here
    http://asktom.oracle.com/pls/asktom/f?p=100:11:3667281145899708::::P11_QUESTION_ID:110612348061
    or
    http://www.dba-oracle.com/t_cursor_sharing.htm
    I'm not much clear with the first approach,so I'm thinking of to modify my procedure as below
    CREATE OR REPLACE PROCEDURE ref_sample
    p_account_nbr     in     varchar2,
    p_ref_out          out     sys_refcursor
    IS
    BEGIN
         alter session set cursor_sharing=force;
         OPEN p_ref_out FOR
         SELECT     account_nbr,status,(
                                            CASE
                                                 WHEN status = 'Pending' THEN
                                                      req_mail_date
                                                 WHEN status IN ('Rejected','Approved') THEN
                                                      NVL(verified_mail_date,req_mail_date)
                                            END
                                            )req_mail_date ,
                                                 CASE
                                                      WHEN status = 'Pending' THEN
                                                           NULL
                                                      WHEN status IN ('Rejected','Approved') THEN
                                                           NVL(verified_user_id,req_user_id)
                                                 END
                                            )req_user_id
         FROM     X_tbl
         WHERE     account_nbr IN p_account_nbr
                   AND TRUNC(upload_date) = TRUNC(SYSDATE)
         ORDER BY upload_date DESC ;
         alter session set cursor_sharing=exact;     
    END;
    /Please let me know if the above modified code is fine or should I use bind variables??Also let me know better approach of both.

    The correct way to do this is use an array type for the input values as in this example.
    SQL> create or replace procedure p
      2      (
      3      p_values sys.odcivarchar2list,
      4      c out sys_refcursor
      5      ) as
      6  begin
      7      open c for
      8         select object_name, owner, object_type
      9         from all_objects
    10         where object_name in (select column_value from table(p_values));
    11  end;
    12  /
    Procedure created.
    SQL> var c refcursor
    SQL> exec p (sys.odcivarchar2list('DUAL','USER_VIEWS'), :c)
    PL/SQL procedure successfully completed.
    SQL> print c
    OBJECT_NAME                    OWNER                          OBJECT_TYPE
    DUAL                           SYS                            TABLE
    DUAL                           PUBLIC                         SYNONYM
    USER_VIEWS                     SYS                            VIEW
    USER_VIEWS                     PUBLIC                         SYNONYM
    SQL> exec p (sys.odcivarchar2list('DUAL','USER_VIEWS','ALL_OBJECTS','ALL_SOURCE'), :c)
    PL/SQL procedure successfully completed.
    SQL> print c
    OBJECT_NAME                    OWNER                          OBJECT_TYPE
    DUAL                           SYS                            TABLE
    DUAL                           PUBLIC                         SYNONYM
    ALL_OBJECTS                    SYS                            VIEW
    ALL_OBJECTS                    PUBLIC                         SYNONYM
    USER_VIEWS                     SYS                            VIEW
    USER_VIEWS                     PUBLIC                         SYNONYM
    ALL_SOURCE                     SYS                            VIEW
    ALL_SOURCE                     PUBLIC                         SYNONYM
    8 rows selected.
    SQL>That and other methods are described here.
    http://tkyte.blogspot.com/2006/06/varying-in-lists.html
    You would not use dynamic SQL.

  • Using temporary tables with a ref. cursor

    I want to use a temporary table to populate certain data and then return a ref cursor fetching data from the temporary table.
    1. Will this approach work ?
    2. Do I need to drop the temporary table ? Can I drop the table as a last statement in the stored proc (remember a ref cursor based on this table is to be returned as a out parameter).
    Please help.

    1. Will this approach work ?Sort of, just like it is possible to dig a trench with a spoon. It can be done, but why can't you just write a select that returns the data without storing intermediate versions of your processing somewhere.
    2. Do I need to drop the temporary table ?No. and you shouldn't.
    Can I drop the table as a last statement in the stored proc
    (remember a ref cursor based on this table is to be returned as a out parameter).No.
    If you really need to use a temporary table, it should be created one time when the application is installed, and should never be created in code.

  • Restrictions while using ref cursor inside an xmltype

    Hi,
    Looks like that getclobVal() can't be used in select where select statement is ref cursor for xmltype.
    example
    SQL> select xmltype(cursor(select xmltype('<a>1</a>').getclobval() from dual)) from dual;
    select xmltype(cursor(select xmltype('<a>1</a>').getclobval() from dual)) from dual
    ERROR at line 1:
    ORA-03001: unimplemented feature
    ORA-22806: not an object or REF also doesn't work the following select
    SQL> select xmltype(cursor(select xmltype('<a>'||lpad('a',1,'a')||'</a>') from dual)) from dual;
    ERROR:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00234: namespace prefix
    "XMLTYPE_x0028__x0027__x003C_A_x003E__x0027__x007C__x007C_LPAD_x0028_" is not
    declared
    Error at line 4
    ORA-06512: at "SYS.XMLTYPE", line 334
    ORA-06512: at line 1DB version 10.2.0.1
    Ants
    Message was edited by:
    Ants Hindpere

    I'm not sure if it is about datatypes per se. Looks to more of a restriction of the XMLTYPE object itself:
    SQL> select cursor (select xmltype ('<A>1</A>').getclobval () a from dual) from dual
    select cursor (select xmltype ('<A>1</A>').getclobval () a from dual) from dual
    Error at line 0
    ORA-03001: unimplemented feature
    ORA-22806: not an object or REF
    but astonishingly
    SQL> select cursor (select xmlelement(A, 1).getclobval () a from dual) from dual
    Cursor (A)
    <A>1</A> 

  • REF CURSOR to Associative Array

    I have a procedure that builds up a collection (associative array / index-by table). Is there any way to hand the collection over to ODP.NET without putting the contents into a temporary table? REF CURSOR seems to fit, but I cannot find the syntax to OPEN a REF CURSOR for the collection.
    I am trying to turn the GetResourceGroup() a_Resources parameter into a ref cursor in the example below (which, as I understand it, would also hold the collection in memory until the cursor is closed).
    Alternatively, is there a direct method? I.e. is it possible to get the collection directly into a DataTable or similar?
    Any advice gratefully received,
    Peter
    TYPE RsrcRow IS RECORD
    ResourceId Resource.ResourceId%TYPE,
    ResourceName Resource.ResourceName%TYPE
    TYPE Resources IS TABLE OF RsrcRow INDEX BY VARCHAR2(80);
    PROCEDURE GetResourceGroup(
    a_ResourceType IN VARCHAR2,
    a_Resources OUT Resources
    IS
    l_LocalCollection Resources;
    BEGIN
    GetResourcesByType(a_ResourceType, l_LocalCollection);
    -- Return resource set (need to port this to ODP.NET).
    a_Resources := l_LocalCollection;
    RETURN;
    END GetResourceGroup;

    odp.net does not have collection support right now.
    PL/SQL Associative Array should be available in next release (see other forum threads)
    1. Support for Varchar2 indexes is unlikely (since OCI does not provide such functionality). Which means you can only return an C style "array" like structure at best.
    2. Your 'GetResourceGroup' need to return REF CURSOR (or other primitive type like VARCHAR2), until Associative Array become available.
    FB

  • Regarding REF cursor

    Hi all,
    Well, I am trying to find out why the REF cursor is used in the documentation .. But, I couldnt find a satisfying answer .. Can anybody pass on any link or can anyone give me the answers for the below queries
    1)what is REF cursor
    2)what's the use
    3)where to use the REF cursor
    4)why to use the REF cursor ..
    Regards

    Something more informative than this ?
    http://scarlet.ucc.nau.edu/oracle10.2.0/appdev.102/b14261/sqloperations.htm#sthref1392

Maybe you are looking for

  • Retriving an Array from an Oracle Procedure in Java

    I have a procedure in Oracle which returns an VARRAY of VARCHAR2 I am Unable to get the Array back in the Servlet in my Application..... I have tried this using normal thin driver and couldn't succed.... So I have tried with OCI driver then also i wa

  • Buffer Hit Ratio % -- Whats the right query ?

    Whats the right query to track Buffer Hit % ; Using this : prompt BUFFER HIT RATIO % prompt =============== select 100 * ((a.value+b.value)-c.value) / (a.value+b.value) "Buffer Hit Ratio" from v$sysstat a, v$sysstat b, v$sysstat c where a.statistic#

  • Record with evaser

    When I record a skype session, on playback I only get audio no video,what am I doing wrong? Does skype have a tech support, if so where is it? I paid for the download and I have a problem getting it to work properly,who can I talk to about this matte

  • People cannot hear me... but I can hear them

    I am having a problem with my phone, when people call me, I can hear them, but they cannot hear me...any suggestions.  I have restored my phone and I am still having issues.

  • Issues logging data - does not save the correct data

    I am having 2 issues: 1. I am having issues with my logging occuring at the right time. I have a few things occuring based on the state of 'Injection'. In the case of logging, the following needs to happen: When injection is 'True' nothing should occ