Dynamic sql and ref cursors URGENT!!

Hi,
I'm using a long to build a dynamic sql statement. This is limited by about 32k. This is too short for my statement.
The query results in a ref cursor.
Does anyone have an idea to create larger statement or to couple ref cursors, so I can execute the statement a couple of times and as an result I still have one ref cursor.
Example:
/* Determine if project is main project, then select all subprojects */
for i in isMainProject loop
if i.belongstoprojectno is null then
for i in ProjectSubNumbers loop
if ProjectSubNumbers%rowcount=1 then
SqlStatement := InitialStatement || i.projectno;
else
SqlStatement := SqlStatement || PartialStatement || i.projectno;
end if;
end loop;
else
for i in ProjectNumber loop
if ProjectNumber%rowcount=1 then
SqlStatement := InitialStatement || i.projectno;
else
SqlStatement := SqlStatement || PartialStatement || i.projectno;
end if;
end loop;
end if;
end loop;
/* Open ref cursor */
open sql_output for SqlStatement;
Thanks in advance,
Jeroen Muis
KCI Datasystems BV
mailto:[email protected]

Example for 'dynamic' ref cursor - dynamic WHERE
(note that Reports need 'static' ref cursor type
for building Report Layout):
1. Stored package
CREATE OR REPLACE PACKAGE report_dynamic IS
TYPE type_ref_cur_sta IS REF CURSOR RETURN dept%ROWTYPE; -- for Report Layout only
TYPE type_ref_cur_dyn IS REF CURSOR;
FUNCTION func_dyn (p_where VARCHAR2) RETURN type_ref_cur_dyn;
END;
CREATE OR REPLACE PACKAGE BODY report_dynamic IS
FUNCTION func_dyn (p_where VARCHAR2) RETURN type_ref_cur_dyn IS
ref_cur_dyn type_ref_cur_dyn;
BEGIN
OPEN ref_cur_dyn FOR
'SELECT * FROM dept WHERE ' | | NVL (p_where, '1 = 1');
RETURN ref_cur_dyn;
END;
END;
2. Query PL/SQL in Reports
function QR_1RefCurQuery return report_dynamic.type_ref_cur_sta is
begin
return report_dynamic.func_dyn (:p_where);
end;
Regards
Zlatko Sirotic
null

