Ref cursor not accepted

Hi,
When I try to compile the following procedure:
Declare
query_str VARCHAR2(4000) := 'SELECT STREET_NAME||chr(09)||ADDRESS.HOUSE_NR||chr(09)||ADDRESS.HOUSE_CHAR||chr(09)||
ADDRESS.HOUSE_NR_TO_BY||chr(09)||ADDRESS.HOUSE_NR_EXTRA||chr(09)||ADDRESS.POSTALCODE||chr(09)||PLACE_NAME ADR
FROM PREVENT.ADDRESS, PREVENT.PLACE_STREET, PREVENT.ADDRESS_DISTRICT
WHERE PLACE_STREET_ID=ID_PLACE_STREET
AND ADDRESS_ID=ID_ADDRESS
AND DISTRICT_ID=P_DISTRICT_ID';
TYPE cur_typ IS REF CURSOR;
c cur_typ;
DECLARE
OPEN c FOR query_str;-- USING inv_num;
LOOP
null;
EXIT WHEN c%NOTFOUND;
-- process row here
END LOOP;
CLOSE c;
END;
forms says:
encountered the symbol 'query_str' when expecting 'select'
When I put the procedure in the database it compiles fine.
Is there maybe another way to approach this in forms?
Thanx,
Pim

Hi,
Thanx for the fast replies.
Based on exec_sql I build the following:
DECLARE
query_str VARCHAR2(4000) := 'SELECT STREET_NAME||chr(09)||ADDRESS.HOUSE_NR||chr(09)||ADDRESS.HOUSE_CHAR||chr(09)||
ADDRESS.HOUSE_NR_TO_BY||chr(09)||ADDRESS.HOUSE_NR_EXTRA||chr(09)||ADDRESS.POSTALCODE||chr(09)||PLACE_NAME ADR
FROM PREVENT.ADDRESS, PREVENT.PLACE_STREET, PREVENT.ADDRESS_DISTRICT
WHERE PLACE_STREET_ID=ID_PLACE_STREET
AND ADDRESS_ID=ID_ADDRESS
AND DISTRICT_ID=P_DISTRICT_ID';
orderby_str varchar(200) := ' ORDER BY STREET_NAME, HOUSE_NR;';
TYPE cur_typ IS REF CURSOR;
c cur_typ;
BEGIN
connection_id EXEC_SQL.CONNTYPE;
cursorID EXEC_SQL.CURSTYPE;
exec_id PLS_INTEGER;
l_adr varchar2(4000);
set_application_property(CURSOR_STYLE, 'BUSY');
--Create exportfile as defined by user parameters 
export_file := TEXT_IO.FOPEN(:SELECTION.PATH_AND_FILE_NAME,'W');
IF (:SELECTION.BUILDING_TYPE <>'<<Selecteer>>')
THEN
query_str := query_str||' and
building_type_id='||:selection.temp_lov_id_buildingtype;
SHOW_ERROR_ALERT('ERROR',substr(query_str,250));
END IF;
IF (:SELECTION.BUILDING_USAGE <>'<<Selecteer>>')
THEN
query_str := query_str||' and
building_usage_id='||:selection.temp_lov_id_buildingusage;
SHOW_ERROR_ALERT('ERROR',substr(query_str,250));
END IF;
IF (:SELECTION.BUILDING_PROPERTY_3 <>'<<Selecteer>>')
THEN
query_str := query_str||' and
BUILDING_PROPERTY_3_id='||:selection.temp_lov_id_BUILDINGPROPERTY3;
SHOW_ERROR_ALERT('ERROR',substr(query_str,250));
END IF;
IF (:SELECTION.BUILDING_PROPERTY_4 <>'<<Selecteer>>')
THEN
query_str := query_str||' and
BUILDING_PROPERTY_4_id='||:selection.temp_lov_id_BUILDINGPROPERTY4;
SHOW_ERROR_ALERT('ERROR',substr(query_str,250));
END IF;
query_str := query_str||orderby_str;
SHOW_ERROR_ALERT('ERROR',substr(query_str,250));
connection_id := EXEC_SQL.OPEN_CONNECTION('PREVENT/*****@prcl');
SHOW_ERROR_ALERT('ERROR','connectie made');
cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
SHOW_ERROR_ALERT('ERROR','cursor opened');
EXEC_SQL.PARSE(connection_id, cursorID, query_str, exec_sql.V7);
SHOW_ERROR_ALERT('ERROR','geparsed');
EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1,l_adr, 4000);
SHOW_ERROR_ALERT('ERROR','column defined');
exec_id := EXEC_SQL.EXECUTE(connection_id, cursorID);
SHOW_ERROR_ALERT('ERROR','EXECUTE SQL');
SHOW_ERROR_ALERT('ERROR','Begin loop');
WHILE (EXEC_SQL.FETCH_ROWS(connection_id, cursorID) > 0 ) LOOP
EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 1,l_adr);
TEXT_IO.PUT_LINE(export_file, l_adr);
nr_of_addresses:=nr_of_addresses+1;
END LOOP;
SHOW_ERROR_ALERT('ERROR','UIT loop');
EXEC_SQL.CLOSE_CURSOR(connection_id, cursorID);
EXEC_SQL.CLOSE_CONNECTION(connection_id);
TEXT_IO.FCLOSE(export_file);
SHOW_NOTE_ALERT('Aanmaken exportbestand','Het aanmaken van exportbestand '
||UPPER(:SELECTION.PATH_AND_FILE_NAME)||' is voltooid. Totaal: '||nr_of_addresses||' adressen.');
go_item('SELECTION.EXPORT');
set_application_property(CURSOR_STYLE, 'DEFAULT');
END;
After the message 'cursor openes' the form hangs. It seems like it doesn't come back from parsing. I tested the sql statement, it's very fast.
Does anybody know of a reason why the parsing results in a hang.
Thanx,
Pim

