SQL Cursors HELP  ASAP

I need somebody to help me with sql cursors, in JSP.
This is my peace of code what is wrong with it?
          Statement stmt = myConn.createStatement();
          stmt.executeQuery("BEGIN WORK");
          stmt.executeQuery("DECLARE item_cursor CURSOR FOR SELECT user_name FROM admin_info");
          stmt.executeQuery("FETCH 10 FROM item_cursor");
          ResultSet rs = stmt.getResultSet();
          while(rs.next()){
               if(rs.getString(1) != null){
                    user_name = rs.getString(1).trim();
%><P><%= user_name %></P><%
          stmt.executeQuery("CLOSE item_cursor");
          stmt.executeQuery("COMMIT WORK");
and this is the error that a get: No results where returned by the query
Please help anybody
thanx guys

If you are using ORACLE drivers and classes.
This sample program shows Oracle JDBC REF CURSOR functionality, creating a PL/SQL package that includes a stored function that returns a REF CURSOR type. The sample retrieves the REF CURSOR into a result set object.
* This sample shows how to call a PL/SQL function that opens
* a cursor and get the cursor back as a Java ResultSet.
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
class RefCursorExample
public static void main (String args [])
throws SQLException
// Load the driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Connect to the database
// You can put a database name after the @ sign in the connection URL.
Connection conn =
DriverManager.getConnection ("jdbc:oracle:oci8:@", "scott", "tiger");
// Create the stored procedure
init (conn);
// Prepare a PL/SQL call
CallableStatement call =
conn.prepareCall ("{ ? = call java_refcursor.job_listing (?)}");
// Find out all the SALES person
call.registerOutParameter (1, OracleTypes.CURSOR);
call.setString (2, "SALESMAN");
call.execute ();
ResultSet rset = (ResultSet)call.getObject (1);
// Dump the cursor
while (rset.next ())
System.out.println (rset.getString ("ENAME"));
// Close all the resources
rset.close();
call.close();
conn.close();
// Utility function to create the stored procedure
static void init (Connection conn)
throws SQLException
Statement stmt = conn.createStatement ();
stmt.execute ("create or replace package java_refcursor as " +
" type myrctype is ref cursor return EMP%ROWTYPE; " +
" function job_listing (j varchar2) return myrctype; " +
"end java_refcursor;");
stmt.execute ("create or replace package body java_refcursor as " +
" function job_listing (j varchar2) return myrctype is " +
" rc myrctype; " +
" begin " +
" open rc for select * from emp where job = j; " +
" return rc; " +
" end; " +
"end java_refcursor;");
stmt.close();

Similar Messages

  • PL/SQL Cursor Help

    I am trying to figure out how to get the following code to work.
    I am using a cursor to run a SELECT statement with a group function. How do I get the information from the group function to print out with a dbms_output.put_line statement? Just for my knowledge, is there some way to reference the next/previous cursor field as part of the wf_country_spoken_rec variable?
    DECLARE
    CURSOR wf_country_spoken_cur IS SELECT c.country_name, COUNT(s.language_id)
    FROM wf_countries c, wf_spoken_languages s
    WHERE c.country_id = s.country_id
    GROUP BY country_name
    HAVING COUNT(s.language_id) > 6;
    wf_rowcount INTEGER;
    BEGIN
    FOR wf_country_spoken_rec IN wf_country_spoken_cur
    LOOP
    DBMS_OUTPUT.PUT_LINE(wf_country_spoken_rec.country_name || ' ' || wf_country_spoken_rec.language_id);
    wf_rowcount := wf_country_spoken_cur%ROWCOUNT;
    END LOOP;
    DBMS_OUTPUT.PUT_LINE(wf_rowcount);
    END;
    Thanks,
    John

    The only problem I think your code has is how it's referencing the language_id. If it suppose to print out the count of language_ids then you just need to add an alias to it. just like this:
    DECLARE
        CURSOR wf_country_spoken_cur IS
            SELECT c.country_name,
                   COUNT(s.language_id) language_id_cnt
              FROM wf_countries c,
                   wf_spoken_languages s
             WHERE c.country_id = s.country_id
             GROUP BY country_name
            HAVING COUNT(s.language_id) > 6;
        wf_rowcount INTEGER;
    BEGIN
        FOR wf_country_spoken_rec IN wf_country_spoken_cur
        LOOP
            DBMS_OUTPUT.PUT_LINE(wf_country_spoken_rec.country_name || ' ' || wf_country_spoken_rec.language_id_cnt);
            wf_rowcount := wf_country_spoken_cur%ROWCOUNT;
        END LOOP;
        DBMS_OUTPUT.PUT_LINE(wf_rowcount);
    END;
    /

  • Need help on Dynamic SQL Cursor in Forms

    Hi All,
    I am trying to execute Dynamic SQL Cursor in forms using EXEC_SQL built in.
    I have a cursor for example:
    'select * from supplier where supplier = '||p_supplier||' and processing_order = '||p_order
    My code is
    cur_num := Exec_SQL.Open_cursor;
    sql_order := 'select * from supplier where supplier = '||p_supplier||' and processing_order = '||p_order;
    EXEC_SQL.PARSE(cursor_number, sql_order);
      EXEC_SQL.DEFINE_COLUMN(cur_num ,1,ln_Supp_Id);
      EXEC_SQL.DEFINE_COLUMN(cur_num ,2,ls_Suppl_Name,30);
    EXEC_SQL.DEFINE_COLUMN(cur_num ,24,ls_exchange,20);
      sql_count := EXEC_SQL.EXECUTE(cur_num );
      While EXEC_SQL.FETCH_ROWS(cur_num ) > 0 Loop
            EXEC_SQL.COLUMN_VALUE(cur_num ,1,ln_Supp_Id);
            EXEC_SQL.COLUMN_VALUE(cur_num ,2,ls_Suppl_Name);
            EXEC_SQL.COLUMN_VALUE(cur_num ,24,ls_exchange);
    End Loop;
    EXEC_SQL.CLOSE_CURSOR(cur_num );
    In this case I have to write 24 Define Columns and 24 Column value. Is there any way to assign them to %rowtype at one time as I need all coulmn of the table.
    I had similar case on multiple tables.
    Please help me
    Thanks,
    Maddy

    I need this dynamic sql because p_supplier and p_order values changes at run time
    I do not understand. Is this a simplified sample or the real thing? You do know that you can pass variables to cursors:
    cursor test is
    select * from supplier where supplier = p_supplier and processing_order = p_order;
    or does e.g. p_supplier hold other parts of the query?
    cheers

  • SQL query...pls help ASAP

    Actor (Aname: varchar(40), Ano: varchar(6)) Ano is pk
    Movie (Mname: varchar(40),mno: varchar(8)) Mno is pk
    PlayIn (Ano, Mno, Pay: Integer) Ano and Mno are fk referencing Acotr and Movie respectively.
    Actor(Aname, Ano)
    A Bingo, A1
    B Castro, A2
    C Katie, A3
    S Hommy, A4
    J Tammy, A5
    K loren, A6
    Movie(Mname, Mno)
    Gladiator, M1
    Cast, M2
    Dog, M3
    Jilters, M4
    PlayIn(Ano,Mno,Pay)
    A1 M1 800
    A1 M2 1500
    A2 M2 78
    A2 M3 1750
    A2 M4 2301
    A3 M2 904
    A3 M3 629
    A4 M2 565
    A4 M3 5695
    A4 M4 1255
    A5 M1 989
    A5 M4 238
    A6 M2 137
    A6 M3 236
    A6 M4 545
    QUESTION: write SQL query to find the names of actors who earned less than 'B Castro' in each movie that 'B Castro' played in.

    thanks so so much.....
    another question:
    for each movie, list the movie number, the average
    pay and the total number of actors in the movie.....Rather than just asking homework questions and expecting everyone else to do your work for you, why don't you at least have a go at it yourself and post the query that you've tried, then we'll tell you where you are going wrong. You won't learn anything if we just write it for you.
    Also, your use of "pls help ASAP" in the subject title is not polite.
    This forum is manned by volunteers who have their own jobs and offer their help free of charge.
    Everyone who posts an issue on here would love to have it answered as soon as possible, but nobody has the right to assume that their issue is any more important, urgent or requires a quicker answer than anybody elses.
    If you need urgent help then you should pay someone to do the work for you.

  • Help with "ORA-06511: PL/SQL: cursor already open"

    I've tried numerous variations on this piece of code and I always get the same result. I'm sure this is painfully obvious to an experienced PL/SQL person.
    Any help will be appreciated!
    Thank You!
    1 DECLARE
    2 CURSOR EMP_CURSOR IS SELECT last_name from employees;
    3 current_last_name varchar2(25);
    4 BEGIN
    5 IF EMP_CURSOR%ISOPEN
    6 THEN
    7 dbms_output.put_line ('cursor is already open');
    8 close EMP_CURSOR;
    9 END IF;
    10 dbms_output.put_line ('opening cursor');
    11 OPEN EMP_CURSOR;
    12 FOR item in EMP_CURSOR LOOP
    13 FETCH EMP_CURSOR INTO current_last_name;
    14 EXIT WHEN EMP_CURSOR%NOTFOUND;
    15 dbms_output.put_line (item.last_name);
    16 END LOOP;
    17 CLOSE EMP_CURSOR;
    18* END;
    19 /
    DECLARE
    ERROR at line 1:
    ORA-06511: PL/SQL: cursor already open
    ORA-06512: at line 2
    ORA-06512: at line 12

    Mathieu,
    Log in as anotherSchema and grant select on 'IDsTable' to the current user.
    SQL> r
      1  create or replace function f1(theID varchar2) return mytype pipelined is
      2  out varchar2(30);
      3  cursor myCursor (x varchar2) is select * from scott.emp where job=x;
      4  begin
      5  for rec in myCursor(theID) loop
      6  pipe row(rec.ename);
      7  end loop;
      8  return;
      9* end;
    Warning: Function created with compilation errors.
    SQL> show errors
    Errors for FUNCTION F1:
    LINE/COL ERROR
    3/33     PL/SQL: SQL Statement ignored
    3/53     PL/SQL: ORA-00942: table or view does not exist
    6/1      PL/SQL: Statement ignored
    6/10     PLS-00364: loop index variable 'REC' use is invalid
    SQL> connect scott
    Enter password: *****
    Connected.
    SQL> grant select on emp to testuser;
    Grant succeeded.
    SQL> connect testuser
    Enter password: ****
    Connected.
    SQL> create or replace function f1(theID varchar2) return mytype pipelined is
      2  out varchar2(30);
      3  cursor myCursor (x varchar2) is select * from scott.emp where job=x;
      4  begin
      5  for rec in myCursor(theID) loop
      6  pipe row(rec.ename);
      7  end loop;
      8  return;
      9  end;
    10  /
    Function created.
    SQL> disconnect
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - 64bit Production
    With the Partitioning option
    JServer Release 9.2.0.3.0 - Production
    SQL>

  • SQL help ASAP plz!

    Hello! :)
    I'll try to describe my problem. So let's assume that I have a function that recursively calls itself. In this function first i do an executequery, and while i 'browse' through the resultset(for eg.: while (rs.next())), i make updates (updatequeries) on those records too. I wanted to make it faster, and i decided to do one connection (for eg.: conMain) and one statement (for eg.: stmtMain), and do all executequeries and executeupdates via this stmtMain. And it didn't work well. My code runs well only on the first row of the rs.next(), and call itself recursively, but only on the first row, in every while(rs.next()). And i think after finishing, and stepping back from recursion, it doesn't get the rs's next row (rs.next()). So I thought about maybe the updatequeries and executequeries doesn't fit next to each other or what!? So i made 2 public statments one is stmtMain and one is execStatement for example. And i used stmtMain for executeupdates, and execStatement for executequeries. And it still didn't work well! I tried out, that i get out recurcion(so only call the function once), and then on the first Resultset the while(rs.next()) stepped through ALL the rows properly. So as i saw the recursion somehow makes the resultset's next() value FALSE!? I haven't tried out yet, to make statements in every call of that recursive function, but i think it'd work. But i think that would slow down the whole source. I read somewhere that a statement can handle lots of resultsets and so, but in this case it seemed that if i call recursively that function, after stepping back, the while(rs.next()) gives false (or what!?), and not stepping to the next record, as it DOES if there's no recursion.
    Huh, i hope i've made myself clear, sorry for my english, and maybe i haven't read the documents well or so, but i'm a bit angry i spent my whole last night trying to fix this problem, and discover the problem.
    pls help asap :)
    thanks
    athalay

    well, I'll try to explain it a bit more. So I have records named 'catalog'. And this record type has fields: parentid (this points to another 'catalog' record) and catalogdesc (the description of the catalog). The catalogdesc contains the description PLUS before the description, a prefix. As you can see in books, prefix for example: 1.2.2.1 etc. So I want to modify the prefix (which is included in the 'catalogdesc' field) of the childs BASED on the parent's prefix. But in the beginning the parent's prefix is changed too! (example, because a catalog before itself has been deleted) So I have to modify all of it's children's prefix, and their childrens and theirs etc. You see now!? So this is why I do an executequery(which selects the parent's childs), I go into the while(rs.next()) loop, I do an executeupdate(to update the children's prefix based on their parent's), and then call this funtion on them, because they have childrens too!
    This is why I need recursion, I hope it's clearer now.
    So I still need help :/
    thanks
    athalay

  • Error in the following code.need help asap

    hi i have written a block which bulk collects into a pl/sql table.
    Getting an error as shown below.
    PLz help asap
    declare
    type summary_upd_tab is table of summary%rowtype;
    summary_upd_var summary_upd_tab;
    begin
    select
    min(a.start_time_utc),
    max(a.end_time_utc),
    sum(duration_seconds),
    sum(upload_bytes),
    sum(download_bytes)
    bulk collect into summary_upd_var ------GEETTING AN ERROR --TOO MANY VALUES???
    from aaa_sessions a
    group by user_id;
    ---,type_of_summary,ispeak;
    end;
    Edited by: user8731258 on Jul 20, 2010 10:16 PM

    i think the no. of columns should match(and that too in Order) else how will it know which value should go in which field of the collection ?

  • CR+LF Code at the end of each record selected in sql cursor

    i am selecting some data records in a sql cursor and writing it into a file using UTL_FILE.puT in a plsql procedure.
    at the end of select statement if i add ||chr(13||chr(10) iam getting CR+CR+LF code
    if i add only || chr(10) i am getting LF code.
    What i need is only CR+LF code. Kindly help to use any other commands.
    Thanks,
    Shivaji.
    Edited by: Shivaji M on Apr 22, 2010 12:11 AM
    Edited by: Shivaji M on Apr 22, 2010 12:36 AM

    It's in the book!
    "PUT_LINE terminates the line with the platform-specific line terminator character or characters."
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10577/u_file.htm#i997640

  • Row_number query - need help ASAP

    Hi ,
    Need some help bout query
    I need a query for display output like below
    DATE          CODE     MAC_NO BATCH_NO
    01-OCT-07     1119     02     1
    20-OCT-07     1210     01     2
    01-NOV-07     1209     01     3
    01-NOV-07     1510     01     4
    01-NOV-07     4025     01     5
    01-NOV-07     4025     01     5
    01-NOV-07     4051     03     6
    02-NOV-07     1209     01     7
    i hv no idea how to do it. My query doesn't work for tat requirement.Tis is my query
    SELECT date
    ,code
    ,mac_no
    ,ROW_NUMBER()
    OVER (PARTITION by date,code,mac_no
    ORDER by date,code,mac_no)
    as batch_no
    FROM PAYMENT
    WHERE npcs_cycle_num = 27
    AND txn_insert_seq_num > 0;
    The output juz like below.I need everybody help ASAP.
    DATE          CODE     MAC_NO BATCH_NO
    01-OCT-07     1119     02     1
    20-OCT-07     1210     01     1
    01-NOV-07     1209     01     1
    01-NOV-07     1510     01     1
    01-NOV-07     4025     01     1
    01-NOV-07     4025     01     2
    01-NOV-07     4051     03     1
    02-NOV-07     1209     01     1
    Thanks
    CT

    I'm sorry..Maybe my words it not that clear enough. You were right about how ROW_NUMBER works (it
    assigns a numeric value and resets based on the grouping you specify in the PARTITION clause).
    What I want actually is the row number increment based on the txn_date,poc_code and machine_no.
    I'm not sure whether using the row_number() can solve my solutions. I really hope that you could help me.
    I thought of using row_number() may help. Do you have any other solution?
    Here is my table description.
    DESC PAYMENT;
    Name Null? Type
    TXN_ID_NUM NOT NULL NUMBER(12)
    ACCT_NO NOT NULL VARCHAR2(14)
    CANCEL_CODE VARCHAR2(5)
    ADJ_TYPE_NO VARCHAR2(2)
    REASON_CODE VARCHAR2(5)
    CASHIER_ID_NO VARCHAR2(10)
    SUPERVISOR_ID_NO VARCHAR2(10)
    REV_CODE VARCHAR2(5)
    TXN_DATE DATE
    PAY_ADJ_DATE DATE
    POC_CODE VARCHAR2(10)
    MACHINE_NO VARCHAR2(3)
    PAY_MODE_CODE VARCHAR2(5)
    ORIG_ACCT_NO VARCHAR2(14)
    PAY_AMT NUMBER(12,2)
    INVOICE_NO VARCHAR2(20)
    PAY_RECEIPT_NO VARCHAR2(24)
    PAY_BATCH_NO VARCHAR2(20)
    NPCS_CYCLE_NUM NUMBER(4)
    TXN_INSERT_SEQ_NUM NOT NULL NUMBER(12)
    2) Below is the query before assigning the row number:
    SQL> SELECT TXN_DATE,POC_CODE,MACHINE_NO,PAY_BATCH_NO,PAY_AMT,REV_CODE,ADJ_TYPE_NO,PAY_MODE_CODE
    2 FROM PAYMENT
    3 WHERE NPCS_CYCLE_NUM=27
    4 AND REV_CODE IN (SELECT rev_code
    5 FROM OUTBND_REV_CODE
    6 WHERE outbnd_agen_file_code = 'TMB'
    7 AND sys_appl_id ='CCC')
    8 ORDER BY TXN_DATE,POC_CODE,MACHINE_NO;
    TXN_DATE POC_CODE MAC PAY_BATCH_NO PAY_AMT REV_C AD PAY_M
    01-OCT-07 1119 02 20071101120900000000 154.25 017 85 1
    20-OCT-07 1210 01 20071101402501400000 444.02 017 00 5
    01-NOV-07 1209 01 20071101120901100000 585.32 017 85 1
    01-NOV-07 1510 01 20071101402501100000 493 014 00 1
    01-NOV-07 4025 01 20071101402501100000 203.85 016 00 3     
    01-NOV-07 4025 01 20071101402501100000 487.96 017 00 1
    01-NOV-07 4051 03 20071101402501100000 109.26 016 00 3
    02-NOV-07 1209 01 20071102120900000000 105.76 014 00 1
    3)This is my query and the result:
    SQL> SELECT /* SQL_ID 2703 */
    2 txn_date
    3 ,poc_code
    4 ,machine_no
    5 ,pay_batch_no
    6 ,pay_amt
    7 ,rev_code
    8 ,adj_type_no
    9 ,pay_mode_code
    10 ,ROW_NUMBER()
    11 OVER (PARTITION by txn_date,poc_code,machine_no
    12 ORDER by txn_date,poc_code,machine_no)
    13 as row_number
    14 FROM PAYMENT
    15 WHERE npcs_cycle_num = 27
    16 AND txn_insert_seq_num > 0
    17 AND rev_code IN (SELECT rev_code
    18 FROM OUTBND_REV_CODE
    19 WHERE outbnd_agen_file_code = 'TMB'
    20 AND sys_appl_id ='CCC');
    TXN_DATE POC_CODE MAC PAY_BATCH_NO PAY_AMT REV_C AD PAY_M ROW_NUMBER
    01-OCT-07 1119 02 20071101120900000000 154.25 017 85 1 1 (1)
    20-OCT-07 1210 01 20071101402501400000 444.02 017 00 5 1 (2)
    01-NOV-07 1209 01 20071101120901100000 585.32 017 85 1 1 (3)
    01-NOV-07 1510 01 20071101402501100000 493 014 00 1 1 (4)
    01-NOV-07 4025 01 20071101402501100000 203.85 016 00 3 1 (5)
    01-NOV-07 4025 01 20071101402501100000 487.96 017 00 1 2 (5)
    01-NOV-07 4051 03 20071101402501100000 109.26 016 00 3 1 (6)
    02-NOV-07 1209 01 20071102120900000000 105.76 014 00 1 1 (7)
    8 rows selected.
    What I want actually as in the bracket (group by three fields which are txn_date,poc_code and machine_no)
    .I hope this is clearer.

  • So, i just connected my ipod touch 4g to my laptop and there is an update 4.3.3  available  i was downloading it and just as it finishes it says your network session has timed out what ca i do? HELP ASAP PLEASE!!!

    i just connected my ipod touch 4g to my laptop and there is an update 4.3.3  available  i was downloading it and just as it finishes it says your network session has timed out what ca i do? HELP ASAP PLEASE!!!

    Try a direct download:
    iPod, iPhone and iPad Firmware Download
    Manually install it by holding your "Option" key down when clicking on the "Restore" button in iTunes and select the firmware file you downloaded.

  • Building report from PL/SQL cursor

    Hello,
    is there any way to build APEX report using just PL/SQL cursor?
    I don't have grant to SELECT from views or tables, but I can use some functions returning row types and cursors. I know I can use them to build table from scratch with htp.p etc., but it’s not very nice. I want to do it using APEX reporting with filtering and pagination functionality.
    Is it possible?
    Regards,
    Przemek

    Apologies for the delay, I was out of the office.
    Below is a package serving as the basis for creating a view based on a pipelined function. The package is just a skeleton and will not compile in its current form, you will need to go through it filling in the blanks as described by the comments.
    If you want some control over what rows are returned by the view from a larger result set, use the set_parameters function in the WHERE clause, E.G.:
    select * from really_big_complicated_slow_view where 1 = view_pkg.set_parameters(something_that_reduces_the_view_result_set_size);
    Or, a more concrete example:
    select result_text from view_to_convert_to_csv where 1 = view_pkg.set_parameters(pi_table => 'my_table', pi_where = 'whatever');
    In the spirit of full disclosure, I got the idea for using the "set_parameters" function in the view WHERE clause from a post or blog somewhere a couple of years ago but have lost track of who actually deserves the credit for the good idea.
    -Tom
    create or replace package demo_vw as
    -- Package to serve as the basis for a view based on a function
    -- Customize this record so that it represents a row from this view...
    type row_type is record (
    -- record fields here
    type table_type is table of row_type;
    -- This function is used in the DDL to define the view, for example:
    -- create or replace view my_view (col1, col2, ..., colN) as
    -- select * from table(my_view_vw.get_view);
    function get_view
    return table_type
    pipelined;
    -- Customize this function header to accept the parameters for this view, if
    -- any. If this view does not require any parameters, the set_parameters
    -- function may be deleted.
    -- This function should always return 1 and is called as follows
    -- select <whatever>
    -- from my_view
    -- where 1 = my_view_vw.set_parameters(p1, p2, p3, ..., pN);
    function set_parameters (pi_whatever1 in whatever,
    pi_whateverN in whatever)
    return number;
    end demo_vw;
    show error package demo_vw
    create or replace package body demo_vw as
    -- Customize this list of private global variables to match the parameters
    -- required by the view. These variables are set, reset, and validated by
    -- set_parameters, reset_parameters, and valid_parameters respectively...
    g_var1 whatever;
    g_varN whatever;
    function set_parameters (pi_whatever1 in whatever,
    pi_whateverN in whatever)
    return number
    is
    -- Customize this function header to accept the parameters for this view, if
    -- any. If this view does not require any parameters, the set_parameters
    -- function may be deleted.
    -- This function should always return 1 and is called as follows
    -- select col1, col2, ..., colN
    -- from my_view
    -- where 1 = my_view_vw.set_parameters(p1, p2, p3, ..., pN);
    begin
    g_var1 := pi_whatever1;
    g_varN := pi_whateverN;
    return 1;
    end set_parameters;
    function valid_parameters
    return boolean
    is
    -- Customize...
    -- Assumes that set_parameters has been called to set the value of the view
    -- parameters.
    l_valid boolean := true;
    begin
    return l_valid;
    end valid_parameters;
    procedure reset_parameters
    is
    -- Customize...
    -- This is called at the end of the get_view function to reset the view
    -- parameters for the next caller.
    begin
    g_var1 := null;
    g_varN := null;
    end reset_parameters;
    function get_view
    return table_type
    pipelined
    is
    -- build and return each row for the view...
    l_row row_type;
    begin
    if valid_parameters then
    -- do your process to populate the l_row variable here...
    pipe row (l_row);
    end if;
    reset_parameters;
    exception
    when others then
    reset_parameters;
    raise;
    end get_view;
    end demo_vw;
    show error package body demo_vw
    create or replace view demo
    as
    select * from table(demo_vw.get_view);

  • Implicit PL/SQL cursors remain open, causing ORA-01000 (Client 9.2.0.1)

    Hello,
    since migrating our system from Oracle Client 9.0.X to 9.2.0.1 (Windows XP), i am encountering troubles when calling a stored procedure from a Cobol-Program:
    after a while i run into a 'Maximum open cursors exceeded'-message (ORA-01000)
    The stored procedure returns a cursor (ref_cursor)
    When Executing the stored procedure, there are actually 2 cursors involved, in fact the stored PL/SQL procedure implicitely opens a child-cursor when doing a select within the PL/SQL.
    After fetching the result and closing the cursor in my cobol-program, it correctly closes the cursor associated with the stored-procedure, but it does not close the cursor that was implicitely opened by oracle.
    After a while i am running into a Maximum open cursors message, because those cursors have not properly been closed.
    Here's a simple PL/SQL package that illustrates the problem:
    create or replace package scott.SCOTTS_PACKAGE is
    type ref_cursor IS REF CURSOR;
    function GET_EMP(EMP_IN CHAR) return ref_cursor;
    end SCOTTS_PACKAGE;
    create or replace package body scott.SCOTTS_PACKAGE is
    -- Function and procedure implementations
    function GET_EMP(EMP_IN CHAR) return ref_cursor is
    MyCurs ref_cursor;
    begin
    OPEN MyCurs FOR
    SELECT EMPNO ,
    ENAME ,
    JOB
    FROM SCOTT.EMP
    WHERE ENAME = EMP_IN;
    return(MyCurs);
    end;
    end SCOTTS_PACKAGE;
    Here are some exerpts from my cobol program:
    (The program iterates 100x through the section that executes the PL/SQL. After each iteration an additional open cursor remains in the database)
    003800 EXEC SQL BEGIN DECLARE SECTION END-EXEC.
    003900*
    004000 01 SQL-USERNAME PIC X(16) VARYING.
    004100 01 SQL-PASSWD PIC X(16) VARYING.
    004200 01 SQL-DBNAME PIC X(64) VARYING.
    004300 01 ORACLE.
    004700 02 ORA-CUR-EMP SQL-CURSOR.
    01 EMPREC.
    02 EMPREC-EMPNO PIC X(4).
    02 EMPREC-ENAME PIC X(10).
    02 EMPREC-JOB PIC X(9).
    005400 EXEC SQL END DECLARE SECTION END-EXEC.
    018400 PROCEDURE DIVISION.
    CONTINUE.
    018700 EXEC SQL
    018800 WHENEVER SQLERROR DO PERFORM SQL-ERROR
    018900 END-EXEC.
    019000*
    CONTINUE.
    019100 EXEC SQL
    019200 WHENEVER NOT FOUND DO PERFORM SQL-NOT-FOUND
    019300 END-EXEC.
    022400 EXEC SQL
    022500 ALLOCATE :ORA-CUR-EMP
    022600 END-EXEC
    PERFORM VARYING I FROM 1 BY 1 UNTIL I > 100
    ACCEPT DUMMY FROM TER
    IF DUMMY = "E"
    MOVE 100 TO I
    END-IF
    PERFORM GET-EMP
    ADD 1 TO I
    END-PERFORM
    119300 GET-EMP SECTION.
    119400************************
    119500 GAM0.
    MOVE SPACES TO EMPREC-EMPNO EMPREC-JOB
    MOVE "SMITH" TO EMPREC-ENAME
    120200 EXEC SQL AT SSSI EXECUTE
    120300 BEGIN
    120400 :ORA-CUR-EMP:=
    120500 SCOTT.SCOTTS_PACKAGE.GET_EMP(:EMPREC-ENAME );
    120900
    END;
    121000 END-EXEC
    121200 IF DB-ERR-CODE NOT = HIGH-VALUE
    121300 DISPLAY "CCSIFSO:GET-AUTRE-MATR:APPEL PERS... OK"
    121400 EXEC SQL
    121500 FETCH :ORA-CUR-EMP
    121600 INTO
    121700 :EMPREC-EMPNO,
    121800 :EMPREC-ENAME,
    121900 :EMPREC-JOB
    122400 END-EXEC
    122500 END-IF
    122600*
    122700 IF DB-ERR-CODE NOT = HIGH-VALUE
    122800 DISPLAY "CCSIFSO:GET-AUTRE-MATR:APPEL FETCH.. OK"
    123000 ELSE
    123100 MOVE LOW-VALUE TO DB-ERR-CODE
    123200 END-IF
    123300 EXEC SQL
    123400 CLOSE :ORA-CUR-EMP
    123500 END-EXEC
    123600 GA-EX.
    123700 EXIT.
    124000 SQL-NOT-FOUND SECTION.
    124100*----------------------
    124200 NF0.
    124300 DISPLAY "CCSIFSO:SQL-NOT-FOUND SECTION."
    124400 MOVE HIGH-VALUE TO DB-ERR-CODE.
    124500 NF-EX.
    124600 EXIT.
    124700*
    124800 SQL-ERROR SECTION.
    124900*-----------------
    125000 ER0.
    125200 EXEC SQL
    125300 WHENEVER SQLERROR CONTINUE
    125400 END-EXEC
    125700 MOVE HIGH-VALUE TO DB-ERR-CODE
    125800*
    126100 DISPLAY "ORACLE ERROR DETECTED: " SQLCODE UPON TER
    126200 DISPLAY SQLERRMC UPON TER
    126300*
    126400 EXEC SQL AT SSSI
    126500 ROLLBACK WORK
    126600 RELEASE
    126700 END-EXEC
    126800 DISPLAY "----------------------------" UPON TER
    126900 DISPLAY " ! ROLLBACK ET DISCONNECT ! " UPON TER
    127000 DISPLAY "----------------------------" UPON TER
    127200 CALL "PPTERMJ".
    127400 ER-EX.
    127500 EXIT.
    Finally here's an exerpt from V$OPEN_CURSOR, after a few iterations:
    1 begin :b1 := SCOTT . SCOTTS_PACKAGE . GET_EMP (:b2 ) ; END ;
    2 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    3 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    4 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    5 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    6 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    7 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    8 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    9 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    10 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    11 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    As you see, there is only 1 cursor starting with 'begin ... '
    but there are 10 implicit cursors 'SELECT EMPNO, ... ' that have not been properly closed, nor reused by ORACLE.
    In our old configuration (ORACLE CLient 9.0.X), you would only see:
    1 begin :b1 := SCOTT . SCOTTS_PACKAGE . GET_EMP (:b2 ) ; END ;
    2 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    meaning all the other cursors have properly been closed.
    As a conclusion: the program correctly closes the implicit cursors when using a 9.0 Client, wheras the implicit cursors remain open on Client 9.2.0.1 (Windows XP)
    The underlying database can be either 8.i or 9, the problem remains the same.
    Finally here's a small Delphi code, using ODAC-components, that somewhat illustrates the same problem:
    procedure TForm1.ExecProcClick(Sender: TObject);
    var I: INTEGER ;
    begin
    FOR I := 1 TO 5 DO
    BEGIN
    SP1.StoredProcName:='SCOTT.SCOTTS_PACKAGE.GET_EMP';
    SP1.Prepare;
    SP1.ParamByName('EMP_IN').AsString := 'SMITH';
    SP1.ExecProc;
    SP1.Next;
    SP1.Close;
    SP1.UnPrepare;
    END;
    end;
    After each call to 'PREPARE', an additional implicit cursor remains open on the database. (using Oracle Client 9.2.0.1)
    On our old system (Oracle Client 9.0 or 8.X), the same program would not generate accumulating open cursors on the database
    Any suggestions would be welcome,
    Claude

    Cobol.. been many years since I last even saw some Cobol source code. Invokes all kinds of memories. :-)
    Since you found the patch, the advice is superfluous, but works. Close the cursor at the PL/SQL side, e.g.
    create or replace procedure CloseRefCursor( cRefCursor TYPELIB.TRefCursor ) is
    begin
      close cRefCursor;
    exception when OTHERS then
      -- if the cursor is already gone, not a problem
      NULL;
    end;In Delphi for example, one can subclass the class used for ref cursor calls and add a call to the above PL/SQL proc in the destructor. Or add create a standard Cobol close ref cursor section that does similar.

  • Stuttering flv playback issue- need help asap

    We need help asap. Have a project is due to deliver today (5/14).
    We have a video to go on a dvd-rom, live action with Motion Graphics behind.
    When output is done thru Projector the Motion Graphics stutter as they scroll.
    Here is more technical info:
    Stuttering flv playback issue:
    Prores 422 timeline 29.97fps 1280x720 output from fcp using current settings.
    Mov file is approx 7gb, plays relatively smooth on a mac pro with no raid.
    Frame by frame analysis shows all frames are present with no jumps tears or skips.
    Tried several output paths, programs and settings to create a smooth flv file to no avail.
    We adjusted data rates from 2k, 3.5k, 4k and 8k, no luck
    We adjusted keyframe rates from low to all frames, no luck.
    We tried cs3 flash encoder, cs5 media encoder, squeeze ect, same results.
    Playback in the flash projector seems to choke slightly no matter what we do.
    Have also posted in the Director Forum.
    Any help much appreciated!

    Here are a few ideas off the top of my head:
    Try playing the file using a different xtra, sometimes different ones will work better.  If you have Director 11.5, there is a native flv playback xtra.
    You can build a player easily in Flash using the flvPlayback component, then bring that into Director as a swf.
    Once you have the video in Director, try making the member Direct To Stage (DTS).  If it is already DTS, try making it not DTS.
    Make sure the video is not transparent, and nothing in Director overlaps the video... in fact, when the video is playing, nothing should be moving at all, and try to keep the amount of code that is running to a minimum.
    Try lowering your video's data rate further or try using a different codec.
    Using VBR (Variable Bit Rate) compression often makes the video appear to play smoother.
    Try compressing the flv with different software.  FFMpeg, for example, is free and does a very good job, often better than the Flash Video Encoder that comes with Flash/Creative Suite.

  • Need Help ASAP  my State tax form is in a PDF file and the attachment in my email says Please wait

    Need Help ASAP  my State tax form is in a PDF file and the attachment in my email says Please wait...
    I tried downloading updates like it said to but it still will not display the document.  How do I print the PDF file ASAP

    Can you give us a LOT more info?
    What email client? What version of Reader (I can only assume you even have Reader at this point)?
    Please wait? I'm sure it says more than that, right?
    Have you tried simply saving the PDF (it IS a PDF correct?) to your desktop and opening it from there?
    Did you get this form from the IRS or did it come from somewhere else? If the IRS again, what version of Reader?
    Help us help you.

  • My wifi will not turn on. The button is settings seems to be locked. I tried turning it on from the control panel, and also with Siri, but it still does not turn on in settings, so i cannot access wifi. Please help ASAP

    Wifi will not work. The button in settings seems to be locked. Tried control panel and siri to turn it on, doesnt work because the settings wont turn it on. Need help ASAP cause my data limit is approaching.

    If the battery was completely drained the iPad will not respond for some time after connecting it to the charger. Connect the iPad to the charger that came with it and plug that into a good wall outlet. Wait 30 minutes. Then reset the iPad.Press and hold both the Home button and the Sleep/Wake button continuously until the Apple logo appears. Then release the button and let the device restart. You will not lose data doing this. It's like a computer reboot.
    If the iPad restarts let it continue to charge until it's battery shows fully charged. If the iPad still does not start Make an appointment at an Apple Store to have your device examined by a technician. Or contact Apple Support. Be sure to back up your device before taking or sending it to Apple.