Similar Messages

  • Dynamic sql and updating cursors

    hi to anyone,
    we use few temporary global tables which will be created on the fly if not present ( the reason is - they are not created by power designer ).
    addressing theses tables is only possible by using dynamic sql via "execute immediate" because they may not be known to the compiler as they are not created yet.
    Now I defined a cursor to walk through the table - using cursor reference "ref cursor". Using this cursor works, but i found no way using this cursor for update. i.e. declaring as .. for update of and later putting it into an execute immediate like " execute immediate 'update ' || w_temp_table || ' set f1 = :1, f2 = :2 where current of ' || w_cursor using w_1, w_2;" It doesnt work if I block this command using "begin / end".
    Does naybody know a solution ?
    thanks in advance
    wilko

    Thanks todd,
    my main purpose has been just using the dynamic cursor for update as I know that this is quite easy and also fast. I didnt concern about locking all rows I walk through. But you are right - at end you will use the most easy way. So what I did because of another cursor problem ( with analytical functions ) - I defined the temporary table before compiling and everything is much more convenient.
    thanks for help
    wilko

  • Dyn SQL in Ref cursor?

    Hi all,
    I have a pkg as below and its err message in compile:
    create or replace PACKAGE PKG_DARTS1 is
    TYPE TY_PARTY_DETAIL1 IS RECORD (
         PTY_TYPE xxx.yyyy%TYPE
    TYPE cur_partydetail1 IS REF CURSOR RETURN TY_PARTY_DETAIL1;
    procedure SP_GetPartyDetail1(     c_partydetail1 OUT pkg_darts1.cur_partydetail1) ;
    end PKG_DARTS1;
    create or replace PACKAGE BODY PKG_DARTS1 as
    procedure SP_GetPartyDetail1(     c_partydetail1 OUT pkg_darts1.cur_partydetail1)
    AS
         sql_stmt VARCHAR2(2000);
    BEGIN
         sql_stmt := 'select ''XXX'' FROM DUAL ';
         OPEN c_partydetail1 FOR sql_stmt;
    EXCEPTION
         WHEN OTHERS THEN
              dbms_output.put_line(sqlerrm);
    END SP_GetPartyDetail1;
    END PKG_DARTS1;
    .Warning: Package Body created with compilation errors.
    Errors for PACKAGE BODY PKG_DARTS1:
    LINE/COL ERROR
    13/3 PL/SQL: Statement ignored
    13/8 PLS-00455: cursor 'C_PARTYDETAIL1' cannot be used in dynamic SQL
    OPEN statement
    what's wrong with my syntax? anything I should care in constructing sql in ref cursor?
    thx,
    bean

    You can't use strongly types ref cursors with dynamic SQL, you will have to use weakly typed.
    Hth
    Martin

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

  • "java.sql.SQLException: Ref cursor is invalid" - Please help

    Hi everyone,
    I'm really having problem. I'm surrently calling a PL/SQL stored procedure from Java but I'm getting the following error:
    java.sql.SQLException: Ref cursor is invalid
    The procedure has 2 normal IN parameters and 1 ref cursor OUT parameter. Depending upon Parameter 1 a ref cursor may or may not be initialised.
    If Parameter 1 is "yes" then a ref cursor is called to retrieve some data and passed into the OUT. If Parameter 1 is set to "no" then the ref cursor is not initialised. It is here where the error is being hrown. Does anyone know why? Microsoft ADO doesn't seem to complain. Please help is needed. Thanks in advance.
    John

    Hi Justin,
    Thanks for replying. The Java code is a bit awkward to send because we're using several "home-made" wrapper objects to call SQL and stored procedures. In both cases I create a resultset object and only this one object is used irrespective if the first parameter is "yes" or "no", but a ref cursor is passed to the OUT parameter only on condition yes. Hence, the PL/SQL code takes the form similar to:
    OPEN curs FOR SELECT * FROM table;
    The "curs" is then put into the OUT of the procedure. When the parameter is "no" then the "curs" ref cursor in the PL/SQL procedure isn't even initialised like the above. At this point Java complains of an invalid ref cursor. I can try and piece togather the code but it may be very tricky.
    John

  • Dynamic SQL and Data with Single Quotes in it.

    Hi There,
    I have a problem in that I am using dynamic SQL and it happens that one of the columns does contain single quotes (') in it as part of the data. This causes the resultant dynamic SQL to get confused as the single quote that is part of the data is taken to mean end of sting, when in fact its part of the data. This leaves out a dangling single quote that was meant to enclose the string. Here is my dynamic SQL and the result of the parsed SQL that I have captured:
    ****Dynamic SQL*****
    l_sql:='select NOTE_TEMPLATE_ID '||
    'FROM TMP_NOTE_TEMPLATE_VALUES '||
    'where TRIM(LEGACY_NOTE_CODE)='''||trim(fp_note_code)||''' '||
    'and TRIM(DISPLAY_VALUE)='''||trim(fp_note_text)||''' ';
    execute immediate l_sql INTO l_note_template_id;
    Because the column DISPLAY_VALUE contains data with single quotes, the resultant SQL is:
    ******PARSED SQL************
    select NOTE_TEMPLATE_ID
    FROM TMP_NOTE_TEMPLATE_VALUES
    where TRIM(LEGACY_NOTE_CODE)='INQ' and TRIM(DISPLAY_VALUE)='Cont'd'
    And the problem lies with the single quote between teh characters t and d in the data field for DISPLAY_ITEM. How can I handle this?
    Many thanks,

    I have been reliably informed that if one doesn't enclose char/varchar2 data items in quotes, the right indices may not be usedI am into oracle for past 4 years and for the first time i am hearing this.
    Your reliable source is just wrong. Bind variables are variables that store your value and which are used in SQL. They are the proper way to use values in your SQL. By default all variables in PL/SQL is bind variable.
    When you can do some thing in just straight SQL just do it. Dynamic SQL does not make any sense to me here.
    Thanks,
    Karthick.

  • Dynamic SQL and Bulk Bind... Interesting Problem !!!

    Hi Forum !!
    I've got a very interesting problem involving Dynamic SQL and Bulk Bind. I really Hope you guys have some suggestions for me...
    Table A contains a column named TX_FORMULA. There are many strings holding expressions like '.3 * 2 + 1.5' or '(3.4 + 2) / .3', all well formed numeric formulas. I want to calculate each formula, finding the number obtained as a result of each calculation.
    I wrote something like this:
    DECLARE
    TYPE T_FormulasNum IS TABLE OF A.TX_FORMULA%TYPE
    INDEX BY BINARY_INTEGER;
    TYPE T_MontoIndicador IS TABLE OF A.MT_NUMBER%TYPE
    INDEX BY BINARY_INTEGER;
    V_FormulasNum T_FormulasNum;
    V_MontoIndicador T_MontoIndicador;
    BEGIN
    SELECT DISTINCT CD_INDICADOR,
    TX_FORMULA_NUMERICA
    BULK COLLECT INTO V_CodIndicador, V_FormulasNum
    FROM A;
    FORALL i IN V_FormulasNum.FIRST..V_FormulasNum.LAST
    EXECUTE IMMEDIATE
    'BEGIN
    :1 := TO_NUMBER(:2);
    END;'
    USING V_FormulasNum(i) RETURNING INTO V_MontoIndicador;
    END;
    But I'm getting the following messages:
    ORA-06550: line 22, column 43:
    PLS-00597: expression 'V_MONTOINDICADOR' in the INTO list is of wrong type
    ORA-06550: line 18, column 5:
    PL/SQL: Statement ignored
    ORA-06550: line 18, column 5:
    PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL
    Any Idea to solve this problem ?
    Thanks in Advance !!

    Hallo,
    many many errors...
    1. You can use FORALL only in DML operators, in your case you must use simple FOR LOOP.
    2. You can use bind variables only in DML- Statements. In other statements you have to use literals (hard parsing).
    3. RETURNING INTO - Clause in appropriate , use instead of OUT variable.
    4. Remark: FOR I IN FIRST..LAST is not fully correct: if you haven't results, you get EXCEPTION NO_DATA_FOUND. Use Instead of 1..tab.count
    This code works.
    DECLARE
    TYPE T_FormulasNum IS TABLE OF VARCHAR2(255)
    INDEX BY BINARY_INTEGER;
    TYPE T_MontoIndicador IS TABLE OF NUMBER
    INDEX BY BINARY_INTEGER;
    V_FormulasNum T_FormulasNum;
    V_MontoIndicador T_MontoIndicador;
    BEGIN
    SELECT DISTINCT CD_INDICATOR,
    TX_FORMULA_NUMERICA
    BULK COLLECT INTO V_MontoIndicador, V_FormulasNum
    FROM A;
    FOR i IN 1..V_FormulasNum.count
    LOOP
    EXECUTE IMMEDIATE
    'BEGIN
    :v_motto := TO_NUMBER('||v_formulasnum(i)||');
    END;'
    USING OUT V_MontoIndicador(i);
    dbms_output.put_line(v_montoindicador(i));
    END LOOP;
    END;You have to read more about bulk- binding and dynamic sql.
    HTH
    Regards
    Dmytro
    Test table
    a
    (cd_indicator number,
    tx_formula_numerica VARCHAR2(255))
    CD_INDICATOR TX_FORMULA_NUMERICA
    2 (5+5)*2
    1 2*3*4
    Message was edited by:
    Dmytro Dekhtyaryuk

  • Dynamic SQL and Sub Query

    I want need to use dynamic SQL, and include a subquery in the where clause.  However, I am getting a syntax error.
    I have code that looks like this.
        SELECT (p_v_sqlobj_select)
            INTO CORRESPONDING FIELDS OF TABLE <matrix>
          FROM (p_v_sqlobj_from)
          WHERE (p_v_sqlobj_where).
    and I pass it the following bold-faced SQL where clause (please ignore whether the statement makes sense and is the best way to do it - this is just to illustrate).   However, it returns an error.
    select tcode from tstc where tcode in <b>( select min( tcode ) as min from tstc )</b>
    Am I correct in concluding that I cannot pass complex statements, or have I just missed something?
    Thanks for any help.

    Hi,
    Please try with order by clause in select statement and also use descending
          select * from (p_table)
                   into corresponding fields of table <ptab>
                  up to p_rows rows
                  order by <fieldname> descending.
    aRs

  • Dynamic sql and cursors

    We are running an oracle sql procedure that uses a LOT of dynamic sql. We are using a 3rd party package (SQR) as a sort of shell to run the sql procedure. The 3rd party package passes to us an oracle error. This error says, in effect, that there are no inactive database cursors available and that the sql program is too large to process. We conclude from this that we must increase one or more of the cursor parameters in init.ora (v$parameters). Is this the correct assumption? If not, does anyone know what we can do? We'd prefer not to break up the sql procedure into smaller pieces.

    increase the parameter for open cursors.
    check, wether all cursors in your programs are closed in time, or if you are using ref cursors from front-ends (e.g. Java JDBC) that this front-ends close these ref cursors , too.
    If you want to decrease the size of procedures get rid of comments, superfluos spaces, tabs, etc.
    keep a commented version outside vor documentation purposes.
    Hope thsi helps

  • Dynamic sql and block based on a stored procedure

    Hi!
    I'm triying to generate a block based on a stored procedure. I want the stored procedure to execute a dynamic sql, but I'm having getting the error "PLS-00455 cursor 'AULOCASLATE' cannot be used in dynamic SQL OPEN statement".
    I have the following code:
    CREATE OR REPLACE package pkg_f0015 is
    type rClieInstSlate is record
    (clie_id CMS_CLIENTS.ID%type
    ,client_nm varchar2(1000)
    ,cs_no CMS_CLIENTS.CS_NO%type
    ,dob CMS_CLIENT_NAMES.BIRTH_DT%type);
    type tClieInstSlate is table of rClieInstSlate;
    type uClieInstSlate is ref cursor return rClieInstSlate;
    procedure prLocationSlateQry(
    auLocaSlate in out uClieInstSlate,                anCsNo in CMS_CLIENTS.CS_NO%type,
    avClieNm in varchar2,
    avSearchType in varchar2,
    avLotyCd in CMS_LOCATION_TYPES.CD%type);
    end pkg_f0015;
    CREATE OR REPLACE PACKAGE BODY pkg_cms_f0015 is
    procedure PRLocationSlateQry( auLocaSlate in out uClieInstSlate,
    anCsNo in CMS_CLIENTS.CS_NO%type,
    avClieNm in varchar2,
    avSearchType in varchar2,
    avLotyCd in CMS_LOCATION_TYPES.CD%type) IS
    vSelect varchar2(5000);
    vAddCond varchar2(1000);
    vSupLevel varchar2(50);
    begin
    vSelect := 'select clie.ID,'||
    ' CLIENT_NAME,'||
    ' clie.CS_NO,'||
    ' clna.BIRTH_DT dob'
    ' from CMS_CLIENT_NAMES clna,'||
    'CMS_CLIENTS clie'||
    ' where clna.CLIE_ID = clie.ID';
    if avSearchType= 'C' then
    vAddCond := ' and clie.CS_NO = nvl('||anCsNo||',clie.CS_NO)';
    vSelect := vSelect || vAddCond;
    open auLocaSlate for vSelect;
    end if;
    end PRLocationSlateQry;
    end;
    I wonder if what I want is possible

    OK,
    Now it works. Previously we had the parameter p_guid declared as RAW, which obviously is not any good. :)
    Radovan
    Edited by: biciste on Apr 28, 2009 4:57 PM

  • How to populate table name dynamically to a ref cursor

    Hi,
    I came accross with a requirement that in ref cursor how can i pass the table name
    for ex
    open ref_cur for select * from emp;Like that i've some 100 tables , instead of typing each and every time the table name
    that should be dynamically changed
    Like below
    open ref_cur for select * from &tbl_nm;How can i do that??
    Thank you

    I assume you are using SQL*Plus:
    SQL> variable ref_cur refcursor;
    SQL> begin
      2      open :ref_cur for select * from &tbl_nm;
      3  end;
      4  /
    Enter value for tbl_nm: emp
    old   2:     open :ref_cur for select * from &tbl_nm;
    new   2:     open :ref_cur for select * from emp;
    PL/SQL procedure successfully completed.
    SQL> print ref_cur
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 12/17/1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN        7698 02/20/1981 00:00:00       1600        300         30
          7521 WARD       SALESMAN        7698 02/22/1981 00:00:00       1250        500         30
          7566 JONES      MANAGER         7839 04/02/1981 00:00:00       2975                    20
          7654 MARTIN     SALESMAN        7698 09/28/1981 00:00:00       1250       1400         30
          7698 BLAKE      MANAGER         7839 05/01/1981 00:00:00       2850                    30
          7782 CLARK      MANAGER         7839 06/09/1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST         7566 04/19/1987 00:00:00       3000                    20
          7839 KING       PRESIDENT            11/17/1981 00:00:00       5000                    10
          7844 TURNER     SALESMAN        7698 09/08/1981 00:00:00       1500          0         30
          7876 ADAMS      CLERK           7788 05/23/1987 00:00:00       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 12/03/1981 00:00:00        950                    30
          7902 FORD       ANALYST         7566 12/03/1981 00:00:00       3000                    20
          7934 MILLER     CLERK           7782 01/23/1982 00:00:00       1300                    10
    14 rows selected.
    SQL> begin
      2      open :ref_cur for select * from &tbl_nm;
      3  end;
      4  /
    Enter value for tbl_nm: dept
    old   2:     open :ref_cur for select * from &tbl_nm;
    new   2:     open :ref_cur for select * from dept;
    PL/SQL procedure successfully completed.
    SQL> print ref_cur
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    SQL> SY.

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

  • Dynamic query with ref cursors

    please help me out there.
    can you give an example of how to construct a procedure using ref cursors.
    say if I had an employee table.
    employee table
    first name
    last name
    position
    dept
    I would have three input parameters, last name, position, dept. Sometimes only one parameters would be passed. Sometimes only two or sometimes all three.
    How can I construct the procedure being that the parameters will be dynamic
    thanks.

    Don't worry user484105 I don't do kicking, sarcasm and bad humour are other matters though.
    Yes you can use sys_refcursor, in fact all the tests that Todd and I have supplied, have done just that. Do you have a development database to work in?
    if so I would recommend
    1. Run demobld.sql if you don't already have emp table.
    2. Copy my second post in your other thread.
    3. Edit out all the sqlplus output and the first four columns.
    4. If any of this puzzles you see if you can find the answer in the SQL Reference, PL/SQL Guide or SQL*Plus manuals
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/toc.htm
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14357/toc.htm
    5. If you can't find the answer post what you have and the error here.
    6. It is probably best if you use sqlplus for this.
    You will learn a lot if you can do this.

  • Dynamic SQL and PL/SQL Gateway

    This question is kind of out of curiosity...I had created a procedure that used some dynamic sql (execute immediate), and was trying to use it on pl/sql gateway. I kept getting page not found errors until I removed the execute immediate statement, and reverted to using static sql statements.
    I am just curious, is dynamic sql not supported at all with pl/sql gateway?
    Thanks
    Kevin

    > Relax damorgan, no need to be condescending. Of course I read the docs ..
    Well, you're one of the few that actually read the docs.. And one of many that lacked to state any real technical details for forum members to understand the actual problem, the actual error, and what the environment is that this is happening in.
    Remember that you came to this forum for forum members to help you. In order for us to do that, you need to help us understand
    - your problem
    - your environment
    - what you have tried
    What PL/SQL Gateway do you refer to? Thus is an old term for an old product - today in Oracle there are two "gateways" into the PL/SQL engine via HTTP. Via Apache/mod_plsql and via the internal Java servlet web engine called EPG inside Oracle.
    As for what the "Gateway" access to the PL/SQL engine via HTTP.. whether it supports EXECUTE IMMEDIATE or not is like asking if a car "supports" soft drinks or not (just because a human that may consume soft drinks acts as the driver of the car). Not sensible or relevant at all.
    mod_plsql creates an Oracle session to the database instance, and executes a PL/SQL procedure in the database. This is no different from any other client connection to Oracle. Oracle has no clue that the client is mod_plsql and not TOAD or Java or VB or PHP or Perl or whatever else.
    So how can this support or not support the EXECUTE IMMEDIATE command? Does PL/SQL support EXECUTE IMMEDIATE? Well duh...
    Why do you get a generic 404? Because the PL/SQL call made by mod_plsql failed with an unhandled exception. mod_plsql gets that exception and now what? Was a valid HTP buffer created for it to stream to the web browser? If the buffer perhaps partially completed? All that mod_plsql knows is that it asked for a HTP buffer via that PL/SQL call and it got an exception in return.
    A 404 HTTP error is the only reasonable and logical response for it to pass to the web browser in this case.
    PS. to see why mod_plsql fail, refer to the access_log and error_log of that Apache httpd server

  • Using plsql table and ref cursor in oracle forms 10g

    Hi all,
    Can anyone give me an example of a scenario where we need to create a form manually based on a database stored procedures.
    And in that procedure i have created a pl/sql table and a ref cursor in data base level.
    CREATE OR REPLACE PACKAGE SCOTT.BONUS_PKG IS TYPE bonus_rec
    IS RECORD(
    empno     bonus_EMP.empno%TYPE,
    ename     bonus_EMP.ename%TYPE,
    job     bonus_EMP.job%TYPE,
    sal     bonus_EMP.sal%TYPE,
    comm     bonus_EMP.comm%TYPE);
    TYPE b_cursor IS REF CURSOR RETURN bonus_rec;
    TYPE bontab IS TABLE OF bonus_rec INDEX BY BINARY_INTEGER;
    PROCEDURE bonus_refcur(bonus_data IN OUT b_cursor);
    PROCEDURE bonus_query(bonus_data IN OUT bontab);
    END bonus_pkg;
    CREATE OR REPLACE PACKAGE BODY SCOTT.BONUS_PKG IS
    PROCEDURE bonus_query(bonus_data IN OUT bontab) IS
    ii NUMBER;
    CURSOR bonselect IS
    SELECT empno, ename, job, sal, comm FROM bonus_EMP ORDER BY empno;
    BEGIN
    OPEN bonselect;
    ii := 1;
    LOOP
    FETCH bonselect INTO
    bonus_data( ii ).empno,
    bonus_data( ii ).ename,
    bonus_data( ii ).job,
    bonus_data( ii ).sal,
    bonus_data( ii ).comm;
    EXIT WHEN bonselect%NOTFOUND;
    ii := ii + 1;
    END LOOP;
    END bonus_query;
    PROCEDURE bonus_refcur(bonus_data IN OUT b_cursor) IS
    BEGIN
    OPEN bonus_data FOR SELECT empno, ename, job, sal, comm FROM bonus_EMP ORDER BY empno;
    END bonus_refcur;
    END bonus_pkg;
    i want to populate the data in forms manually not using forms data block wizard and programmatically.
    please reply...

    Can anyone give me an example of a scenario where we need to create a form manually based on a database stored procedures.Typically, you would use a procedure based block when you have a collection of data from multiple tables presented in a Form and your user needs to be able to update the information displayed.
    From your code example, it looks like you are using Oracle Support document "Basing a Block on a Stored Procedure - Sample Code [ID 66887.1]". If this is the case, keep following the document - it walks you through all of the steps. There is no need to Manually configure things that the Data Block Wizard will perform for you!
    i want to populate the data in forms manually not using forms data block wizard and programmatically. Why? Let the Data Block Wizard take care of configuring your block based on a procedure for you. There is no need to manually loop through the data! I've actually done what you are attempting and it was more work than was needed. Let Forms do the work for you. :)
    If you absolutely must do things manually, I recommend you use the PROCEDURE bonus_query(bonus_data IN OUT bontab) instead of the bonus_refcur(bonus_data IN OUT b_cursor) . Then, in your code create a variable of type BONTAB and then call the bonus_query procedure. Then it is a simple case of looping through the table of records returned by the bonus_query procedure. For example:
    DECLARE
       t_bonus    bonus_pkb.bontab;
    BEGIN
       bonus_pkg.bonus_query(t_bonus);
       FOR i in 1 .. t_bonus.count LOOP
          :YOUR_BLOCK.EMPLOYEE_NUMBER := t_bonus(i).empno;
          :YOUR_BLOCK.EMPLOYEE_NAME := t_bonus(i).ename;
          :YOUR_BLOCK.EMPLOYEE_JOB := t_bonus(i).job;
          :YOUR_BLOCK.EMPLOYEE_SALARY := t_bonus(i).sal;
          :YOUR_BLOCK.EMPLOYEE_COMMISSION := t_bonus(i).comm;
       END LOOP;
    END;This code sample demonstrates the basics, but as it is sample code - you will have to adapt it to your situation.
    Also, I strongly recommend you look at the article InoL listed. This is a very comprehensive discussion on REF CURSORs. If you are set on using a procedure based data source - it is more efficient to pass the table of records back to your form than it is to pass a ref cursor. Using a ref cursor, you might as well just using a standard named cursor and loop through your named cursor. The effect is the same (one row returned at a time creating lots of network traffic). Using the table of records is more efficient because the entire data set is returned so network traffic is reduced.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

Maybe you are looking for

  • Printing Issue on a MacPro and Lion

    When using any Apple prgram, such as Pages, Numbers, Text, etc. and I try to print to my laser printer from my MacPro I get an error and the following message: You don't have permission to write to the folder that the file "Untitled" is in. You can d

  • ABAP List Faxing using BCS  method ( Business communication service )

    Experts, I have a requirement where we are faxing the ABAP list as it gets generated . I am using NEW-PRINT ON and NEW-PRINT OFF , to get the ABAP list in a spool request , and then  get the spool contents using function module : 'RSPO_RETURN_SPOOLJO

  • F110 - limit open items selected

    Hi Where can I specify such that for a particular payment run, I only want to process payment to vendors where the payment balance is <$X. For vendors with payment >$X will not be selected in that run. I am unable to utilise the free selection screen

  • Other than the -36.....

    I'm getting the following message; "A buffer overrun has been detected which has corrupted the programs internal state. The program cannot safely continue execution and must now be terminated." I hit "OK" and the entire QT program shuts down. Scripts

  • Is there any encryption function in Single Language Windows 8.1?

    Looking to install a data encryption utility on my Single Language Windows 8.1 Truecrypt only seems to work on Windows 7, and there is no Bitlocker or EFS on my version of 8.1. Any recommendations? If you find my response helpful, please click on the