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

Similar Messages

  • NULL and dynamic SQL

    If table testrh2 has the following columns and data
    col1 --> NULL
    col2 --> 2
    and table testrh has the following columsn and data
    col1 --> NULL
    How could I write a dynamic SQL statement to join on the nulls? I've written the following block as a starting point.
    declare
    cursor c1 is select col1 from isis.testrh;
    lval varchar2(1000);
    lval2 varchar2(1000);
    begin
    for r1 in c1 loop
    lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
    execute immediate lval into lval2;
    dbms_output.put_line(lval2);
    end loop;
    end;

    You can't compare null values with '=' in Oracle SQL.
    Null can only be compared with <column> is null .
    You can see it when you try these two queries:
    select * from dual where null is null;  -- you will see one row
    select * from dual where null=null;  -- you will see no rowsThat's why you have to write something like
    (<column1>=<column1>   or   (<column1> is null and <column2> is null))This should also work with null:
    decode(<column1>,<column2>,1,0)=1By the way, why do you use dynamic sql?
    lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
    I think you could replace your two lines ( lval:= ... AND execute immediate) by this:
    begin
      select col2
      into lval
      from isis.testrh2
      where decode(col1,r1.col1,1,0)=1;
      dbms_output.put_line('lval='||lval);
    exception
    when no_data_found then
      dbms_output.put_line('no data found'); -- or whatever you want
    end;Edited by: hartmutm on 02.10.2010 23:54

  • Dynamic SQL and MERGE

    Hi all,
    I'm under 10G r1
    I want to execute a dynamic SQL with merge in it
    when I try with insert ,update it works
    but I just want to use merge if possible
    this is the code
    CREATE OR REPLACE
    PROCEDURE I_COLUMN_CDS_FIXINGS
    v_ticker VARCHAR2,
    v_date DATE,
    v_tenor VARCHAR2,
    v_bid NUMBER,
    v_ask NUMBER)
    AS
    l_column VARCHAR2(80);
    v_column_bid VARCHAR2(80);
    v_column_ask VARCHAR2(80);
    v_source VARCHAR2(60) :='CMAN@BBG';
    v_gen_order pls_integer;
    BEGIN
    SELECT 'CDS_SPREAD_'
    ||v_TENOR
    ||'_BID'
    INTO v_column_bid
    FROM dual;
    SELECT 'CDS_SPREAD_'
    ||v_TENOR
    ||'_ASK'
    INTO v_column_ask
    FROM dual;
    dbms_output.put_line(v_ticker||' '||v_column_ask||' '||v_column_bid||' '||v_bid|| ' '||v_ask||' '||v_date);
    EXECUTE immediate 'MERGE into CDS_FIXINGS C
    using ( select v_ticker,'
    ||v_column_bid
    ||','
    ||v_column_ask
    ||',trunc(v_date) info_date ,v_bid,v_ask from dual ) B
    on (C.cds_ticker=b.v_ticker and c.info_date=b.info_date)
    WHEN MATCHED THEN
    update set '||v_column_bid||'=:1,'||v_column_ask||'=:2 using v_bid,v_ask
    WHEN NOT MATCHED THEN
    INSERT
    CDS_TICKER ,
    INFO_DATE ,
    '||v_column_bid||' ,
    '||v_column_ask||' ,
    SOURCE
    VALUES (:1, :2,:3,:4,:5) ' using v_ticker,
    v_date ,
    v_bid ,
    v_ask ,
    v_source
    ---EXCEPTION
    ---when others then raise;
    end;
    when I launch hte procedure
    exec i_column_cds_fixings('TEST',trunc(sysdate-1),'8Y',4232.01,4234.02);
    I get
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    ORA-06512: at "OWNER_HISTO.I_COLUMN_CDS_FIXINGS", line 26
    ORA-06512: at line 1
    How can I deal with this
    Thanks
    babata
    I get

    Sorry
    this is formatted one
    REATE OR REPLACE PROCEDURE i_Column_cds_FixIngs
    (v_Ticker VARCHAR2,
    v_Date DATE,
    v_Tenor VARCHAR2,
    v_Bid NUMBER,
    v_Ask NUMBER)
    AS
    l_Column VARCHAR2(80);
    v_Column_Bid VARCHAR2(80);
    v_Column_Ask VARCHAR2(80);
    v_Source VARCHAR2(60) := 'CMAN@BBG';
    v_gen_Order PLS_INTEGER;
    BEGIN
    SELECT 'CDS_SPREAD_'
    ||v_Tenor
    ||'_BID'
    INTO v_Column_Bid
    FROM Dual;
    SELECT 'CDS_SPREAD_'
    ||v_Tenor
    ||'_ASK'
    INTO v_Column_Ask
    FROM Dual;
    dbms_Output.Put_Line(v_Ticker
    ||' '
    ||v_Column_Ask
    ||' '
    ||v_Column_Bid
    ||' '
    ||v_Bid
    ||' '
    ||v_Ask
    ||' '
    ||v_Date);
    EXECUTE IMMEDIATE 'MERGE into CDS_FIXINGS C
    using ( select v_ticker,'
    ||v_Column_Bid
    ||','
    ||v_Column_Ask
    ||',trunc(v_date) info_date ,v_bid,v_ask from dual ) B
    on (C.cds_ticker=b.v_ticker and c.info_date=b.info_date)
    WHEN MATCHED THEN
    update set '
    ||v_Column_Bid
    ||'=:1,'
    ||v_Column_Ask
    ||'=:2 USING v_bid,v_ask
    WHEN NOT MATCHED THEN
    INSERT
    CDS_TICKER ,
    INFO_DATE ,
    ||v_Column_Bid
    ||' ,
    ||v_Column_Ask
    ||' ,
    SOURCE
    VALUES
    :1,
    :2,
    :3,
    :4,
    :5
    USING v_Ticker,v_Date,v_Bid,v_Ask,v_Source;
    ---EXCEPTION
    ---when others then raise;
    END;
    /

  • 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 IN CLAUSE from Pro C code

    Hi Guys,
    Tyring to embed sql in Pro C. Here I don't know in hand how many items will be there in the IN Clause of my dynamic sql. Tried this with a loop and then adding actual values to the stement and then executing it. This worked but as this hard coding makes it literal sql and hence hampers performance. Can any one help me with how to put bind variables where we don't know how many of them will be there in a dynamic sql.
    Thanks,

    Dynamic SQL supports user defined types, try passing a collection and using TABLE(CAST(collection)) in the SQL statement.
    In the current approach (creating IN clause at runtime) keep in mind that in a IN clause you can put a maximum of 255 elements...
    Max

  • Dynamic SQL and use of aggregate functions

    Hello Forum members,
    I'm trying to create dynamic SQL in a function module and return the MAX value of a field. 
    I am passing in a parameter called CREATE_FIELD_NAME, and my SQL is
    SELECT MAX(CREATE_FIELD_NAME) INTO (CREATE_DATE) FROM (TABLE_NAME).
    I also tried:
    SELECT MAX((CREATE_FIELD_NAME)) INTO (CREATE_DATE) FROM (TABLE_NAME).
    But abap is not recognizing my variable as a variable in either case, but rather, as a field name.
    Anyone know a way around this?
    Thanks in advance,
    Jeff
    Here is my program:
    FUNCTION ZJLSTEST4.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(TABLE_NAME) LIKE  MAKT-MAKTX
    *"     VALUE(CREATE_FIELD_NAME) LIKE  MAKT-MAKTX
    *"     VALUE(UPDATE_FIELD_NAME) LIKE  MAKT-MAKTX
    *"  EXPORTING
    *"     VALUE(MAX_DATE) LIKE  SY-DATUM
    DATA: CREATE_DATE LIKE MCHA-ERSDA VALUE '19000101',
          UPDATE_DATE LIKE MCHA-LAEDA VALUE '19000101'.
    SELECT MAX(CREATE_FIELD_NAME) INTO (CREATE_DATE) FROM (TABLE_NAME).
    ENDSELECT.
    *SELECT MAX((UPDATE_FIELD_NAME)) INTO (UPDATE_DATE) FROM (TABLE_NAME).
    *ENDSELECT.
    IF CREATE_DATE > UPDATE_DATE.
       MAX_DATE = CREATE_DATE.
    ELSE.
       MAX_DATE = UPDATE_DATE.
    ENDIF.
    IF MAX_DATE = '19000101'.
    MAX_DATE = SY-DATUM.
    ENDIF.
    ENDFUNCTION.

    Max is right, you need the spaces, as in my example.
    You might like to try this:
    data: l_CREATE_FIELD_NAME) LIKE MAKT-MAKTX,
          l_UPDATE_FIELD_NAME) LIKE MAKT-MAKTX.
    DATA: CREATE_DATE LIKE MCHA-ERSDA VALUE '19000101',
    UPDATE_DATE LIKE MCHA-LAEDA VALUE '19000101'.
    concatenate 'MAX(' create_name ')' into l_create_name separated by space.
    concatenate 'MAX(' update_name ')' into l_update_name separated by space.
    SELECT SINGLE (l_CREATE_FIELD_NAME)
    INTO CREATE_DATE FROM (table_name).
    SELECT SINGLE (l_updATE_FIELD_NAME)
    INTO updATE_DATE FROM (table_name).
    IF CREATE_DATE > UPDATE_DATE.
    MAX_DATE = CREATE_DATE.
    ELSE.
    MAX_DATE = UPDATE_DATE.
    ENDIF.
    IF MAX_DATE = '19000101'.
    MAX_DATE = SY-DATUM.
    ENDIF.
    If it still fails please post the latest abap code for us to check.

  • Dynamic SQL and PL/SQL

    I have the following scenario:
    User Scott has two tables named USERINFO and EMP with the following description:
    desc USERINFO
    schema varchar2(30)
    desc EMP
    ename varchar2(30)
    empno number(4)
    User Blake has one table named EMP which looks like:
    desc EMP
    ename varchar2(30)
    I want to write a function which would copy the values from Scott's EMP table to Blake's EMP table but I want to get the user Blake's name from USERINFO's schema column. I figured I'd have to use dynamic SQL but am getting some errors when I execute the function. It compiles fine. Below is the code
    CREATE OR REPLACE FUNCTION CopyInfo()
    RETURN VARCHAR2 AS
    name VARCHAR22(30);
    target_schema VARCHAR2(30);
    ret_str CHAR := NULL;
    BEGIN
    SELECT schema INTO target_schema FROM version;
    SELECT ename INTO name FROM scott.emp WHERE empno = 7902;
    DECLARE
    sqlStmt VARCHAR2(1028);
    BEGIN
    sqlStmt := 'INSERT INTO ' || target_schema || '.emp VALUES( name )';
    execute SqlStmt ;
    END;
    ret_str := 't';
    RETURN ret_str;
    END CopyInfo
    When I create the function, it comes back with -
    Function created.
    when I try to execute I get an error as shown below:
    SQL>BEGIN
    2 DBMS_OUTPUT.PUT_LINE( CopyInfo());
    3 END;
    4 /
    ERROR at line 1:
    ORA-00984: column not allowed here
    ORA-06512: at "SCOTT.COPYINFO", line 13
    ORA-06512: at line 2
    Any idea, how to fix this ??? Thanks a lot....

    ---Sorry I meant userinfo not version in the code----
    I have the following scenario:
    User Scott has two tables named USERINFO and EMP with the following description:
    desc USERINFO
    schema varchar2(30)
    desc EMP
    ename varchar2(30)
    empno number(4)
    User Blake has one table named EMP which looks like:
    desc EMP
    ename varchar2(30)
    I want to write a function which would copy the values from Scott's EMP table to Blake's EMP table but I want to get the user Blake's name from USERINFO's schema column. I figured I'd have to use dynamic SQL but am getting some errors when I execute the function. It compiles fine. Below is the code
    CREATE OR REPLACE FUNCTION CopyInfo()
    RETURN VARCHAR2 AS
    name VARCHAR22(30);
    target_schema VARCHAR2(30);
    ret_str CHAR := NULL;
    BEGIN
    SELECT schema INTO target_schema FROM userinfo;
    SELECT ename INTO name FROM scott.emp WHERE empno = 7902;
    DECLARE
    sqlStmt VARCHAR2(1028);
    BEGIN
    sqlStmt := 'INSERT INTO ' || target_schema || '.emp VALUES( name )';
    execute SqlStmt ;
    END;
    ret_str := 't';
    RETURN ret_str;
    END CopyInfo
    When I create the function, it comes back with -
    Function created.
    when I try to execute I get an error as shown below:
    SQL>BEGIN
    2 DBMS_OUTPUT.PUT_LINE( CopyInfo());
    3 END;
    4 /
    ERROR at line 1:
    ORA-00984: column not allowed here
    ORA-06512: at "SCOTT.COPYINFO", line 13
    ORA-06512: at line 2
    Any idea, how to fix this ??? Thanks a lot....

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

  • 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

  • Strange behavior when searching a phrase using reg exp and dynamic sql

    Hi,
    I have a strange issue while using dynamic sql for an apex page. I have a requirement to search a string in the database column which is entered by user on a page item. The search process should search the whole phrase only.
    I have a query generated dynamically in the back end and use it in a cursor in the stored procedure
      SELECT t.group_cn , t.group_desc, t.group_type, t.partner_organization_id, t.partner_organization
      FROM vr_idm_group t WHERE regexp_like(t.group_desc,'(^|\W)HR Selection & Assignment(\W|$)', 'i')The pl sql code with the dynamic sql statements are below.
       IF p_search_process NOT in ('PARTNER') THEN
          OPEN v_cursor FOR v_sql;
       ELSE
          OPEN v_cursor FOR v_sql USING p_search_id;
       END IF;
       LOOP
          FETCH v_cursor INTo v_obj.group_cn, v_obj.group_desc, v_obj.group_type, v_obj.partner_organization_id,
             v_obj.partner_organization, v_obj.match_count;
          EXIT WHEN v_cursor%NOTFOUND ;
          v_search_array.extend;
          v_search_array(v_search_array.last) := v_obj;
          dbms_output.put_line(v_sql);
       END LOOP;The search works fine if the search string does not contain any special character like &,- etc.
    However, if the search string contains any special character, it does not return any thing. This strange issue happens only if I call the procedure from the apex page and the search string contains a special character. (please note that the procedure works fine even from apex if the string does not have a special character). When I debugged this, found that, the cursor does not fetch any rows (it is supposed to fetch two rows) for unknown reason. When I run the query separately, it returns the two rows (in which the column group_desc contains the search string "HR Selection & Assignment") as desired. Also, when I test the procedure in the back end (PLSQL developer), it works fine.
    Any idea, what is causing this strange behaviour?
    Advance thanks.
    Regards,
    Natarajan

    i don't see anything about a dataProvider.  you're assigning a source for a scrollpane.  scrollpane's don't have a dataProvider property.
    anyway, other than arrayRun always being false when that last if-statement executes, what's the problem?  doesn't that movieclip display when that 2nd branch of the last if-statement executes (assuming instance is defined correctly etc)?

  • ORA-01008 with ref cursor and dynamic sql

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

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

  • Insert into using a select and dynamic sql

    Hi,
    I've got hopefully easy question. I have a procedure that updates 3 tables with 3 different update statements. The procedure goes through and updates through ranges I pass in. I am hoping to create another table which will pass in those updates as an insert statement and append the data on to the existing data.
    I am thinking of using dynamic sql, but I am sure there is an easy way to do it using PL/SQL as well. I have pasted the procedure below, and what I'm thinking would be a good way to do it. Below I have pasted my procedure and the bottom is the insert statement I want to use. I am faily sure I can do it using dynamic SQL, but I am not familiar with the syntax.
    CREATE OR REPLACE PROCEDURE ACTIVATE_PHONE_CARDS (min_login in VARCHAR2, max_login in VARCHAR2, vperc in VARCHAR2) IS
    BEGIN
    UPDATE service_t SET status = 10100
    WHERE poid_id0 in
    (SELECT poid_id0 FROM service_t
    WHERE poid_type='/service/telephony'
    AND login >= min_login AND login <= max_login);
    DBMS_OUTPUT.put_line( 'Service Status:' || sql%rowcount);
    UPDATE account_t SET status = 10100
    WHERE poid_id0 IN
    (SELECT account_obj_id0 FROM service_t
    WHERE poid_type = '/service/telephony'
    AND login >= min_login AND login <= max_login);
    DBMS_OUTPUT.put_line( 'Account Status:' || sql%rowcount);
    UPDATE account_nameinfo_t SET title=Initcap(vperc)
    WHERE obj_id0 IN
    (SELECT account_obj_id0 FROM service_t
    WHERE poid_type='/service/telephony'
    AND login >=min_login AND login <= max_login);
    DBMS_OUTPUT.put_line('Job Title:' || sql%rowcount);
    INSERT INTO phone_card_activation values which = 'select a.status, s.status, s.login, to_char(d.sysdate,DD-MON-YYYY), ani.title
    from account_t a, service_t s, account_nameinfo_t ani, dual d
    where service_t.login between service_t.min_login and service_t.max_login
    and ani.for_key=a.pri_key
    and s.for_key=a.pri_key;'
    END;
    Thanks for any advice, and have a good weekend.
    Geordie

    Correct my if I am wrong but aren't these equal?
    UPDATE service_t SET status = 10100
    WHERE poid_id0 in
    (SELECT poid_id0 FROM service_t
    WHERE poid_type='/service/telephony'
    AND login >= min_login AND login <= max_login);
    (update all the records where there id is in the sub-query that meet the WHERE Clause)
    AND
    UPDATE service_t SET status = 10100
    WHERE poid_type='/service/telephony'
    AND login >= min_login AND login <= max_login);
    (update all the records that meet the WHERE Clause)
    This should equate to the same record set, in which case the second update would be quicker without the sub-query.

  • Difference between Static SQL Query and Dynamic SQL Query.

    Hi,
    Please explain the basic difference between static and dynamic sql queries. Please explain with example.

    Static: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/static.htm
    Dynamic: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/dynamic.htm

Maybe you are looking for

  • Blocking Vendor Payment Using F110

    Hi All, If I run F110 to pay a vendor, block one of the open items for payment, carry out the payment run, and start another payment run for the same vendor, will the open item that was blocked still be blocked? Will I have to unblock it? Thanks, Dek

  • How to arrange a backup set in RMAN

    I have configured the RMAN parametrs for my database. when I'm going to take the backups it gives an error called no backupset found screen is like this RMAN> BACKUP BACKUPSET ALL; Starting backup at 25-JUL-07 using channel ORA_DISK_1 RMAN-00571: ===

  • IMPLEMENTING GUI SATUS FOR THE LIST

    HI I am a newbie to ABAP and netweaver. I am currently studying BC400 and doing exercise 17. Unfortunately the whole explanation of how to add or remove functionaly from buttons (Save for instance) is very lacking. Can someone refer me to a better so

  • Missing startup script for version cue

    I'm having the problem where I don't seem to have the startup scripts for version cue in bridge. When I check the list of startup scripts in preferences, the other scripts all seem to be there like for contribute, fireworkds etc. However version cue

  • Where can i find some pixel bender 3d for flash tutorials ?

    where can i find some pixel bender 3d for flash tutorials ? anyone !?