Maybe you are looking for

  • Querying Dates missing in the table

    I have columns name, taskname start_date and end_date in my table. e.g., Name Task StartDate EndDate abc task1 2008-04-01 2008-04-03 abc task2 2008-04-05 2008-04-15 abc task3 2008-04-08 2008-04-18 abc task4 2008-04-21 2008-04-25 abc task5 2008-04-19

  • Error when using Patch Set Assistant on DEV_MDS for 11.1.14 upgrade

    I have successfully run the upgrade to SOA 11.1.1.4 from 11.1.1.3, and I am now trying to run the Patch Set Assistant to upgrade the DEV_MDS database schema. But I get the following error: Updating the Oracle Fusion Middleware Metadata Schema to rele

  • File.upload on Air SDK for iOS devices failed to send http request to server.

    I am trying to use ActionScript's File.upload to upload a file on Air SDK for iOS8 environment, but the File.upload does not work properly. No handler about the file upload is executed after File.upload is invoked, and no exception is caught. When I

  • Why does my media appear offline for a split second? It's messing up my exports! FCP 7.0.3

    Every so often, while I'm working, I'll see some of my media go red, with the slash, just for a split second. Just a red flicker almost. It doesn't require me to reconnect or anything, which is weird, as FCP usually makes me go through all the steps

  • Oracle Text: CTXCAT

    Hi all, I have the following table CREATE TABLE SEM_TRAJS OF SEM_TRAJECTORY NESTED TABLE EPISODES STORE AS EPISODES_NESTEDTAB ... and the following types CREATE OR REPLACE type SEM_TRAJECTORY as object -- Attributes sem_trajectory_tag varchar2(50), s