Spliting SDO_JOIN in two ref cursors

Hi,
What is the best/most efficient way to return two ref cursor using a SDO_JOIN?
In other words, from this example taken from the Oracle Spatial User Guide
SELECT a.gid, b.gid FROM parks a, highways b,
TABLE(SDO_JOIN('PARKS', 'SHAPE', 'HIGHWAYS', 'SHAPE',
'mask=ANYINTERACT')) c
WHERE c.rowid1 = a.rowid AND c.rowid2 = b.rowid;
I would like to have a procedure that split the result of the above Select in two ref cursors. Something like this:
PROCEDURE "GET_PARKS_HIGHWAYS"
"P_PARKS" OUT SYS_REFCURSOR,
"P_HIGHWAYS" OUT SYS_REFCURSOR
as
BEGIN
/* Here I want every Parks that interact a highway
OPEN P_PARKS FOR
SELECT * FROM PARKS WHERE ....
/* Here I want every highway that interact a park
OPEN P_HIGHWAYS FOR
SELECT * FROM HIGHWAYS WHERE ....
END
Can I do this with a single SDO_JOIN or do I have to put one in the where clause of each select?
Hope that somebody understand! If not, let me know, I will try to be clearer.
Thanks
Frederic Goulet

Hi Frederic,
You will get the complete set of answers for both questions when using the anyinteract mask, i.e. you will have in your result set:
All of the parks that interact with highways, and all of the highways that interact with parks.
If you want, you can order by a.gid, and for each park you would see all of the highways.
If you order by b.gid, for each highway you would see all the parks.
The result set is complete in both cases.
Hope this helps.

Similar Messages

  • Importing function with multiple ref cursors in Stored Procedure of Oracle 12c database Using EF6

    Hi Good day!
    I can able to import function for stored procedure of oracle db and able to add the complex type and get the output but i tried to import the procedure which having two ref cursors and unable to retrieve the column information. Only able to retrieve the
    columns of first ref cursor.  Please help me to get the result of two ref cursors which acting as out parameters.

    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

  • Link Query and Ref Cursor Query

    Hi all!!
    How can I link Query and Ref Cursor Query??
    I mean, How can I pass input parameters to the PL/SQL procedure if they are not User parameters but they come from another table??
    Thanks a lot
    F.

    I have searched the forum and this is the closest to my problem.
    Just started using ref cursors in my reports.
    The problem I am running into is that I have two ref cursor queries in my report - they each contain a column named seq_no which forms a join (in the database) .
    My report returns the correct number of records in each query, but I can't find a way to enforce the join. I've tried all the methods I can think of including combining the results into one query.
    The IDE won't let me join on a column and when I join on the group (which I make only contain the seq_no fields) that join is ignored.
    Can anyone help me on this?

  • ORA-01008 with ref cursor and dynamic sql

    When I run the follwing procedure:
    variable x refcursor
    set autoprint on
    begin
      Crosstab.pivot(p_max_cols => 4,
       p_query => 'select job, count(*) cnt, deptno, row_number() over (partition by job order by deptno) rn from scott.emp group by job, deptno',
       p_anchor => Crosstab.array('JOB'),
       p_pivot  => Crosstab.array('DEPTNO', 'CNT'),
       p_cursor => :x );
    end;I get the following error:
    ^----------------
    Statement Ignored
    set autoprint on
    begin
    adsmgr.Crosstab.pivot(p_max_cols => 4,
    p_query => 'select job, count(*) cnt, deptno, row_number() over (partition by
    p_anchor => adsmgr.Crosstab.array('JOB'),
    p_pivot => adsmgr.Crosstab.array('DEPTNO', 'CNT'),
    p_cursor => :x );
    end;
    ORA-01008: not all variables bound
    I am running this on a stored procedure as follows:
    create or replace package Crosstab
    as
        type refcursor is ref cursor;
        type array is table of varchar2(30);
        procedure pivot( p_max_cols       in number   default null,
                         p_max_cols_query in varchar2 default null,
                         p_query          in varchar2,
                         p_anchor         in array,
                         p_pivot          in array,
                         p_cursor in out refcursor );
    end;
    create or replace package body Crosstab
    as
    procedure pivot( p_max_cols          in number   default null,
                     p_max_cols_query in varchar2 default null,
                     p_query          in varchar2,
                     p_anchor         in array,
                     p_pivot          in array,
                     p_cursor in out refcursor )
    as
        l_max_cols number;
        l_query    long;
        l_cnames   array;
    begin
        -- figure out the number of columns we must support
        -- we either KNOW this or we have a query that can tell us
        if ( p_max_cols is not null )
        then
            l_max_cols := p_max_cols;
        elsif ( p_max_cols_query is not null )
        then
            execute immediate p_max_cols_query into l_max_cols;
        else
            RAISE_APPLICATION_ERROR(-20001, 'Cannot figure out max cols');
        end if;
        -- Now, construct the query that can answer the question for us...
        -- start with the C1, C2, ... CX columns:
        l_query := 'select ';
        for i in 1 .. p_anchor.count
        loop
            l_query := l_query || p_anchor(i) || ',';
        end loop;
        -- Now add in the C{x+1}... CN columns to be pivoted:
        -- the format is "max(decode(rn,1,C{X+1},null)) cx+1_1"
        for i in 1 .. l_max_cols
        loop
            for j in 1 .. p_pivot.count
            loop
                l_query := l_query ||
                    'max(decode(rn,'||i||','||
                               p_pivot(j)||',null)) ' ||
                                p_pivot(j) || '_' || i || ',';
            end loop;
        end loop;
        -- Now just add in the original query
        l_query := rtrim(l_query,',')||' from ( '||p_query||') group by ';
        -- and then the group by columns...
        for i in 1 .. p_anchor.count
        loop
            l_query := l_query || p_anchor(i) || ',';
        end loop;
        l_query := rtrim(l_query,',');
        -- and return it
        execute immediate 'alter session set cursor_sharing=force';
        open p_cursor for l_query;
        execute immediate 'alter session set cursor_sharing=exact';
    end;
    end;
    /I can see from the error message that it is ignoring the x declaration, I assume it is because it does not recognise the type refcursor from the procedure.
    How do I get it to recognise this?
    Thank you in advance

    Thank you for your help
    This is the version of Oracle I am running, so this may have something to do with that.
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    I found this on Ask Tom (http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3027089372477)
    Hello, Tom.
    I have one bind variable in a dynamic SQL expression.
    When I open cursor for this sql, it gets me to ora-01008.
    Please consider:
    Connected to:
    Oracle8i Enterprise Edition Release 8.1.7.4.1 - Production
    JServer Release 8.1.7.4.1 - Production
    SQL> declare
      2    type cur is ref cursor;
      3    res cur;
      4  begin
      5    open res for
      6    'select * from (select * from dual where :p = 1) connect by 1 = 1'
      7    using 1;
      8  end;
      9  /
    declare
    ERROR at line 1:
    ORA-01008: not all variables bound
    ORA-06512: at line 5
    SQL> declare
      2    type cur is ref cursor;
      3    res cur;
      4  begin
      5    open res for
      6    'select * from (select * from dual where :p = 1) connect by 1 = 1'
      7    using 1, 2;
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    And if I run the same thing on 10g -- all goes conversely. The first part runs ok, and the second
    part reports "ORA-01006: bind variable does not exist" (as it should be, I think). Remember, there
    is ONE bind variable in sql, not two. Is it a bug in 8i?
    What should we do to avoid this error running the same plsql program code on different Oracle
    versions?
    P.S. Thank you for your invaluable work on this site.
    Followup   June 9, 2005 - 6pm US/Eastern:
    what is the purpose of this query really?
    but it would appear to be a bug in 8i (since it should need but one).  You will have to work that
    via support. I changed the type to tarray to see if the reserved word was causing a problem.
    variable v_refcursor refcursor;
    set autoprint on;
    begin 
         crosstab.pivot (p_max_cols => 4,
                 p_query => 
                   'SELECT job, COUNT (*) cnt, deptno, ' || 
                   '       ROW_NUMBER () OVER ( ' || 
                   '          PARTITION BY job ' || 
                   '          ORDER BY deptno) rn ' || 
                   'FROM   emp ' ||
                   'GROUP BY job, deptno',
                   p_anchor => crosstab.tarray ('JOB'),
                   p_pivot => crosstab.tarray ('DEPTNO', 'CNT'),
                   p_cursor => :v_refcursor);
    end;
    /Was going to use this package as a stored procedure in forms but I not sure it's going to work now.

  • [Solved] 27.8.4 How to Create a VO on a REF CURSOR - Missing first row

    Searching the forum I found: BC4J - Get one less row from view object.
    Dive into BC4J related  --REF CURSOR (Resultset)
    The first message did not have any answers, and the second had a follow up question - still no answers though - and I thought I would try a different title.
    (This is off topic, but it would be a great help if the search results also displayed the number of replys in the thread. That way, I wouldn't have to view the messages that don't have responses.)
    (This will be deployed on a server that has the ADF for JDeveloper 10.1.2 installed, so using that version of JDeveloper to develop the app.)
    Okay, back to the problem ==>
    I created a VO from a ref cursor, using the manual as a guide. When I run a page that displays a read only table of the view object, I am missing the first row. (Always the first row!) I don't have any order set, and if I call the ref cursor in a Java program for testing, I see all rows and the count is correct.
    One other point, when I call the page, I get the following validation error:
    Validation Error
    You must correct the following error(s) before proceeding:
    * JBO-29000: Unexpected exception caught: java.lang.ClassCastException, msg=null
    * null
    I still see the table, it is just missing the first row of data.
    In my form I have first, previous set, next set , and last
    navigation buttons. If I press last then first, the error goes away. I still don't see the missing row though.
    Any guidance would be appreciated! I can post my code, but it is pretty much the same code in the AdvancedViewObjectExamples.zip in the ViewObjectOnRefCursor example. I just substituted my two package calls (getRefCursor and getRefCursorCount).
    Thanks, Ken

    Went back to a backup copy of the source. Fixed the error. Now I'm back to just not being able to see the first row of data.
    Additional Note: I had removed fields in the display. Once I truncated the ps_txn table in the schema defined by the model, the data would display (Still without the first record.)
    Are there any examples that are more in depth than the few pages in the developer guide?
    Here is the code for my VOImpl class:
    package newslinearchive.model.datamodel;
    import java.math.BigDecimal;
    import java.sql.CallableStatement;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Timestamp;
    import java.sql.Types;
    import oracle.jbo.InvalidParamException;
    import oracle.jbo.JboException;
    import oracle.jbo.domain.Date;
    import oracle.jbo.domain.Number;
    import oracle.jbo.server.DBTransaction;
    import oracle.jbo.server.QueryCollection;
    import oracle.jbo.server.SQLBuilder;
    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;
    // --- File generated by Oracle ADF Business Components Design Time.
    // --- Custom code may be added to this class.
    // --- Warning: Do not modify method signatures of generated methods.
    public class SearchRefCursorImpl extends ViewObjectImpl {
    * This is the default constructor (do not remove)
    public SearchRefCursorImpl() {
    * Overridden framework method.
    * Executed when the framework needs to issue the database query for
    * the query collection based on this view object. One view object
    * can produce many related result sets, each potentially the result
    * of different bind variable values. If the rowset in query is involved
    * in a framework-coordinated master/detail viewlink, then the params array
    * will contain one or more framework-supplied bind parameters. If there
    * are any user-supplied bind parameter values, they will PRECEED the
    * framework-supplied bind variable values in the params array, and the
    * number of user parameters will be indicated by the value of the
    * numUserParams argument.
    protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
    storeNewResultSet(qc,retrieveRefCursor(qc,params));
    super.executeQueryForCollection(qc, params, numUserParams);
    * Overridden framework method.
    * Wipe out all traces of a built-in query for this VO
    protected void create() {
    getViewDef().setQuery(null);
    getViewDef().setSelectClause(null);
    setQuery(null);
    * Overridden framework method.
    * The role of this method is to "fetch", populate, and return a single row
    * from the datasource by calling createNewRowForCollection() and populating
    * its attributes using populateAttributeForRow().
    protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
    * We ignore the JDBC ResultSet passed by the framework (null anyway) and
    * use the resultset that we've stored in the query-collection-private
    * user data storage
    rs = getResultSet(qc);
    * Create a new row to populate
    ViewRowImpl r = createNewRowForCollection(qc);
    try {
    * Populate new row by attribute slot number for current row in Result Set
    // populateAttributeForRow(r,0, rs.getLong(1));
    // populateAttributeForRow(r,1, rs.getString(2));
    // populateAttributeForRow(r,2, rs.getString(3));
    // MASTERID NOT NULL NUMBER
    populateAttributeForRow(r,0, rs.getBigDecimal(1));
    //ID NOT NULL NUMBER
    populateAttributeForRow(r,1, rs.getBigDecimal(2));
    // CAID NOT NULL NUMBER
    populateAttributeForRow(r,2, rs.getBigDecimal(3));
    // LANGUAGE NOT NULL VARCHAR2(30)
    populateAttributeForRow(r,3, rs.getString(4));
    // IS_CURRENT_VERSION NOT NULL NUMBER(1)
    populateAttributeForRow(r,4, rs.getBigDecimal(5));
    // FOLDER_ID NOT NULL NUMBER
    populateAttributeForRow(r,5, rs.getBigDecimal(6));
    // FOLDER_REGION_ID NOT NULL NUMBER
    populateAttributeForRow(r,6, rs.getBigDecimal(7));
    // NAME NOT NULL VARCHAR2(256)
    populateAttributeForRow(r,7, rs.getString(8));
    // DISPLAY_NAME VARCHAR2(256)
    populateAttributeForRow(r,8, rs.getString(9));
    // ITEMTYPE NOT NULL VARCHAR2(30)
    populateAttributeForRow(r,9, rs.getString(10));
    // SUBTYPE VARCHAR2(40)
    populateAttributeForRow(r,10, rs.getString(11));
    // SUBTYPE_CAID NUMBER
    populateAttributeForRow(r,11, rs.getBigDecimal(12));
    // PARENT_ITEM_ID NUMBER
    populateAttributeForRow(r,12, rs.getBigDecimal(13));
    // CATEGORY_ID NUMBER
    populateAttributeForRow(r,13, rs.getBigDecimal(14));
    // CATEGORY_CAID NUMBER
    populateAttributeForRow(r,14, rs.getBigDecimal(15));
    // AUTHOR VARCHAR2(50)
    populateAttributeForRow(r,15, rs.getString(16));
    // DESCRIPTION VARCHAR2(2000)
    populateAttributeForRow(r,16, rs.getString(17));
    // PUBLISH_DATE NOT NULL DATE
    populateAttributeForRow(r,17, rs.getDate(18));
    // EXPIREMODE VARCHAR2(90)
    populateAttributeForRow(r,18, rs.getString(19));
    // EXPIRENUMBER NUMBER
    populateAttributeForRow(r,19, rs.getBigDecimal(20));
    // EXPIREDATE DATE
    populateAttributeForRow(r,20, rs.getDate(21));
    // IMAGE VARCHAR2(350)
    populateAttributeForRow(r,21, rs.getString(22));
    // KEYWORDS VARCHAR2(2000)
    populateAttributeForRow(r,22, rs.getString(23));
    // URL VARCHAR2(4000)
    populateAttributeForRow(r,23, rs.getString(24));
    // FILENAME VARCHAR2(350)
    populateAttributeForRow(r,24, rs.getString(25));
    // TEXT CLOB()
    populateAttributeForRow(r,25, rs.getClob(26));
    // FOLDER_LINK_ID NUMBER
    populateAttributeForRow(r,26, rs.getBigDecimal(27));
    // FOLDER_LINK_CAID NUMBER
    populateAttributeForRow(r,27, rs.getBigDecimal(28));
    // ACTIVE NOT NULL NUMBER(1)
    populateAttributeForRow(r,28, rs.getBigDecimal(29));
    // CAN_BE_CHECKEDOUT NUMBER(1)
    populateAttributeForRow(r,29, rs.getBigDecimal(30));
    // IS_ITEM_CHECKEDOUT NUMBER(1)
    populateAttributeForRow(r,30, rs.getBigDecimal(31));
    // CHECKER_USERNAME VARCHAR2(256)
    populateAttributeForRow(r,31, rs.getString(32));
    // CHECKOUT_DATE DATE
    populateAttributeForRow(r,32, rs.getDate(33));
    // FULLSCREEN NOT NULL NUMBER(1)
    populateAttributeForRow(r,33, rs.getBigDecimal(34));
    // INPLACE NOT NULL NUMBER(1)
    populateAttributeForRow(r,34, rs.getBigDecimal(35));
    // CREATEDATE NOT NULL DATE
    populateAttributeForRow(r,35, rs.getDate(36));
    // CREATOR NOT NULL VARCHAR2(256)
    populateAttributeForRow(r,36, rs.getString(37));
    // UPDATEDATE DATE
    populateAttributeForRow(r,37, rs.getDate(38));
    // UPDATOR VARCHAR2(256)
    populateAttributeForRow(r,38, rs.getString(39));
    // SECURITY VARCHAR2(25)
    populateAttributeForRow(r,39, rs.getString(40));
    // VISIBLE NOT NULL NUMBER(1)
    populateAttributeForRow(r,40, rs.getBigDecimal(41));
    // SEQUENCE NOT NULL NUMBER
    populateAttributeForRow(r,41, rs.getBigDecimal(42));
    // CATEGORY_SEQUENCE NOT NULL NUMBER
    populateAttributeForRow(r,42, rs.getBigDecimal(43));
    // AUTHOR_SEQUENCE NOT NULL NUMBER
    populateAttributeForRow(r,43, rs.getBigDecimal(44));
    // CREATE_DATE_SEQUENCE NOT NULL NUMBER
    populateAttributeForRow(r,44, rs.getBigDecimal(45));
    // ITEMTYPE_SEQUENCE NOT NULL NUMBER
    populateAttributeForRow(r,45, rs.getBigDecimal(46));
    catch (SQLException s) {
    throw new JboException(s);
    return r;
    * Overridden framework method.
    * Return true if the datasource has at least one more record to fetch.
    protected boolean hasNextForCollection(Object qc) {
    ResultSet rs = getResultSet(qc);
    boolean nextOne = false;
    try {
    nextOne = rs.next();
    * When were at the end of the result set, mark the query collection
    * as "FetchComplete".
    if (!nextOne) {
    setFetchCompleteForCollection(qc, true);
    * Close the result set, we're done with it
    rs.close();
    catch (SQLException s) {
    throw new JboException(s);
    return nextOne;
    * Overridden framework method.
    * The framework gives us a chance to clean up any resources related
    * to the datasource when a query collection is done being used.
    protected void releaseUserDataForCollection(Object qc, Object rs) {
    * Ignore the ResultSet passed in since we've created our own.
    * Fetch the ResultSet from the User-Data context instead
    ResultSet userDataRS = getResultSet(qc);
    if (userDataRS != null) {
    try {
    userDataRS.close();
    catch (SQLException s) {
    /* Ignore */
    super.releaseUserDataForCollection(qc, rs);
    * Overridden framework method
    * Return the number of rows that would be returned by executing
    * the query implied by the datasource. This gives the developer a
    * chance to perform a fast count of the rows that would be retrieved
    * if all rows were fetched from the database. In the default implementation
    * the framework will perform a SELECT COUNT(*) FROM (...) wrapper query
    * to let the database return the count. This count might only be an estimate
    * depending on how resource-intensive it would be to actually count the rows.
    public long getQueryHitCount(ViewRowSetImpl viewRowSet) {
    Long result = (Long)callStoredFunction(NUMBER,
    "PORTAL.SEARCH_REFCURSOR.getRefCursorCount",
    viewRowSet.getParameters(true));
    return result.longValue();
    // ------------- PRIVATE METHODS ----------------
    * Return a JDBC ResultSet representing the REF CURSOR return
    * value from our stored package function.
    * new Object[]{getNamedBindParamValue("Email",params)}
    private ResultSet retrieveRefCursor(Object qc, Object[] params) {
    ResultSet rs = (ResultSet)callStoredFunction(OracleTypes.CURSOR,
    "PORTAL.SEARCH_REFCURSOR.getRefCursor",
    null);
    return rs ;
    private Object getNamedBindParamValue(String varName, Object[] params) {
    Object result = null;
    if (getBindingStyle() == SQLBuilder.BINDING_STYLE_ORACLE_NAME) {
    if (params != null) {
    for (Object param : params) {
    Object[] nameValue = (Object[])param;
    String name = (String)nameValue[0];
    if (name.equals(varName)) {
    return (String)nameValue[1];
    throw new JboException("No bind variable named '"+varName+"'");
    * Store a new result set in the query-collection-private user-data context
    private void storeNewResultSet(Object qc, ResultSet rs) {
    ResultSet existingRs = getResultSet(qc);
    // If this query collection is getting reused, close out any previous rowset
    if (existingRs != null) {
    try {existingRs.close();} catch (SQLException s) {}
    setUserDataForCollection(qc,rs);
    hasNextForCollection(qc); // Prime the pump with the first row.
    * Retrieve the result set wrapper from the query-collection user-data
    private ResultSet getResultSet(Object qc) {
    return (ResultSet)getUserDataForCollection(qc);
    * Return either null or a new oracle.jbo.domain.Date
    private static Date nullOrNewDate(Timestamp t) {
    return t != null ? new Date(t) : null;
    * Return either null or a new oracle.jbo.domain.Number
    private static Number nullOrNewNumber(BigDecimal b) {
    try {
    return b != null ? new Number(b) : null;
    catch (SQLException s) { }
    return null;
    //----------------[ Begin Helper Code ]------------------------------
    public static int NUMBER = Types.NUMERIC;
    public static int DATE = Types.DATE;
    public static int VARCHAR2 = Types.VARCHAR;
    public static int CLOB = Types.CLOB;
    * Simplifies calling a stored function with bind variables
    * You can use the NUMBER, DATE, and VARCHAR2 constants in this
    * class to indicate the function return type for these three common types,
    * otherwise use one of the JDBC types in the java.sql.Types class.
    * NOTE: If you want to invoke a stored procedure without any bind variables
    * ==== then you can just use the basic getDBTransaction().executeCommand()
    * @param sqlReturnType JDBC datatype constant of function return value
    * @param stmt stored function statement
    * @param bindVars Object array of parameters
    * @return function return value as an Object
    protected Object callStoredFunction(int sqlReturnType, String stmt,
    Object[] bindVars) {
    CallableStatement st = null;
    try {
    st = getDBTransaction().createCallableStatement("begin ? := " + stmt +
    "; end;", 0);
    st.registerOutParameter(1, sqlReturnType);
    if (bindVars != null) {
    for (int z = 0; z < bindVars.length; z++) {
    st.setObject(z + 2, bindVars[z]);
    st.executeUpdate();
    return st.getObject(1);
    catch (SQLException e) {
    throw new JboException(e);
    finally {
    if (st != null) {
    try {
    st.close();
    catch (SQLException e) {}
    /**Gets the bind variable value for Email
    public String getEmail() {
    return (String)getNamedWhereClauseParam("Email");
    /**Sets <code>value</code> for bind variable Email
    public void setEmail(String value) {
    setNamedWhereClauseParam("Email", value);
    /**getEstimatedRowCount - overridden for custom java data source support.
    public long getEstimatedRowCount() {
    long value = super.getEstimatedRowCount();
    return value;
    Thanks, Ken

  • Reports On Ref Cursor - Patch download and Installation issue

    I have made a dummy report based on ref cursor.
    Code
    DB
    ==
    create or replace PACKAGE my_cursors IS
    type emp_rc_strong is ref cursor return emp%rowtype;
    type emp_rc_weak is ref cursor;
    function fn_RefCur(p_deptno number) return my_cursors.emp_rc_strong;
    END;
    create or replace PACKAGE body my_cursors IS
    function fn_RefCur(p_deptno number) return my_cursors.emp_rc_strong is
    emp_data_strong my_cursors.emp_rc_strong;
    emp_data_weak my_cursors.emp_rc_weak;
    begin
    open emp_data_weak for 'select * from emp where deptno = :1' using p_deptno;
    emp_data_strong := emp_data_weak;
    return emp_data_strong;
    end;
    Report Builder
    =========
    Inside ref_cursor query object
    function QR_1RefCurDS return my_cursors.emp_rc_strong is
    emp_data_weak my_cursors.emp_rc_weak;
    begin
    emp_data_strong := my_cursors.fn_RefCur(:p_deptno);
    return emp_data_strong;
    end;
    While running it's giving following error
    REP-0065: Virtual Memory System Error
    REP-0200: Cannot allocate enough memory cavaa 22
    So, when I searched on net, I found
    Cause
    This is a known Oracle Reports bug for MS Windows Platform.
    Bug 5584001 DYNAMIC REF CURSORS DON'T WORK IN VERSION 10.1.2.0.2 REPORTS BUILDER
    Solution
    To implement the solution, two one-off patches should be applied to
    Oracle Reports %ORACLE_HOME% Please execute the following steps:
    1. Download the following two one-off patches from Metalink:
    One-off Patch 4505133
    One-off Patch 5634746
    But since I am a home user, so how I can download these patches and test.

    You can't without metalink access.

  • How to write REF-CURSOR Query in Oracle Reports

    Hello Guys!!
    I have a form in which you can select regions/divisions/locations etc by the use of check boxes. And the selected values will be inserted into a table, and based on the selected values of the table the report is run.
    The issue I have is with the query inside the Oracle reports(attached to this file).
    The query works fine until the last two EXISTS conditions.
    IF a region exists In the table report_param then it works fine but if there are no divisions in it , then the query returns no values, which is not correct.
    Someone has advised me to use a ref-cursor query inside reports tool, which I am not aware off. So, anykind of suggestions or advises are welcome. Please let me know about it as it is very urgent issue for me. Anykind of help would be greatly
    appreciated.
    Thanks,
    Vishal
    -------------------------------------------------------Query in Oracle Reports---------------------------------------------------------
    select c.key_segment, p.supplier_id,
    decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>')) COL_NM,
    sum(a.ext_price) sales_dols,
    sum(comp_allow_pkg.get_comp_allow_stddiv(a.control_loc_id, a.product_id, a.sold_to_customer_id,
    a.doc_dt, a.ext_price, a.units)) cust_reb_dols,
    sum(a.units) units,
    sum(a.ext_cost) cost_dols
    from sales a, key_segment_plns c, product p, rep_wrtr_dw_cust h
    where a.doc_dt between :in_start_dt and :in_end_dt
    and a.customer_oc = h.control_loc_id
    and a.sold_to_customer_id = h.sold_to_cust_id
    and a.ship_to_customer_id = h.ship_to_cust_id
    and ((:in_dg_cd = 'B' and h.dealer_grower_cd in ('D','G')) or h.dealer_grower_cd = :in_dg_cd)
    and a.product_id = p.product_id
    and p.product_gl_class_cd = 'CHEM'
    and p.product_legal_name = c.product_legal_name
    and c.key_segment in ('GLYPHOSATE','PLANT HEALTH/RUST FUNGICIDES','PYRETHROIDS','STROBI FUNGICIDES')--&IN_KEY_SEGMENTS
    -- and (:in_oc = 'ALL' or (a.control_loc_id in (select control_loc from control_loc_comb_ocs where control_loc_comb = :in_oc)))
    -- SALES DATA FILTERS TO MATCH ACCUM_SALES_DG_MV
    and a.sale_type_cd in ('02','08')
    and a.document_type_cd in ('I','C','D')
    and (substr(a.product_id,-1) in ('0','1') OR nvl(upper(trim(p.product_brand)),'X') = 'TECH FEE')
    and a.units <> 0
    and a.unit_cost <> 0
    and a.unit_price <> 0
    -- NEW FILTERS ADDED 9/11/07: LOCATION(BRANCH), BUSINESS TYPE, RSM/ASM/REP
    and ((:in_loc = 'ALL') or (nvl(a.warehouse_id,'<blank>') in (SELECT param_value
    FROM report_param
    WHERE report_id = :IN_REPORT_ID
    AND session_id= :IN_SESSION_ID
    AND USER_ID = :IN_USER_ID
    AND param_name='LOCATION_TYPE')))
    and ((:in_uhs_ag = 'ALL') or (:in_uhs_ag = 'NA' and p.product_uhs_ag != 'A') or (p.product_uhs_ag = :in_uhs_ag))
    and ((:in_sales_rep = 'ALL') or (nvl(a.territory_id,'<blank>') in (SELECT param_value
    FROM report_param
    WHERE report_id = :IN_REPORT_ID
    AND session_id= :IN_SESSION_ID
    AND USER_ID = :IN_USER_ID
    AND param_name='SALES_REP_TYPE')))
    and EXISTS
    (SELECT '1'
    FROM locations l, report_param rp
    WHERE rp.report_id = :IN_REPORT_ID
    AND rp.session_id= :IN_SESSION_ID
    AND rp.user_id = :IN_USER_ID
    AND rp.param_value = l.region
    AND rp.param_name = 'REGION_TYPE'
    AND a.warehouse_id = L.ARS_LOCATION)
    and EXISTS
    (SELECT '1'
    FROM locations l, report_param rp
    WHERE rp.report_id = :IN_REPORT_ID
    AND rp.session_id= :IN_SESSION_ID
    AND rp.user_id = :IN_USER_ID
    AND rp.param_value = l.region
    AND rp.param_name = 'DIVISION_TYPE'
    AND a.warehouse_id = L.ARS_LOCATION)
    group by c.key_segment, P.supplier_id,
    decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>'))

    Hi,
    I need your help to create a report using Ref-Cursor. please see the below thread
    Report using ref cursor or dynamic Sql

  • Reports 3.0, Ref Cursor from stored procedure

    I have a problem trying to use Ref Cursor as datasource (i.e.
    Ref Cursor Query) in Reports 3.0
    I have created a stored package with a function which returns
    Ref Cursor.
    That function just opens the cursor and returns it to the
    calling module.
    Reports recognizes returned cursor - it creates a group for that
    query, with all columns, than I built
    a layout model - everything is OK on that stage.
    During the execution of that report (from previewer or using
    Reports Runtime) I got an error message like that:
    REP-0065 Virtual Memory System Error
    REP-0200 Cannot allocate enough memory cavaa22
    Error's description does not correspond the reality :) - there
    is enough virtual & physical memory according to
    Task Manager information.
    So, that does not work when this package is stored one.
    When I create the package on the client side - in Reports -
    everything works just fine.
    Cursor is opened with a very simple query, selecting records
    from the very simple table having only one record.
    There is no code written which closes that cursor or fetches the
    records.
    Client platform: WinNT 4.0 SP3
    Oracle Reports: 3.0.5.8.0
    Oracle Server: Oracle8 8.0.5.0.0 (and I tried also on Oracle7
    7.3.4.3.0)
    Thanx.
    null

    Sara,
    GTT (Global Temporary Tables) in Oracle work a different way compared to SQL Server and Informix. There you can create temporary tables on the fly and drop them on the fly.
    Here you should (note, you don't have to, but, best practice says that you should) create the table using the syntax...
    create global temporary table.....
    Once you create it, even though it looks like persistent table, it's not. It will have it's own individual data PER SESSION . You have two types of GTTs:
    ON COMMIT PRESERVE ROWS and ON COMMIT DELETE ROWS (they work in slightly different way).
    Look up GTTs here:
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14231/tables.htm#sthref2213
    HTH,
    Rahul

  • Help on CAST function, defining TYPE TABLE and using a REF cursor

    Hi,
    I have written a procedure (lookup) inside a package (lookup_pkg) as shown below.
    Procedure has an output variable of type PL/SQL TABLE which is defined in the package.
    I want to write a wrapper procedure lookupref to the procedure lookup to return a ref cursor.
    CREATE OR REPLACE PACKAGE lookup_pkg AS
    TYPE t_lookup_refcur IS REF CURSOR;
    CURSOR c_lookup IS
         Select columns1,2,3,....100
                   FROM A, B, C, D, E
                   WHERE ROWNUM < 1;
    TYPE t_lookup IS TABLE OF c_lookup%ROWTYPE;
    Procedure lookup(id Number, o_lookup OUT t_lookup);
    End lookup_pkg;
    CREATE OR REPLACE PACKAGE BODY lookup_pkg As
    Procedure lookup(id Number, o_lookup OUT t_lookup) IS
    BEGIN
    END lookup;
    Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
    o_lookup t_lookup;
    BEGIN
    lookup(id, o_lookup t_lookup);
    OPEN t_lookup_refcur FOR
    SELECT *
         FROM TABLE(CAST(o_lookup AS t_lookup));
    Exception
    End lookupref;
    END lookup_pkg;
    When I compile this procedure, I am getting invalid datatype Oracle error and
    cursor points the datatype t_lookup in the CAST function.
    1. Can anyone tell me what is wrong in this. Can I convert a PL/SQL collection (pl/sql table in this case) to PL/SQL datatype table or does it need to be a SQL datatype only (which is created as a type in database).
    Also, to resolve this error, I have created a SQL type and table type instead of PL/SQL table in the package as shown below.
    create or replace type t_lookuprec as object
                   (Select columns1,2,3,....100
                   FROM A, B, C, D, E
                   WHERE ROWNUM < 1);
    create or replace type t_lookup_tab AS table of t_lookuprec;
    CREATE OR REPLACE PACKAGE BODY lookup_pkg As
    Procedure lookup(id Number, o_lookup OUT t_lookup) IS
    BEGIN
    END lookup;
    Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
    o_lookup t_lookup;
    BEGIN
    lookup(id, o_lookup t_lookup);
    OPEN t_lookup_refcur FOR
    SELECT *
         FROM TABLE(CAST(o_lookup AS t_lookup_tab));
    Exception
    End lookupref;
    END lookup_pkg;
    When I compile this package, I am getting "PL/SQL: ORA-22800: invalid user-defined type" Oracle error and
    points the datatype t_lookup_tab in the CAST function.
    2. Can anyone tell me what is wrong. Can I create a type with a select statement and create a table type using type created earlier?
    I have checked the all_types view and found that
    value for Incomplete column for these two types are YES.
    3. What does that mean?
    Any suggestions and help is appreciated.
    Thanks
    Srinivas

    create or replace type t_lookuprec as object
    (Select columns1,2,3,....100
    FROM A, B, C, D, E
    WHERE ROWNUM < 1);You are correct that you need to use CREATE TYPE to use the type in SQL.
    However unless I am mistaken you appear to have invented your own syntax for CREATE TYPE, suggest you refer to Oracle documentation.

  • Using CRUD procedures to update data and ref cursors to return data

    Hi:
    I am currently evaluating Apex 3.x to replace an existing app that uses lots of procedures to update and return data.
    1. Is it possible to return data from a function that returns a cursor (or from a procedure that has an input/output ref cursor parameter for that matter) ? Example: Let's say I have the following function in a package:
    function get_data return sys_refcursor
    is
    l_cursor sys_refcursor;
    begin
    open l_cursor for select sysdate as field from sys.dual;
    return l_cursor;
    end;
    Can I add a page with a table that is populated based on this function? Based on my research it is not possible, but I want an APEX expert to confirm it
    2. The old application uses CRUD procedures to update date, that is for each table there are 3 procedures, insert update and delete. Question: is it possible to channel all the update, inserts and deletes through these procedures? Furthermore, in lots of cases I use sequences to populate the primary keys, and the new value is returned as output parameter. Can I retrieve the output value and use it maybe in the next page I am branching to?
    In the samples that I've seen the same form is used for insert and update. How do I distinguish between the two modes?
    3. Can you please point me to some samples that show how to do 1 & 2. The standard samples that I've seen use the automatic row processing.
    4. Could you please recommend some good books about Apex or HTML db? I found the documentation unintuitive. It is hard to picture quickly how things tie together by reading this documention. I wish the documentation was more task oriented and presented 'how to...' implement generic patterns used in web apps.
    Thank you in advance

    Hi guys
    Check out the last 2 posts in this thread for ideas on how to implement 1.
    Report on user data from LDAP
    Varad

  • How to put a collection into a Ref Cursor?

    Hi,
    I am trying to create a procedure (inside a package) which fills a collection and I need to fill a ref cursor (out parameter) with this collection. I can fill the collection but I how can I fill the ref cursor? I am receiving the message "PL/SQL: ORA-00902: invalid datatype" (Highlighted below as comments)
    I have a limitation: I am not allowed to create any kind of objects at the database schema level, so I have to create them inside the package. I'm writting it with SQL Tools 1.4, I'm also not allowed to do this in SQL+.
    This is the code of the package. The cursors' selects were simplified just because they are not the problem, but their structure is like follows below.
    CREATE OR REPLACE PACKAGE U3.PKG_TESTE AS
    TYPE REC_TYPE IS RECORD(
    COL1 VARCHAR2(50) ,
    COL2 VARCHAR2(100) ,
    COL3 VARCHAR2(20) ,
    COL4 VARCHAR2(30) ,
    COL5 VARCHAR2(100) ,
    COL6 VARCHAR2(50) ,
    COL7 NUMBER(3) ,
    COL8 VARCHAR2(30) ,
    COL9 VARCHAR2(16) ,
    COL10 VARCHAR2(50) ,
    COL11 NUMBER(4) ,
    COL12 VARCHAR2(40)
    TYPE REC_TYPE_LIST IS TABLE OF REC_TYPE
    INDEX BY BINARY_INTEGER;
    TYPE C_RESULTSET IS REF CURSOR;
    VAR_TAB_TESTE     REC_TYPE_LIST;
    PROCEDURE     Z_REC_INSTANCE
    pUSER_SYS_CODE VARCHAR2,
    pSYS_SEG_CODE VARCHAR2,
    pComplFiltro VARCHAR2,
    pCodInter NUMBER,
    cResultset out C_RESULTSET
    END PKG_TESTE ;
    CREATE OR REPLACE PACKAGE BODY U3.PKG_TESTE
    AS
    PROCEDURE Z_REC_INSTANCE
    pUSER_SYS_CODE varchar2,
    pSYS_SEG_CODE varchar2,
    pComplFiltro varchar2,
    pCodInter number
    AS
    cursor cur1 is
    select 'A' COL1, 'B' COL2, 'C' COL3, 'D' COL4, 'E' COL5,
    'F' COL6, 'G' COL7, 'H' COL8
    FROM DUAL;
    regCur1 cur1%rowtype;
    cursor cur2 is
    SELECT 'I' C1, 'J' C2, 'K' C3, 'L' C4
    FROM DUAL;
    regCur2 cur2%rowtype;
    varSQL varchar2(4000);
    varCOL10s varchar2(100);
    varFiltroAtrib varchar2(100);
    varCount number(10);
    BEGIN
    varCount := 1;
    open cur1;
    Loop
    fetch cur1 into regCur1;
    exit when cur1%notfound;
    open cur2;
    Loop
    fetch cur2 into regCur2;
    exit when cur2%notfound;
    VAR_TAB_TESTE(varCount).COL1 := regCur1.COL1;
    VAR_TAB_TESTE(varCount).COL2 := regCur1.COL2;
    VAR_TAB_TESTE(varCount).COL3 := regCur1.COL3;
    VAR_TAB_TESTE(varCount).COL4 := regCur1.COL4;
    VAR_TAB_TESTE(varCount).COL5 := regCur1.COL5;
    VAR_TAB_TESTE(varCount).COL6 := regCur1.COL6;
    VAR_TAB_TESTE(varCount).COL7 := regCur1.COL7;
    VAR_TAB_TESTE(varCount).COL8 := regCur1.COL8;
    VAR_TAB_TESTE(varCount).COL9 := regCur2.C1;
    VAR_TAB_TESTE(varCount).COL10 := regCur2.C2;
    VAR_TAB_TESTE(varCount).COL11 := regCur2.C3;
    VAR_TAB_TESTE(varCount).COL12 := regCur2.C4;
    varCount := varCount + 1;
    end Loop;
    end Loop;
    -- I'd like to do something like this:
    -- c_resultset := select * from var_tab_teste;
    -- but i don't know how to put the records of the type on the ref cursor,
    -- probably because I don't know how to select them
    -- pl/sql: ora-00902: invalid datatype
    for varCount in (select COL1 from table( CAST ( VAR_TAB_TESTE AS REC_TYPE_LIST ) ))
    loop
    dbms_output.put('WORKS');
    end loop;
    END Z_REC_INSTANCE;
    END PKG_TESTE;
    SHOW     ERR     PACKAGE          PKG_TESTE;
    SHOW     ERR     PACKAGE BODY     PKG_TESTE;
    SHOW     ERR     PROCEDURE     PKG_TESTE.Z_REC_INSTANCE;
    I'm using:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Thanks in advance.

    I don't have the exact version but in 9iOK I lied, I found a 9i instance ;-)
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    JServer Release 9.2.0.7.0 - Production
    SQL> CREATE TABLE table_name (column_name VARCHAR2 (30));
    Table created.
    SQL> INSERT INTO table_name VALUES ('value one');
    1 row created.
    SQL> INSERT INTO table_name VALUES ('value two');
    1 row created.
    SQL> COMMIT;
    Commit complete.
    SQL> CREATE OR REPLACE PACKAGE package_name
      2  AS
      3     TYPE collection_type_name IS TABLE OF table_name%ROWTYPE;
      4
      5     FUNCTION function_name
      6        RETURN collection_type_name PIPELINED;
      7  END package_name;
      8  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY package_name
      2  AS
      3     FUNCTION function_name
      4        RETURN collection_type_name PIPELINED
      5     IS
      6     BEGIN
      7        FOR record_name IN (SELECT column_name
      8                            FROM   table_name) LOOP
      9           PIPE ROW (record_name);
    10        END LOOP;
    11
    12        RETURN;
    13     END function_name;
    14  END package_name;
    15  /
    Package body created.
    SQL> VARIABLE variable_name REFCURSOR;
    SQL> BEGIN
      2     OPEN :variable_name FOR
      3        SELECT column_name
      4        FROM   TABLE (package_name.function_name);
      5  END;
      6  /
    PL/SQL procedure successfully completed.
    SQL> PRINT variable_name;
    COLUMN_NAME
    value one
    value two
    SQL>I recommend though that you test this thoroughly. There were bugs with this approach when it was newly introduced that prevented you from dropping the package.

  • How to include an out param of a stored proc called inside a ref cursor...????

    I have a stored proc that is defined as
    CREATE or REPLACE
    PROCEDURE ABC
    (linkid IN CHAR,
    Year_in IN DATE,
    Method_in IN CHAR,
    Date_out OUT DATE,
    average_out OUT NUMBER)
    is
    begin
    end;
    another partially completed stored proc that returns a ref
    cursor defined as follows:
    create or replace package zzz
    as
    type cursorType is ref cursor;
    end;
    create or replace function test return zzz.cursortype
    as
    date_OUT date;
    Average_OUT number;
    l_cursor zzz.cursorType;
    CURSOR temp_cur is
    SELECT l.linkid, L.routenumber, ABC(l.linkid,
    to_date('01/01/2000', 'mm/dd/yyyy'),
    '2',
    date_OUT,
    average_OUT)
    FROM LINK l
    WHERE l.LINKID <= '010999';
    begin
    open temp_cur;
    end;
    inside test (which I need help completing), how can I refer to
    the date_out and the average_out params returned by ABC() so
    that these values are in turn passed to the cursortype defined
    in package zzz?
    Thanks in advance.

    Try rewriting your abc proceudre as two functions, abc1 and
    abc2, and rewriting your test function as a test procedure. See
    if you can fill in the blanks prefaced by hyphens -- in the
    following code:
    CREATE OR REPLACE FUNCTION abc1
      (linkid      IN  CHAR,
       year_in     IN  DATE,
       method_in   IN  CHAR)
      RETURN DATE
    IS
      date_out DATE;
    BEGIN
      SELECT   --
      INTO     date_out
      FROM     --
      WHERE    --;
      --or
      date_out := --;
      RETURN date_out;
    END abc1;
    CREATE OR REPLACE FUNCTION abc2
      (linkid      IN  CHAR,
       year_in     IN  DATE,
       method_in   IN  CHAR)
      RETURN NUMBER
    IS
      average_out NUMBER;
    BEGIN
      SELECT   AVG (--)
      INTO     average_out
      FROM     --
      WHERE    --
      GROUP BY --;
      --or
      average_out := --;
      RETURN average_out;
    END abc2;
    CREATE OR REPLACE PACKAGE zzz
    AS
      TYPE cursortype IS REF CURSOR;
      PROCEDURE test
        (temp_cur OUT cursortype);
    END zzz;
    CREATE OR REPLACE PACKAGE BODY zzz
    AS
      PROCEDURE test
        (temp_cur OUT cursortype)
      IS
      BEGIN
        OPEN temp_cur
        FOR
        SELECT l.linkid,
               l.routenumber,
               abc1 (l.linkid,
                    TO_DATE ('01/01/2000', 'mm/dd/yyyy'),
                    '2'),
               abc2 (l.linkid,
                    TO_DATE ('01/01/2000', 'mm/dd/yyyy'),
                    '2')
        FROM   link l
        WHERE  l.linkid <= '010999';
      END test;
    END zzz;
    SQL> VARIABLE g_ref REFCURSOR;
    SQL> EXEC zzz.test (:g_ref);
    SQL> PRINT g_ref

  • Execute store procedure( in Id, in out RefCursor), and data fetched in ref cursor should be sent out as excel sheet.

    I am trying to make a ssis package that get the data calling the store proc with two param one is ID and other is Sys_refcursor. Say Store Proc as ListName(Id int, myCur sys_refcursor), which gets the datas with the conditions inside it.
    REATE OR REPLACE PROCEDURE schemaName.LISTNAME (P_ID  IN INT, LST_NAME_REFCUR   IN OUT SYS_REFCURSOR)
    IS
    P_NAMESOURCE_ID INT;
    BEGIN
        SELECT SOURCE_ID INTO P_NAMESOURCE_ID FROM SEARCHING_TABLE ST WHERE ST.ID = P_ID;           
                   IF (P_NAMESOURCE_ID=1)
                   THEN
                      OPEN LST_SOURCE_REFCUR FOR 
                            SELECT ST.ID,
                                   ST.TRANSACTION_DATE AS TRAN_DATE,
              IF (P_NAMESOURCE_ID=1)
                   THEN 
                      OPEN LST_SOURCE_REFCUR FOR             ....     
    then i need to get the data from that refcursor and fetch those data to excel sheet to a virtual directory.
    Any help would be appreciated. I am new to SSIS. and i need to do this assignment this friday. 

    Hi 11srk,
    To fetch data from Oracle store procedure, you can use a Script Component as source to call the Oracle stored procedure by using System.Data.OracleClient OracleDataReader, and get the rows and add them to the pipeline buffer. For more information, please
    see:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/1d0b3a1b-8792-469c-b0d1-f2fbb9e9ff20/dump-oracle-ref-cursor-into-ms-sql-staging-table-using-ssis
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/fcdaa97e-8415-4c3e-8ffd-1ad45b590d57/executing-an-oracle-stored-procedure-from-ssis?forum=sqlintegrationservices
    http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracledatareader(VS.90).aspx  
    Regards,
    Mike Yin
    TechNet Community Support

  • How to pass strings for IN Clause in REF Cursor

    I have following query;
    SELECT 1 INTO L
    FROM test_po_apprvlines
    where '4020' between NVL(approval_cost_centre_from, '0000') and
    nvl (approval_cost_centre_to, '9999')
    and req_approval_type IN ('BUS', 'FIN') and 10500 >= approval_amount
    and NVL(req_line_type, 'X') = 'X'
    AND ROWNUM =1;
    Now the values for req_approval_type should be dynamic, based on approval_amount. If approval_amout > 10000 then
    req_approval_type should have 'BUS' and 'FIN' , other wise only 'BUS'.
    I have tried with the following code using ref cursor. But i'm not getting the result.
    Any help. The problem is how to concatenate those two values to get the result.
    in the following code, strings are not recoginised properly. Valid data exists in the table.
    DECLARE
    l_approva_type1 VARCHAR2(20) := 'FIN';
    l_approva_type2 VARCHAR2(10) := 'BUS';
    l_approva_type VARCHAR2(20) := '''FIN'''||','||'''BUS''';
    L NUMBER;
    TYPE TEST_REF IS REF CURSOR;
    cur_ref TEST_REF;
    L_str varchar2(1000) := 'SELECT 1'||
    ' FROM test_po_apprvlines'
    ||' where '||'''4020'''||' between NVL(approval_cost_centre_from, '||'''0000'''||') and nvl(approval_cost_centre_to, '|| '''9999'''||')'
    ||' and req_approval_type IN ( :bi_approva_type)'||
    ' and 10500 >= approval_amount '||
    ' and req_line_type IS NULL '||
    'AND ROWNUM =1';
    L_flg varchar2(1);
    BEGIN
    DBMS_OUTPUT.PUT_LINE (l_approva_type);
    open cur_ref for l_str USING l_approva_type;
    fetch cur_ref INTO l_flg;
    close cur_ref;
    DBMS_OUTPUT.PUT_LINE (nvl(L_flg, 'x'));
    EXCEPTION
    WHEN OTHERS THEN
    if cur_ref%isopen then
         close cur_ref;
         end if;
    DBMS_OUTPUT.PUT_LINE (SQLERRM);
    END;

    You cant "Bind" here.
    One way..
    SQL> var a refcursor
    SQL> declare
      2   str varchar2(100) := '''SALESMAN'',''ANALYST''';
      3  begin
      4   open :a for 'select ename from emp
      5                where job in ('||str||')';
      6  end;
      7  /
    PL/SQL procedure successfully completed.
    SQL> print :a
    ENAME
    WARD
    SCOTT
    Message was edited by:
            jeneesh
    Results in More parsing...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Missing data in ref cursor

    I've got a procedure in PL/SQL that returns data to a .NET program using a ref cursor. If I run the procedure, all the data shows correctly. However, when I run it from .NET, it drops two records entirely (they are blank) and another one has "SYSTEM.WINDOWS.FORMS.TEXTBOX, TEXT" before the data prints. I'm passing the date as part of a string, using to_char to convert it.
    The two lines that are missing are address lines (street address is one and city/state/zip is the other). The person's name (which is the first line) shows up fine. The street address starts with a number.
    I'm passing all the fields as varchar2s.
    On the .NET side, here's my code to populate the dataset:
    Dim da As OracleDataAdapter = New OracleDataAdapter(cmd)
    Dim ds As DataSet = New DataSet
    Try
    da.Fill(ds, "Bill")
    When I look at the resulting data, the address lines are blank and the field with the date is showing the "SYSTEM" shown above.
    Anyone have any ideas? This is driving me crazy.
    -Joe

    As a followup, I think the "SYSTEM.WINDOWS.FORMS.TEXTBOX, TEXT" problem has to do with how the parameter is passed. I'm asking the user to enter a date and then pass it as a varchar2. The parameter in my procedure is a varchar2 also. It is passed correctly and comes back correctly, but it puts the "SYSTEM.WINDOWS.FORMS.TEXTBOX, TEXT" before it prints the date. If I hard code the date in my PL/SQL procedure, it passes perfectly and prints perfectly. So it must be coming from .NET to Oracle. I've tried converting it to a date and then back to text, but with the same result.

Maybe you are looking for

  • Get Rid of Relative Dates in Applications?

    How do I get rid of relative dates in applications such as Mail? I cannot find anything in the Mail Preferences to change this. Nor can I find anywhere in System Preferences -> Date & Time and International to change this behaviour. Settings in View-

  • In need of a step-by-step instruction manual

    I have purchased an IPod clone? model ?ZEN Vision W60?, from Creative, installed the software (version 5.60.07), and now I am trying to transfer MP3 and AVI files from the computer to the Creative gadget. The multi-language manual depicts the very ba

  • How to remove column name in select clause

    Hello Guys, I just want to remove a column name in select clause. Because, I don't want to write all column names. I hope I express myself. In other words, I want the following. Select   * - unwanted_column  from table; instead of this Select col1, c

  • Apple id not valid for updating Pages

    Hi all, I just got a mac mini. I used time machine to migrate my desktop from my 2008 mac book. I thought I was using the same apple id for everything (I only have 1), but when I go to update pages it says the apple id does not match. What is happeni

  • NIMax.exe - Entry Point Not Found - attempt to create task in MAX

    I have two different cards that use NI-DAQmx: PXI-4461 and PXI-6259. They are installed in a PXI-1031 chassis with a PXI-8105 controller. Both devices pass their self-test in MAX. When I try to create a new task for either, I get first the expected s