Similar Messages

  • Ref cursor not returning any data

    Hi
    How can I raise an exception when ref cursor is not retrieving any data.
    create or replace function getempdetails(p_deptno in number)
    return sys_refcursor
    is
    v_refcursor sys_refcursor;
    begin
    open v_refcursor for
    select * from emp
    where deptno = p_deptno;
    return v_refcursor;
    exception
    when no_data_found then
    dbms_output.put_lline('No data available for p_deptno');
    end;
    Say for example p_deptno = 12
    Thanks
    Raghu
    Message was edited by:
    user584123

    It is useless but... you can do this
    create or replace function getempdetails(
         p_deptno in number
    return sys_refcursor
    is
         v_refcursor sys_refcursor;
         flag number;
    begin
         select count(*)
              into flag
         from emp
         where deptno = p_deptno
              and rownum = 1;
         if ( flag = 0) then
              dbms_output.put_lline('No data available for p_deptno');
              return null;
         else
              open v_refcursor for
              select * from emp
              where deptno = p_deptno;
              return v_refcursor;
         end if;          
    end;Bye Alessandro
    Message was edited by:
    Alessandro Rossi
    Or this
    create or replace function getempdetails(
         p_deptno in number
    return sys_refcursor
    is
         v_refcursor sys_refcursor;
         flag number;
    begin
         select 1
              into flag
         from emp
         where deptno = p_deptno
              and rownum = 1; -- This throws the exception
         open v_refcursor for
         select * from emp
         where deptno = p_deptno;
         return v_refcursor;
    end;

  • REF CURSOR not returned to "Output Variables"

    I have a poorly performing procedure that returns a Ref Cursor. I can retrieve the Ref Cursor via Crystal Reports, so I know that it is working. However, the data is not showing up in the "Output Variables" section on SQL Developer version 3.1.07.42.
    I have other procs that run much faster and the data shows up just fine for them.
    I'm wondering if the fact that the query runs in about 4 minutes is causing the results to be lost?
    Oracle 11.2.0.3.0 64 bit on AIX version 6.
    Sql Developer 3.1.07.42.
    Thanks.

    Can't reproduce. Test case:
    <code>
    create or replace
    package pivot
    as
    type rc is ref cursor;
    procedure tst4( c1 in out rc, c2 out rc, i out integer, c4 out rc );
    end;
    create or replace
    package body pivot
    as
    procedure tst4( c1 in out rc, c2 out rc, i out integer, c4 out rc ) is
    stmt1 long;
    stmt2 long;
    stmt3 long;
    stmt4 long;
    begin
    stmt1 := 'select 11 one, 12 two, ''a'' from dual union select 21 one, 22 two, ''b'' from dual';
    open c1 for stmt1;
    stmt2 := 'select 2 from dual';
    select count(1) into stmt4 from dual -- simulated delay
    connect by level < 40000000;
    open c2 for stmt2;
    i:=42;
    stmt4 := 'select level from dual connect by level < 7';
    open c4 for stmt4;
    end;
    end;

  • Unit Test Validation for Output Ref Cursor Not Working

    Here is the problem:
    I have a stored procedure as follows:
    CREATE OR REPLACE
    PROCEDURE usp_GetEmployee(
    p_employeeId IN NUMBER,
    cv_employee OUT Sys_RefCursor )
    AS
    BEGIN
    OPEN cv_employee FOR SELECT * FROM employees WHERE employee_id=p_employeeid;
    END usp_GetEmployee;
    For this, I am implementing a unit test.
    * In the "Select Parameters" step, I am unchecking the "Test Result" check box for the cursor OUT variable.
    * In the "Specify Validations" step, I am choosing "Boolean Function" and putting the following PL/SQL code:
    DECLARE
    emp_rec {cv_employee$}%rowtype;
    BEGIN
    FETCH {cv_employee$} INTO emp_rec;
    IF {cv_employee$}%FOUND THEN
    RETURN TRUE;
    ELSE
    RETURN FALSE;
    END IF;
    RETURN TRUE;
    END;
    But, when I try to execute this Test, I get the following error:
    Validation Boolean function failed: Unable to convert <oracle.jdbc.driver.OracleResultSetImpl@4f0617> to REF CURSOR.
    If I run in the debug mode, I get the following content in a dialog box:
    The following procedure was run.
    Execution Call
    BEGIN
    "ARCADMIN"."USP_GETEMPLOYEE"(P_EMPLOYEEID=>:1,
    CV_EMPLOYEE=>:2);
    END;
    Bind variables used
    :1 NUMBER IN 1001
    :2 REF CURSOR OUT (null)
    Execution Results
    ERROR
    CV_EMPLOYEE : Expected: [Any value because apply check was cleared], Received: [EMPLOYEE_ID                             COMMISSION_PCT                          SALARY                                 
    1001                                    0.2                                     8400                                   
    Validation Boolean function failed: Unable to convert <oracle.jdbc.driver.OracleResultSetImpl@31dba0> to REF CURSOR.
    Please suggest how to handle this issue.
    Thanks,
    Rahul

    979635 wrote:
    But, when I try to execute this Test, I get the following error:
    Validation Boolean function failed: Unable to convert <oracle.jdbc.driver.OracleResultSetImpl@4f0617> to REF CURSOR.
    If I run in the debug mode, I get the following content in a dialog box:
    The following procedure was run.
    Execution Call
    BEGIN
    "ARCADMIN"."USP_GETEMPLOYEE"(P_EMPLOYEEID=>:1,
    CV_EMPLOYEE=>:2);
    END;
    Bind variables used
    :1 NUMBER IN 1001
    :2 REF CURSOR OUT (null)
    Try explicity declaring the ref cursor instead of using a bind variable, something like (untested)
    begin
      foo sys_refcurosr;
    begin
      test_procedure(foo);
    end;Alternately, in SQL*PLUS use the DEFINE command to ste a named bind variable to type REFCURSOR and use the named bind variable in your test
    Edited by: riedelme on Jan 23, 2013 7:10 AM

  • How to return integer used wit DMBS_SQL as ref cursor ?

    I am trying to return a ref cursor form a procedure to be used by xsql to output hierarchical XML.
    I created the query using the DBMS_SQL package, did an OPEN_CURSOR and then PARSE.
    Can I, and if so how, return the integer from the PARSE as a ref cursor out of my procedure ? According to the docs the integer in the PARSE is the ID number for a cursor.
    thanks,
    Reinier

    I suspect that you are a little confused. I doubt that what you are asking for is what you really need. I believe you want the contents of a ref cursor, not an integer that is the cursor id. Since you are using Oracle 8i, as mentioned in your other post, you don't need DBMS_SQL; You just need to open a ref cursor dynmacially. Please see my response to your other post:
    Re: Error while compiling form in AS 10g  deployed on Linux

  • Terminal window blinking cursor will not accept keyboard entry

    Have SunBlade100 w/ Solaris8.
    This is probably a dumb beginner question...
    When I enter certain commands at the terminal window - in this particular case
    # cat /dev/cua/a
    and I hit <return> the cursor skips to the next line, and
    continues blinking , and will not accept any keyboard entries.
    1. What is the significance of this? Is the cursor waiting further action, and if so, what?
    2. How do I get back to the prompt?
    3. Under this condition, is it safe to exit the terminal window by closing from the Window menu? (I can't type "exit" because the cursor won't accept keyboard entries, and Help for "closing the terminal" warns against closing from the Window menu because any background processes will not be terminated (and this may cause problems).
    Thanks in advance for any info on this.

    Thanks again for the info. <control>+C was exactly what I was looking for. It's coming back to me now-- the last time I had contact w/ UNIX was back in '85 at UC Berkeley (no GUI's back then!).
    I'm assuming that <control>+C is a graceful (i.e. relatively harmless way to exit the command.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Cursors are not closed when using Ref Cursor Query in a report  ORA-01000

    Dear Experts
    Oracel database 11g,
    developer suite 10.1.2.0.2,
    application server 10.1.2.0.2,
    Windows xp platform
    For a long time, I'm hitting ORA-01000
    I have a 2 group report (master and detail) using Ref Cusor query, when this report is run, I found that it opens several cursors (should be only one cursor) for the detail query although it should not, I found that the number of these cursors is equal to the number of master records.
    Moreover, after the report is finished, these cursors are not closed, and they are increasing cumulatively each time I run the report, and finally the maximum number of open cursors is exceeded, and thus I get ORA-01000.
    I increased the open cursors parameter for the database to an unbeleivable value 30000, but of course it will be exceeded during the session because the cursors are increasing cumulatively.
    I Found that this problem is solved when using only one master Ref Cursor Query and create a breake group, the problem is solved also if we use SQL Query instead of Ref Query for the master and detail queries, but for some considerations, I should not use neither breake group nor SQL Query, I have to use REF Cursor queries.
    Is this an oracle bug , and how can I overcome ?
    Thanks
    Edited by: Mostafa Abolaynain on May 6, 2012 9:58 AM

    Thank you Inol for your answer, However
    Ref Cursor give me felxibility to control the query, for example see the following query :
    function QR_1RefCurDS return DEF_CURSORS.JOURHEAD_REFCUR is
    temp_JOURHEAD DEF_CURSORS.JOURHEAD_refcur;
              v_from_date DATE;
              v_to_date DATE;
              V_SERIAL_TYPE number;
    begin
    SELECT SERIAL_TYPE INTO V_SERIAL_TYPE
    FROM ACC_VOUCHER_TYPES
    where voucher_type='J'
    and IDENT_NO=:IDENT
    AND COMP_NO=TO_NUMBER(:COMPANY_NO);
         IF :no_date=1 then
                   IF V_SERIAL_TYPE =1 THEN     
                   open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
                   FROM JOURHEAD
                   WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
                   AND IDENT=:IDENT
              AND ((TO_NUMBER(VOCH_NO)=:FROM_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NULL)
              OR (TO_NUMBER(VOCH_NO) BETWEEN :FROM_NO AND :TO_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NOT NULL )
              OR (TO_NUMBER(VOCH_NO)<=:TO_NO and :FROM_NO IS NULL AND :TO_NO IS NOT NULL )
              OR (:FROM_NO IS NULL AND :TO_NO IS NULL ))
                   ORDER BY TO_NUMBER(VOCH_NO);
                   ELSE
                   open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
                   FROM JOURHEAD
                   WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
                   AND IDENT=:IDENT               
              AND ((VOCH_NO=:FROM_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NULL)
              OR (VOCH_NO BETWEEN :FROM_NO AND :TO_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NOT NULL )
              OR (VOCH_NO<=:TO_NO and :FROM_NO IS NULL AND :TO_NO IS NOT NULL )
              OR (:FROM_NO IS NULL AND :TO_NO IS NULL ))     
                   ORDER BY VOCH_NO;          
                   END IF;
         ELSE
                   v_from_date:=to_DATE(:from_date);
                   v_to_date:=to_DATE(:to_date);                         
              IF V_SERIAL_TYPE =1 THEN
                   open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
                   FROM JOURHEAD
                   WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
              AND IDENT=:IDENT                         
                   AND ((voch_date between v_from_date and v_to_date and :from_date is not null and :to_date is not null)
                   OR (voch_date <= v_to_date and :from_date is null and :to_date is not null)
                   OR (voch_date = v_from_date and :from_date is not null and :to_date is null)
                   OR (:from_date is null and :to_date is null ))     
                   ORDER BY VOCH_DATE,TO_NUMBER(VOCH_NO);     
              ELSE
                   open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
                   FROM JOURHEAD
                   WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
                   AND IDENT=:IDENT                         
              AND ((voch_date between v_from_date and v_to_date and :from_date is not null and :to_date is not null)
                   OR (voch_date <= v_to_date and :from_date is null and :to_date is not null)
                   OR (voch_date = v_from_date and :from_date is not null and :to_date is null)
                   OR (:from_date is null and :to_date is null ))     
                   ORDER BY VOCH_DATE,VOCH_NO;          
              END IF;
         END IF;               
         return temp_JOURHEAD;
    end;

  • Parallel  piplelined function not parallelizing with ref cursor

    RDBMS 11.2.0.3
    I have a function with the following signature
    function to_file (
      p_source     in  sys_refcursor
    , p_file_name  in  varchar2
    , p_directory  in  varchar2 default 'DD_DUMP'
    return dd_dump_ntt
    pipelined
    parallel_enable ( partition p_source by any )
    authid current_user;The function works in parallel when I use a cursor expression like this
    begin
      for rec in ( select *
                   from table(dd_dump.to_file( cursor(select /*+ parallel(i 4) */ c1||chr(9)||c2 from mytable i), 'f.out' ))
      loop
        dbms_output.put_line(rec.file_name || chr(9) || rec.num_records );
      end loop;
    end;
    f.out_162     276234
    f.out_213     280399
    f.out_230     286834
    f.out_70     289549But when I use a refcursor, it does not run in parallel
    declare
      rc sys_refcursor;
    begin
      open rc for 'select /*+ parallel(i 4) */ c1||chr(9)||c2 from mytable i';
      for rec in ( select *
                   from table(dd_dump.to_file( rc, 'f.out' ))
      loop
        dbms_output.put_line(rec.file_name || chr(9) || rec.num_records );
      end loop;
    end;
    f.out_914     1133016Is this an expected behavior or am I doing something wrong? How can I use the function when the client returns the SQL statement as a character string
    Edited by: Sanjeev Chauhan on Mar 9, 2012 11:54 AM

    Sanjeev Chauhan wrote:
    I am not performing any DML in the pipelined function. If you read the note carefuly it shows parallel_enable works only when you use:
    table(table_function(<font color=red>CURSOR</font>(select...)))and not when you use
    table(table_function(<font color=red>ref-cursor-name</font>))SY.

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

  • Still not possible (4.0 EA3) to copy displayed column headings from ref cursor output.

    Hi,
    I've created an enhancement request to allow displayed column headings from ref_cursor output to be copied.
    This is still not possible (4.0 EA3)
    The ref cursor data can be copied, but not the headings..
    See July 2012 discussion of problem in comments at
    http://www.thatjeffsmith.com/archive/2011/12/sql-developer-tip-viewing-refcursor-output/

    Hi,
    I think you're out of luck... except if you're on 11g where you can use DBMS_SQL.TO_CURSOR_NUMBER to convert the REF CURSOR to a DBMS_SQL cursor, and then benefit from the DBMS_SQL package to get column details.
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_sql.htm#CHDJDGDG

  • Forms Data-Block based on stored procedures - REF CURSOR feature NOT FUNCTIONING

    This topic is related to another topic in this forum titled "FORMS HOW TO SET QUERY SOURCE ARGUMENTS??" I posted my message there as well. I am posting as a NEW TOPIC so that it catches the attention of Oracle Support.
    I built a data form based on a stored procedure and REF CURSOR IN OUT parameter.
    My procedure takes a IN parameter to fill in the criteria for the OPEN <cursor_variable> select ... where ... statement.
    In the Value setting of the Query source Arguments , I set the VALUE to ":BLOCK_NAME.ITEM_NAME" at design time to supply the input value to the procedure. this works to the extent of making available the form item value to the stored procedure parameter. I verified this by doing an insert into some debug table , of the incoming parameter value inside my stored procedure.
    The cursor gets opened properly into the REF cursor variable. I verified this by fetching a record into a local variable and inserting the value into a debug table again in the stored procedure.
    (I took care to close and re-open the REF cursor variable again - so that the front-end can continue to fetch it from the first record. )
    ***** PROBLEM **************
    But the front end forms runtime is giving me a FRM-40301 - query returned no records even though the REF cursor is returned properly opened.
    Did anybody else face the same problem ??
    Please post what you found.
    Thanks,
    Shankaran
    null

    This topic is discussed at length in another thread "How Set Value For Query DataSource Arguments?"
    But I am posting the findings here as well.
    THIS TOPIC IS CLOSED.
    My Bad. The problem Cause : I did not include all columns in the
    cursor rowtype in the Data-block. In the wizard for the data block , I selected ONLY the columns that I needed. But I was doing a Select * from <my_table> in my open cursor <Cursor-Variable> .... The <Cursor Variable>
    itself was declared <my_table>%rowtype
    FIX : The Data Block structure (columns included as items) should match the cursor record Structure. One may or may not
    display all the columns in the LAYOUT though.
    But I don't understand why it gives such a misleading message like FRM-40301 Query retrieved no records. Oracle Team fix it.
    Hope this helps people who face the same problem.
    Thanks,

  • Is Ref Cursor Supported in Froms 10g . If not is there any built-ins

    Hi Experts,
    I need to use ref cursor in my from 10g. My cursor query should be dynamically append the "where clause column name". Hence I used the dynamic query with ref cursor.
    But my problem is , when I compile the form it gives error "this feature is not supported in clinet-side programs'
    Is there any solution for this in forms?
    Will "EXEC_SQL" package works.
    Is there any alternative other than writing pl/sql refcursor....
    Thanks
    Jana

    There are only strong ref cursors allowed in forms (they are not dynamic). you can use exec_sql in forms, or you can use a record group to do dynamic sql. Third option would be to write a database procedure where you can make use ref cursors.
    regards

  • Problem with accepting the Ref Cursor in c# program

    I am passing an argument as OUT Ref Cursor in a stored procedure. and calling the procedure from my c# program.
    I can connect the database successfully but am getting the error on calling the procedure.
    I am using the ODBC connection
    My procedure's signatures are like:
    CREATE OR REPLACE PACKAGE BODY packageName
    IS
    PROCEDURE GetOutput(returnCursor OUT Sys_RefCursor)
    AS
    BEGIN
    OPEN returnCursor FOR
    <<my select statement>>
    END GetOutput;
    END packageName;
    My function call is like:
    CString Extract::ExtractScript() const
         CString script;
         script.Format("{Call %s.%s()}", packageName,GetOutput);
         return script;
    I can compile the procedure successfully on Toad but while calling the procedure from the C# program it gives following error
    Connection Successful
    Problem executing SQL {Call packageName.GetOutput()}...
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'GetOutput'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Message was edited by:
    user653288

    Hi Aga,
    Thanks for your response.
    I figured out the problem.
    I was using the ODBC connection which wasnt updated for Oracle 10g.
    I have updated that. Now its working fine.
    Thanks again
    Regards

  • Dynamic Columns in Ref Cursor

    Hi All,
    I have a requirement that i need to execute query having dynamic number of columns using Ref Cursor e.g.
    v_string := 'PO_NUMBER , ORG_ID' ;
    v_query := 'SELECT '|| v_string || 'FROM table_name';
    Can someone please quide me how to define Type dynamically for the above requirement ?
    Thanks
    Vipul Maheshwari

    hope you understand how to use this with the help of ref cursor
    CURSOR Expressions
    A CURSORexpression returns a nested cursor. This form of expression is equivalent to
    the PL/SQL REF CURSORand can be passed as a REF CURSORargument to a function.
    A nested cursor is implicitly opened when the cursor expression is evaluated. For
    example, if the cursor expression appears in a select list, a nested cursor will be
    opened for each row fetched by the query. The nested cursor is closed only when:
    ■ The nested cursor is explicitly closed by the user
    ■ The parent cursor is reexecuted
    ■ The parent cursor is closed
    ■ The parent cursor is cancelled
    ■ An error arises during fetch on one of its parent cursors (it is closed as part of the
    clean-up)
    Restrictions on CURSOR Expressions The following restrictions apply to CURSOR
    expressions:
    ■ If the enclosing statement is not a SELECTstatement, then nested cursors can
    appear only as REF CURSORarguments of a procedure.
    ■ If the enclosing statement is a SELECTstatement, then nested cursors can also
    appear in the outermost select list of the query specification or in the outermost
    select list of another nested cursor.
    ■ Nested cursors cannot appear in views.
    ■ You cannot perform BINDand EXECUTEoperations on nested cursors.
    Examples The following example shows the use of a CURSORexpression in the
    select list of a query:
    SELECT department_name, CURSOR(SELECT salary, commission_pct
    FROM employees e
    WHERE e.department_id = d.department_id)
    FROM departments d
    ORDER BY department_name;
    The next example shows the use of a CURSORexpression as a function argument. The
    example begins by creating a function in the sample OEschema that can accept the
    REF CURSORargument. (The PL/SQL function body is shown in italics.)
    CREATE FUNCTION f(cur SYS_REFCURSOR, mgr_hiredate DATE)
    RETURN NUMBER IS
    emp_hiredate DATE;
    before number :=0;
    after number:=0;
    begin
    loop
    fetch cur into emp_hiredate;
    exit when cur%NOTFOUND;
    if emp_hiredate > mgr_hiredate then
    after:=after+1;
    else
    before:=before+1;
    end if;
    end loop;
    close cur;
    if before > after then
    return 1;
    else
    return 0;
    end if;
    end;
    The function accepts a cursor and a date. The function expects the cursor to be a query
    returning a set of dates. The following query uses the function to find those managers
    in the sample employeestable, most of whose employees were hired before the
    manager.
    SELECT e1.last_name FROM employees e1
    WHERE f(
    CURSOR(SELECT e2.hire_date FROM employees e2
    WHERE e1.employee_id = e2.manager_id),
    e1.hire_date) = 1
    ORDER BY last_name;

  • Ref Cursor - How to append records into ref cursor?

    Hi,
    Is it possible to append ref cursor?
    Iam having a procedure which accepts 1 string as input
    parameter. That string will have list of ID delimited by comma.
    I want to extract & match every ID with some tables.
    My problem is for first ID i would get 10 records
    and for 2nd ID i 'l get other 20 records. But while returning
    i need to send the same(10 + 20 records) as ref cursor(OUT parameter).
    But in below given code i could send only last 20 records. first
    10 records are not append/updated into ref cursor.
    How to append 2nd 20 records with 1st 10 records? so that i can
    send all the 30 records.
    Here goes my code...
    CREATE OR REPLACE PROCEDURE getCRMGroupsAndRollups_PRC
    in_groupId IN VARCHAR2,
    out_getCRMGroups OUT TYPES.DATASET
    IS
    v_temp VARCHAR2(500) := in_groupId ||',';
    v_temp_split VARCHAR2(500);
    v_pos1 NUMBER := 0;
    v_pos2 NUMBER := 1;
    v_pos3 NUMBER := 0;
    v_extract_char VARCHAR(1) := NULL;
    v_comma_cnt NUMBER := 0;
    BEGIN
    -- check in for null input parameters
    IF ( in_groupId IS NOT NULL ) THEN
    -- loop to count no of in_groupId
    FOR j IN 1..LENGTH(v_temp)
    LOOP
         v_extract_char := SUBSTR(v_temp,j,1);
         IF (v_extract_char = ',') THEN
              v_comma_cnt := v_comma_cnt + 1;
         END IF;     
    END LOOP;
    -- loop to extract in_group Id
    FOR i IN 1..v_comma_cnt
    LOOP
         v_pos1 := instr(v_temp,',',(v_pos1 + 1));
         v_pos3 := ((v_pos1-1) - v_pos2 )+ 1;
         v_temp_split := SUBSTR(v_temp,v_pos2,v_pos3);
         v_pos2 := v_pos1 + 1;
    -- query to return dataset filled BY list of all the current
    -- CRM groups and the associated rollup groups
    OPEN out_getCRMGroups FOR
    SELECT
    DISTINCT
    gcs.crm_st_id_cd,
    gcs.lgcy_roll_up_grp_num,
    gcs.lgcy_roll_up_grp_name,
    gcs.grp_xwalk_complt_dt,
    gcs.crm_grp_num,
    gcs.facets_gnat_id,
    gcs.crm_grp_name
    FROM
    grp_convsn_stat gcs
    --lgcy_xref_elem lxe
    WHERE
    ( gcs.mbrshp_convsn_aprvl_dt = NULL )
    OR ( gcs.mbrshp_convsn_aprvl_dt < (SYSDATE - 7 ) )
    AND ( gcs.facets_grp_stat_actv_ind = 'Y' )
    AND ( gcs.lgcy_roll_up_grp_num = v_temp_split );
    END LOOP;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('INTERNAL ERROR');
    END getCRMGroupsAndRollups_PRC;
    in this v_temp_split will have extracted id & iam opening
    ref cursor for each & every ID extracted from list.
    2) How to handle no_data_found exception for this ref cursor?
    Please help me....
    -thiyagarajan.

    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:210612357425
    Message was edited by:
    Kamal Kishore

Maybe you are looking for

  • Printer Options for HP LJ 3015 Not working

    Hi, I am unable to get the duplex option to appear for my HP LaserJet 3015 (all in one printer). This is my first mac (OS X 10.5.8). I have downloaded the latest driver and software from the HP web site. I've spent over an hour on the phone with appl

  • Resolving lookup column value

    We have the following data model My_Source_Table (Column1,Column2, Column3...) My_Stage_Table (Column1,Column2, Column3...Res_Lookup_Value....) My_Target_Table (Column1,Column2, Column3...other columns) My_Interface1 operates on My_Source_Table --> M

  • Mountain Lion MBP to Projector difficulties.

    Mountain Lion MBP to Projector difficulties. I have the right VGA cable and the VGA to miniport adapter, but no luck. The "arrangements" tab in the Display section of the system preferences doesn't even appear. I've tried low resolution, safe boots,

  • Hi I really need serious help right now

    Okay, from the start, Im a user of s820 , and today, apparently the phone wont turn on, it does not show any led charge light when i put on my cable , and i ve trie hard reset but it wont work, and is there any way i could do? i didnt run anything ex

  • PSRemotingTransportException when invoking command on a distant server

    Hello, I'm having some trouble when I try to call Invoke-Command in powershell on a distant server. I'm receiving a PSRemotingTransportException. It tells me that the user is either unknown or associated with a wrong password. I've run the following