Using DBMS_SQL.PARSE

Hi,
I am trying to write a proc. for dynamically saving data in a table.
My dynamic sql is stored in str_SQL (varchar2(4000) is more than 4000 char.
How can I use it.
DBMS_SQL.PARSE
(cur, str_Qry, DBMS_SQL.NATIVE);
What is the way out.
Regards
Deepak

I got your question and saying that all you need to do is this:
str_sql VARCHAR2(32000);Your concern as of now is that the value being assigned to str_sql can be more than 4000 characters, to which I am saying that increase the size of your variable as VARCHAR2 can go upto 32767 characters inside a PL/SQL block. This will solve your problem, assuming that the length of the query string is not more than 32000.
I have used it myself and that's why I am sure that this concern of yours will be addressed.
Thanks,
Ankur

Similar Messages

  • Error when using DBMS_SQL.parse

    Has anyone ever ran into this error "ORA-00932: inconsistent datatypes: expected NUMBER got DATE" when using DBMS_SQL.parse? I'm trying to pass in a sql statement that includes date columns but it keeps failing during the parse step. If I put a "to_char" around the dates it works fine.
    Any ideas?
    declare
        l_cursor   PLS_INTEGER;
        l_rows     PLS_INTEGER;
        l_col_cnt  PLS_INTEGER;
        l_desc_tab DBMS_SQL.desc_tab;
        l_buffer   CLOB;
        v_query    clob;
        l_file UTL_FILE.file_type;
        g_sep  VARCHAR2(5) := ',';
      BEGIN
        l_cursor := DBMS_SQL.open_cursor;
        v_query := 'SELECT CREATED FROM DBA_USERS';
        DBMS_SQL.parse(l_cursor, v_query, DBMS_SQL.native);
        DBMS_SQL.describe_columns(l_cursor, l_col_cnt, l_desc_tab);
        FOR i IN 1 .. l_col_cnt
        LOOP
          DBMS_SQL.define_column(l_cursor, i, l_buffer);
        END LOOP;
        l_rows := DBMS_SQL.execute(l_cursor);   
        -- Output the column names.
        FOR i IN 1 .. l_col_cnt
        LOOP
          IF i > 1 THEN
            UTL_FILE.put(l_file, g_sep);
          END IF;
          UTL_FILE.put(l_file, l_desc_tab(i).col_name);
        END LOOP;
        UTL_FILE.new_line(l_file);
        -- Output the data.
        LOOP
          EXIT WHEN DBMS_SQL.fetch_rows(l_cursor) = 0;
          FOR i IN 1 .. l_col_cnt
          LOOP
            IF i > 1 THEN
              UTL_FILE.put(l_file, g_sep);
            END IF;
            DBMS_SQL.COLUMN_VALUE(l_cursor, i, l_buffer);
            -- Check for column data type. If "character" data type enclose in quotes
            -- 1 = VARCHAR2 and NVARCHAR2, 96 = CHAR and NCHAR, 112 = CLOB
            IF l_desc_tab(i).col_type IN (1, 96, 112) THEN
              l_buffer := '"' || l_buffer || '"';
            END IF;
            UTL_FILE.put(l_file, l_buffer);
          END LOOP;
          UTL_FILE.new_line(l_file);
        END LOOP;
        UTL_FILE.fclose(l_file);
      EXCEPTION
        WHEN OTHERS THEN
          IF UTL_FILE.is_open(l_file) THEN
            UTL_FILE.fclose(l_file);
          END IF;
          IF DBMS_SQL.is_open(l_cursor) THEN
            DBMS_SQL.close_cursor(l_cursor);
          END IF;
          RAISE;
      END;Edited by: jpvybes on Jun 6, 2013 3:47 PM

    >
    Has anyone ever ran into this error "ORA-00932: inconsistent datatypes: expected NUMBER got DATE" when using DBMS_SQL.parse? I'm trying to pass in a sql statement that includes date columns but it keeps failing during the parse step. If I put a "to_char" around the dates it works fine.
    >
    No - it is NOT failing on the parse step. If you comment out various sections of the code you will find that your loop is causing the problem.
    Comment out this loop and there is NO exception.
        l_buffer   CLOB;
        FOR i IN 1 .. l_col_cnt
        LOOP
          DBMS_SQL.define_column(l_cursor, i, l_buffer);
        END LOOP;Do you now see the problem?
    You are using 'define_column' and passing 'l_buffer' which is a CLOB. But this is your query
        v_query := 'SELECT CREATED FROM DBA_USERS';And that 'CREATED' column in the query is a DATE.
    Why are you defining a column as a CLOB when the cursor column is a DATE?
    See the example3 in Chapter 100 DBMS_SQL in the Packages and Types doc. It shows an example that includes a DATE column.
    http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_sql.htm#i996963

  • Need to execute Long Insert (6000 characters)statement using dbms_sql.parse

    I built an insert statement which is more than 6000 (six thousand) characters stored into two varchar2 variables. I need to execute the statement using dbms_sql.parse.
    I tryed using dbms_sql.varchar2s variable and having no success.
    Any ideas or examples?
    Thanks
    JK

    6000 chars shouldn't be a problem.
    What do you mean with no success?Did you get any error?
    Any ideas or examples?See this thread
    Re: execute immediate with a string longer than 32767

  • APEX Insufficient Privs errors when trying to use dbms_sql.parse

    Hello,
    I have a simple database procedure that changes are user pswd:
    create or replace
    PROCEDURE chg_pswd_test(p_userid in varchar2,
    p_pswd in varchar2)
    -- Invoker rights allow a user with execute privileges to call a subprogram.
    -- Definer Rights allow programs to execute under the privileges of their
    -- definer / schema owner.
    AUTHID CURRENT_USER as x varchar2(20);
    v_cursor INTEGER;
    v_execute INTEGER;
    begin
    v_cursor := sys.DBMS_SQL.OPEN_CURSOR;
    sys.DBMS_SQL.PARSE(v_cursor, 'ALTER USER '||p_userid||' identified by '||p_pswd, sys.DBMS_SQL.NATIVE);
    v_execute := sys.DBMS_SQL.EXECUTE(v_cursor);
    sys.DBMS_SQL.CLOSE_CURSOR(v_cursor);
    commit;
    end chg_pswd_test;
    I can run this procedure in sqlplus as user x and also as my apex_public_user. I have granted both execute on dbms_sql and alter user privs. It runs for both without problems.
    I then create a validation process in APEX can call this database procedure. I then receive insufficient privs errors.
    If I grant all privs to public, the apex app will then run, if I remove all privs I receive the errors again.
    Does anyone know which database priv I am missing, I cannot grant all privs to public on my production database?
    Thanks

    Odd, as I would think that should work, being the DBA role and all...
    If it works as user X from SQL*Plus, could you try to change the parsing schema to User X and try again?
    Thanks,
    - Scott -
    http://spendolini.blogspot.com
    http://sumnertechnologies.com

  • DBMS_SQL.PARSE with PL/SQL types

    Hi
    I need to use DBMS_SQL.PARSE with PL/SQL types defined in a package.
    I tried with a type record in a declare ..begin..end  script but I got an error ..(on second parameter):
    DBMS_SQL.PARSE(cursor_name, XXXXX, DBMS_SQL.NATIVE);
    It's possible?
    WIth SQL types defined at schema level it's works (es. Objects types) .
    If it's not possible, how can I resolve?
    Stefano

    Again, please post what XXXXX is. In order to use package declared types:
    SQL> create or replace
      2    package pkg1
      3      is
      4        type emp_rec
      5          is record (
      6                     empno number,
      7                     ename varchar2(10)
      8                    );
      9        type emp_rec_tbl
    10          is
    11            table of emp_rec
    12            index by pls_integer;
    13        g_emp_rec_tbl pkg1.emp_rec_tbl;
    14  end;
    15  /
    Package created.
    SQL> declare
      2      v_cur integer;
      3      v_sql varchar2(1000);
      4  begin
      5      v_cur := dbms_sql.open_cursor(2);
      6      v_sql := 'begin
      7                    select  empno,
      8                            ename
      9                      bulk  collect
    10                       into  pkg1.g_emp_rec_tbl
    11                       from  emp
    12                       where job = ''CLERK'';
    13                end;';
    14      dbms_sql.parse(
    15                     v_cur,
    16                     v_sql,
    17                      dbms_sql.native
    18                     );
    19  end;
    20  /
    PL/SQL procedure successfully completed.
    SQL>
    SY.

  • DBMS_SQL.PARSE + CLOB

    Hi,
    I am using:
    DBMS_SQL.PARSE ( c IN INTEGER, statement IN VARCHAR2, language_flag IN INTEGER);
    I have to parse very very big pl/sql blocks. So I have to put into statement, paremeter which has CLOB type.
    When my statement is not too big everything works well. But when my block has 5200 lines it gives me error:
    numeric or value error.
    I think my block is too big...
    can anybody help me?
    how to fix ma problem?
    Grzegorz

    hi all,
    I have the same problem with some differences
    when the string is too big it give me error no parse statement
    this not happened when the string is less than 4000 char
    when I assign my string (with clob datatype) to the variable l_lines (DBMS_SQL.varchar2s datatype) it give me error: PLS-00382: expression is of wrong type
    I use oracle 10g
    thanks

  • Error while executing query longer thank 32K using dbms_sql

    Hi,
    I'm using oracle database version is 10.2.0.4.0
    I've a query of size 41K.
    I can't run it with execute immediate, so when I'm running it with dbms_sql I'm getting error -
    ORA-06502: PL/SQL: numeric or value error.
    But when I'm running it in my pl/sql developer it is running fine.
    Code snippet is below
    -- Created on 24/05/2010 by TSHARMA
    declare
    -- Local variables here
    cursor_name INTEGER;
    i integer;
    tc clob;
    begin
    -- Test statements here
    select col1 into tc from temp where a1 = 't1'; --getting the long query from a temp table
    tc := 'create table temp1 as ' || tc;
    cursor_name := dbms_sql.open_cursor;
    DBMS_SQL.PARSE(cursor_name, tc, DBMS_SQL.NATIVE);
    i := DBMS_SQL.EXECUTE(cursor_name);
    DBMS_SQL.CLOSE_CURSOR(cursor_name);
    end;
    -------------------------------

    Hi,
    DBMS_SQL.PARSE is overloaded to accept a VARCHAR2A as the statement parameter. This is a table of VARCHAR2(32767) which can be built up using your long query. I've written the following to handle long CLOB's. Just call the execute_sql procedure passing in the long sql:
    PROCEDURE execute_sql (p_sql IN CLOB) IS
       l_sql_table DBMS_SQL.VARCHAR2a;
       l_ds_cursor PLS_INTEGER;
       l_ret_val   PLS_INTEGER;
    BEGIN
       l_sql_table := populate_sql_table(p_sql => p_sql);
       l_ds_cursor := DBMS_SQL.OPEN_CURSOR;
       DBMS_SQL.PARSE(l_ds_cursor, l_sql_table, l_sql_table.FIRST, l_sql_table.LAST, FALSE, DBMS_SQL.NATIVE);
       l_ret_val := DBMS_SQL.EXECUTE(l_ds_cursor);
       DBMS_SQL.CLOSE_CURSOR(l_ds_cursor);
    END execute_sql;
    FUNCTION populate_sql_table (p_sql IN CLOB) RETURN DBMS_SQL.VARCHAR2a IS
       l_buffer_length CONSTANT PLS_INTEGER := 32767;
       l_lob_length PLS_INTEGER;
       l_offset PLS_INTEGER := 1;
       l_amount PLS_INTEGER := l_buffer_length;
       l_sql_table DBMS_SQL.VARCHAR2a;
    BEGIN
       l_sql_table.DELETE;
       l_lob_length := DBMS_LOB.GETLENGTH(p_sql);
       LOOP
          IF l_buffer_length > l_lob_length THEN
             l_amount := l_lob_length;
          END IF;
          l_sql_table(NVL(l_sql_table.LAST, 0) + 1) := DBMS_LOB.SUBSTR(p_sql, l_amount, l_offset);
          l_offset := l_offset + l_buffer_length;
          l_lob_length := l_lob_length - l_amount;
          IF l_lob_length <= 0 THEN
             EXIT;
          END IF;
       END LOOP;
       RETURN(l_sql_table);
    END populate_sql_table;Hope that helps

  • How to make dynamic query using DBMS_SQL variable column names

    First of all i will show a working example of what i intend to do with "EXECUTE IMMEDIATE":
    (EXECUTE IMMEDIATE has 32654 Bytes limit, which isn't enough for me so i'm exploring other methods such as DBMS_SQL)
    -------------------------------------------------CODE-----------------------------------
    create or replace PROCEDURE get_dinamic_query_content
    (query_sql IN VARCHAR2, --any valid sql query ('SELECT name, age FROM table') 
    list_fields IN VARCHAR2) --list of the columns name belonging to the query (  arr_list(1):='name';   arr_list(2):='age';
    -- FOR k IN 1..arr_list.count LOOP
    -- list_fields := list_fields || '||content.'||arr_list(k)||'||'||'''~cs~'''; )
    AS
    sql_stmt varchar (30000);
    BEGIN
                   sql_stmt :=
    'DECLARE
         counter NUMBER:=0;     
    auxcontent VARCHAR2(30000);     
         CURSOR content_cursor IS '|| query_sql ||';
         content content_cursor%rowtype;     
         Begin
              open content_cursor;
              loop
                   fetch content_cursor into content;
                   exit when content_cursor%notfound;
                   begin                              
                        auxcontent := auxcontent || '||list_fields||';                    
                   end;
                   counter:=counter+1;     
              end loop;
              close content_cursor;
              htp.prn(auxcontent);
         END;';
    EXECUTE IMMEDIATE sql_stmt;
    END;
    -------------------------------------------------CODE-----------------------------------
    I'm attepting to use DBMS_SQL to perform similar instructions.
    Is it possible?

    Hi Pedro
    You need to use DBMS_SQL here because you don't know how many columns your query is going to have before runtime. There are functions in DBMS_SQL to get information about the columns in your query - all this does is get the name.
    SQL&gt; CREATE OR REPLACE PROCEDURE get_query_cols(query_in IN VARCHAR2) AS
    2 cur PLS_INTEGER;
    3 numcols NUMBER;
    4 col_desc_table dbms_sql.desc_tab;
    5 BEGIN
    6 cur := dbms_sql.open_cursor;
    7 dbms_sql.parse(cur
    8 ,query_in
    9 ,dbms_sql.native);
    10 dbms_sql.describe_columns(cur
    11 ,numcols
    12 ,col_desc_table);
    13 FOR ix IN col_desc_table.FIRST .. col_desc_table.LAST LOOP
    14 dbms_output.put_line('Column ' || ix || ' is ' ||
    15 col_desc_table(ix).col_name);
    16 END LOOP;
    17 dbms_sql.close_cursor(cur);
    18 END;
    19 /
    Procedure created.
    SQL&gt; exec get_query_cols('SELECT * FROM DUAL');
    Column 1 is DUMMY
    PL/SQL procedure successfully completed.
    SQL&gt; exec get_query_cols('SELECT table_name, num_rows FROM user_tables');
    Column 1 is TABLE_NAME
    Column 2 is NUM_ROWS
    PL/SQL procedure successfully completed.
    SQL&gt; exec get_query_cols('SELECT column_name, data_type, low_value, high_value FROM user_tab_cols');
    Column 1 is COLUMN_NAME
    Column 2 is DATA_TYPE
    Column 3 is LOW_VALUE
    Column 4 is HIGH_VALUE
    PL/SQL procedure successfully completed.I've just written this as a procedure that prints out the column names using dbms_output - I guess you're going to do something different with the result - maybe returning a collection, which you'll then parse through in Apex and print the output on the screen - this is just to illustrate the use of dbms_sql.
    best regards
    Andrew
    UK

  • How to handle error while using dbms_sql.execute

    Hi,
    I am inserting some records by using the following piece of code.
    stmt := 'insert into SSI_KPI_GOAL_VALUE_H (KPI_VAL_KPI_ID, KPI_VAL_RM_CDE,'|| v_day_value ||',KPI_VAL_ACT_DLY,'||v_month_val||',KPI_VAL_BIZ_UNIT_CDE) values (:kpi_array,:rm_array,:day1_array,:day1_array,:day1_array,:busnunit_array)';
    l := dbms_sql.open_cursor;
         dbms_sql.parse(l, stmt, dbms_sql.native);
         dbms_sql.bind_array(l, ':kpi_array', col1_ins,1,ins_cnt-1);
         dbms_sql.bind_array(l, ':rm_array', col2_ins,1,ins_cnt-1);
         dbms_sql.bind_array(l, ':day1_array', col3_ins,1,ins_cnt-1);
         dbms_sql.bind_array(l, ':busnunit_array', col4_ins,1,ins_cnt-1);     
         dummy := dbms_sql.execute(l);
         dbms_sql.close_cursor(l);
    I am getting an error since any one of the row contains value larger than the column.
    How to handle exception handling for those rows which is having errors. I would like insert the records which is having
    no errors. Like SAVE EXCEPTIONS for 'forall' is there any option is available to handle exceptional records.
    Please help.
    Thanks & Regards,
    Hari.

    Hari,
    What's oracle version? Are you looking for something similar to this? see following example
    DECLARE
       TYPE array
       IS
          TABLE OF my_objects%ROWTYPE
             INDEX BY BINARY_INTEGER;
       data          array;
       errors        NUMBER;
       dml_errors exception;
       error_count   NUMBER := 0;
       PRAGMA EXCEPTION_INIT (dml_errors, -24381);
       CURSOR mycur
       IS
          SELECT *
          FROM t;
    BEGIN
       OPEN mycur;
       LOOP
          FETCH mycur BULK COLLECT INTO data LIMIT 100;
          BEGIN
             FORALL i IN 1 .. data.COUNT
             SAVE EXCEPTIONS
                INSERT INTO my_new_objects
                VALUES data (i);
          EXCEPTION
             WHEN dml_errors
             THEN
                errors        := sql%BULK_EXCEPTIONS.COUNT;
                error_count   := error_count + errors;
                FOR i IN 1 .. errors
                LOOP
                   DBMS_OUTPUT.put_line(   'Error occurred during iteration '
                                        || sql%BULK_EXCEPTIONS(i).ERROR_INDEX
                                        || ' Oracle error is '
                                        || sql%BULK_EXCEPTIONS(i).ERROR_CODE);
                END LOOP;
          END;
          EXIT WHEN c%NOTFOUND;
       END LOOP;
       CLOSE mycur;
       DBMS_OUTPUT.put_line (error_count || ' total errors');
    END;Regards
    OrionNet

  • Problem using DBMS_SQL in a form

    hi,
    I am trying to write a procedure which get an input string containing a SQL statement (a SELECT), executes it, fetches the rows and writes them into a Excel sheet. I found this article http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sql.htm describing how to use DBMS_SQL package. My goal is to parse my query and store result in an array (using DEFINE_ARRAY).
    I put theese two lines
    (declare c number;)
    c := dbms_sql.open_cursor;
    dbms_sql.parse(c,p_query,dbms_sql.native); (p_query is my input string containing SQL)
    But when I compile my program unit I get an error looking like that: "implementation restriction: DBMS_SQL.NATIVE: unable to access a remote package variable or cursor".
    Where is the error? should I set something to access the package, or is it not possible to use it inside a form?

    W1zard is correct. Switch to Exec_SQL. Oracle does not support Forms using DBMS_SQL.
    Now... please explain why you are not using a dynamic record group. It is SOOO much easier!
    And if you want to look at some code using both methods, Exec_SQL and dynamic record group, you can download my "Quick Access" dynamic utility form, here:   Oracle Forms Utilities

  • DBMS_SQL.PARSE

    Hi Team ,
    The below inesrt query returns an error message " exact fetch returns more than one row " . How can I found the insert query statement on the below query in the DBMS_SQL.PARSE ?
    Code :
    v_query(1) := 'insert into ' || gv_table_name || ' ' ;
    v_query(2) :=' select ';
    v_query(3) := v_counter || '+ rownum , ';
    v_query(4) :='''020'' || ';
    v_query(5) :='lpad(p.fixed_cont_code,11,''0'') || ';
    v_query(6) :='rpad(NVL(ref.bridge_code_1,'' ''),15,'' '') || ';
    v_query(7) :='rpad(NVL(ref.bridge_code_2,'' ''),15,'' '') || ';
    v_query(8) :='rpad(NVL(ref.bridge_code_3,'' ''),15,'' '') || ';
    v_query(9) :='LPAD(NVL(ref.bridge_code_4,'' ''),15,'' '') || ';
    v_query(10) :='LPAD(NVL(ref.bridge_code_5,'' ''),15,'' '') || ';
    v_query(11) :='LPAD(NVL(ref.bridge_code_6,'' ''),15,'' '') || ';
    v_query(12) :='LPAD(NVL(ref.bridge_code_7,'' ''),15,'' '') || ';
    v_query(13) :='LPAD(NVL(ref.bridge_code_8,'' ''),15,'' '') || ';
    v_query(14) :='LPAD(NVL(ref.bridge_code_9,'' ''),15,'' '') || ';
    v_query(15) :='LPAD(NVL(ref.bridge_code_10,'' ''),15,'' '') || ';
    v_query(16) :='rpad(prn.prod_short_name,80,'' '') || ';
    v_query(17) :='rpad(nvl(p.pack_description,'' ''),80,'' '') || ';
    v_query(18) :='lpad(NVL(get_prod_org_code(p.market_abbr,p.prod_code,''' || GV_PERIOD_START_DATE ||'''),''0''),5,''00'') || ';
    --v_query(19) :='lpad(''0'',5,''0'') || ';
    v_query(19) :='lpad(NVL(get_prod_org_dist_code(p.market_abbr,p.prod_code,''' || GV_PERIOD_START_DATE ||'''),''0''),5,''00'') || ';
    v_query(20) :='RPAD(NVL(trim(ref.class_code_1),''Z98A2''),12,'' '') || ';
    v_query(21) :='RPAD(NVL(trim(ref.class_code_2),''98A2Z''),12,'' '') || ';
    v_query(22) :='RPAD(NVL(ref.class_code_3,'' ''),12,'' '') || ';
    v_query(23) :='RPAD(NVL(ref.class_code_4,'' ''),12,'' '') || ';
    v_query(24) :='RPAD(NVL(ref.class_code_5,'' ''),12,'' '') || ';
    v_query(25) :='RPAD(NVL(ref.class_code_6,'' ''),12,'' '') || ';
    v_query(26) :='RPAD(NVL(ref.class_code_7,'' ''),12,'' '') || ';
    v_query(27) :='RPAD(NVL(ref.class_code_8,'' ''),12,'' '') || ';
    v_query(28) :='RPAD(NVL(ref.class_code_9,'' ''),12,'' '') || ';
    v_query(29) :='RPAD(NVL(ref.class_code_10,'' ''),12,'' '') || ';
    v_query(30) :='RPAD(NVL(ref.class_code_11,'' ''),12,'' '') || ';
    v_query(31) :='RPAD(NVL(ref.class_code_12,'' ''),12,'' '') || ';
    v_query(32) :='RPAD(NVL(ref.class_code_13,'' ''),12,'' '') || ';
    v_query(33) :='RPAD(NVL(ref.class_code_14,'' ''),12,'' '') || ';
    v_query(34) :='RPAD(NVL(ref.class_code_15,'' ''),12,'' '') || ';
    v_query(35) :='RPAD(NVL(ref.prod_flag_1,'' ''),12,'' '') || ';
    v_query(36) :='RPAD(NVL(ref.prod_flag_2,'' ''),12,'' '') || ';
    v_query(37) :='RPAD(NVL(ref.prod_flag_3,'' ''),12,'' '') || ';
    v_query(38) :='RPAD(NVL(ref.prod_flag_4,'' ''),12,'' '') || ';
    v_query(39) :='RPAD(NVL(ref.prod_flag_5,'' ''),12,'' '') || ';
    v_query(40) :='RPAD(NVL(ref.prod_flag_6,'' ''),12,'' '') || ';
    v_query(41) :='RPAD(NVL(ref.prod_flag_7,'' ''),12,'' '') || ';
    v_query(42) :='RPAD(NVL(ref.prod_flag_8,'' ''),12,'' '') || ';
    v_query(43) :='RPAD(NVL(ref.prod_flag_9,'' ''),12,'' '') || ';
    v_query(44) :='RPAD(NVL(ref.prod_flag_10,'' ''),12,'' '') || ';
    v_query(45) :='RPAD(NVL(ref.prod_flag_11,'' ''),12,'' '') || ';
    v_query(46) :='RPAD(NVL(ref.prod_flag_12,'' ''),12,'' '') || ';
    v_query(47) :='RPAD(NVL(ref.prod_flag_13,'' ''),12,'' '') || ';
    v_query(48) :='RPAD(NVL(ref.prod_flag_14,'' ''),12,'' '') || ';
    v_query(49) :='RPAD(NVL(ref.prod_flag_15,'' ''),12,'' '') || ';
    v_query(50) :='RPAD(NVL(ref.prod_flag_16,'' ''),12,'' '') || ';
    v_query(51) :='RPAD(NVL(ref.prod_flag_17,'' ''),12,'' '') || ';
    v_query(52) :='RPAD(NVL(ref.prod_flag_18,'' ''),12,'' '') || ';
    v_query(53) :='RPAD(NVL(ref.prod_flag_19,'' ''),12,'' '') || ';
    v_query(54) :='RPAD(NVL(ref.prod_flag_20,'' ''),12,'' '') || ';
    v_query(55) :='RPAD(NVL(ref.prod_flag_21,'' ''),12,'' '') || ';
    v_query(56) :='RPAD(NVL(ref.prod_flag_22,'' ''),12,'' '') || ';
    v_query(57) :='RPAD(NVL(ref.prod_flag_23,'' ''),12,'' '') || ';
    v_query(58) :='RPAD(NVL(ref.prod_flag_24,'' ''),12,'' '') || ';
    v_query(59) :='RPAD(NVL(ref.prod_flag_25,'' ''),12,'' '') || ';
    v_query(60) :='RPAD(NVL(ref.pack_flag_1,'' ''),12,'' '') || ';
    v_query(61) :='RPAD(NVL(ref.pack_flag_2,'' ''),12,'' '') || ';
    v_query(62) :='RPAD(NVL(ref.pack_flag_3,'' ''),12,'' '') || ';
    v_query(63) :='RPAD(NVL(ref.pack_flag_4,'' ''),12,'' '') || ';
    v_query(64) :='RPAD(NVL(ref.pack_flag_5,'' ''),12,'' '') || ';
    v_query(65) :='RPAD(NVL(ref.pack_flag_6,'' ''),12,'' '') || ';
    v_query(66) :='RPAD(NVL(ref.pack_flag_7,'' ''),12,'' '') || ';
    v_query(67) :='RPAD(NVL(ref.pack_flag_8,'' ''),12,'' '') || ';
    v_query(68) :='RPAD(NVL(ref.pack_flag_9,'' ''),12,'' '') || ';
    v_query(69) :='RPAD(NVL(ref.pack_flag_10,'' ''),12,'' '') || ';
    v_query(70) :='RPAD(NVL(ref.pack_flag_11,'' ''),12,'' '') || ';
    v_query(71) :='RPAD(NVL(ref.pack_flag_12,'' ''),12,'' '') || ';
    v_query(72) :='RPAD(NVL(ref.pack_flag_13,'' ''),12,'' '') || ';
    v_query(73) :='RPAD(NVL(ref.pack_flag_14,'' ''),12,'' '') || ';
    v_query(74) :='RPAD(NVL(ref.pack_flag_15,'' ''),12,'' '') || ';
    v_query(75) :='RPAD(NVL(ref.pack_flag_16,'' ''),12,'' '') || ';
    v_query(76) :='RPAD(NVL(ref.pack_flag_17,'' ''),12,'' '') || ';
    v_query(77) :='RPAD(NVL(ref.pack_flag_18,'' ''),12,'' '') || ';
    v_query(78) :='RPAD(NVL(ref.pack_flag_19,'' ''),12,'' '') || ';
    v_query(79) :='RPAD(NVL(ref.pack_flag_20,'' ''),12,'' '') || ';
    v_query(80) :='RPAD(NVL(ref.pack_flag_21,'' ''),12,'' '') || ';
    v_query(81) :='RPAD(NVL(ref.pack_flag_22,'' ''),12,'' '') || ';
    v_query(82) :='RPAD(NVL(ref.pack_flag_23,'' ''),12,'' '') || ';
    v_query(83) :='RPAD(NVL(ref.pack_flag_24,'' ''),12,'' '') || ';
    v_query(84) :='RPAD(NVL(ref.pack_flag_25,'' ''),12,'' '') || ';
    v_query(85) :='nvl(lpad(NVL(ref.pack_price_1,''0''),13,''0''),''0000000000000'') || ';
    v_query(86) :='nvl(ref.effective_date_1,''00000000'') || ';
    v_query(87) :='nvl(lpad(NVL(ref.pack_price_2,''0''),13,''0''),''0000000000000'') || ';
    v_query(88) :='nvl(ref.effective_date_2,''00000000'') || ';
    v_query(89) :='nvl(lpad(NVL(ref.pack_price_3,''0''),13,''0''),''0000000000000'') || ';
    v_query(90) :='nvl(ref.effective_date_3,''00000000'') || ';
    v_query(91) :='nvl(lpad(NVL(ref.pack_price_4,''0''),13,''0''),''0000000000000'') || ';
    v_query(92) :='nvl(ref.effective_date_4,''00000000'') || ';
    v_query(93) :='nvl(lpad(NVL(ref.pack_price_5,''0''),13,''0''),''0000000000000'') || ';
    v_query(94) :='nvl(ref.effective_date_5,''00000000'') || ';
    v_query(95) :='nvl(lpad(NVL(ref.pack_price_6,''0''),13,''0''),''0000000000000'') || ';
    v_query(96) :='nvl(ref.effective_date_6,''00000000'') || ';
    v_query(97) :='nvl(lpad(NVL(ref.pack_price_7,''0''),13,''0''),''0000000000000'') || ';
    v_query(98) :='nvl(ref.effective_date_7,''00000000'') || ';
    v_query(99) :='nvl(lpad(NVL(ref.pack_price_8,''0''),13,''0''),''0000000000000'') || ';
    v_query(100) :='nvl(ref.effective_date_8,''00000000'') || ';
    v_query(101) :='nvl(lpad(NVL(ref.pack_price_9,''0''),13,''0''),''0000000000000'') || ';
    v_query(102) :='nvl(ref.effective_date_9,''00000000'') || ';
    v_query(103) :='nvl(lpad(NVL(ref.pack_price_10,''0''),13,''0''),''0000000000000'') || ';
    v_query(104) :='nvl(ref.effective_date_10,''00000000'') || ';
    v_query(105) :='lpad(nvl(NDF_PAV(p.market_abbr,p.fixed_cont_code,''PEF'',''' || GV_PERIOD_START_DATE ||'''),''0''),15,''0'') || ';
    v_query(106) :='RPAD(''0'',15,''0'') || ';
    v_query(107) :='lpad(nvl(NDF_PAV(p.market_abbr,p.fixed_cont_code,''QLIM'',''' || GV_PERIOD_START_DATE ||'''),''0''),15,''0'') || ';
    v_query(108) :='NVL(TO_CHAR(PRD.PROD_LAUNCH_DATE,''YYYYMMDD''),''00000000'') || ';
    v_query(109) :='NVL(TO_CHAR(PCKD.PACK_LAUNCH_DATE,''YYYYMMDD''),''00000000'') || ';
    v_query(110) :='NVL(TO_CHAR(PACK_OUT_OF_TRADE_DATE,''YYYYMMDD''),''00000000'') || ';
    v_query(111) :='nvl(ref.study_connection_1,'' '') || ';
    v_query(112) :='nvl(ref.study_connection_2,'' '') || ';
    v_query(113) :='nvl(ref.study_connection_3,'' '') || ';
    v_query(114) :='nvl(ref.study_connection_4,'' '') || ';
    v_query(115) :='nvl(ref.study_connection_5,'' '') || ';
    v_query(116) :='nvl(ref.study_connection_6,'' '') || ';
    v_query(117) :='nvl(ref.study_connection_7,'' '') || ';
    v_query(118) :='nvl(ref.study_connection_8,'' '') || ';
    v_query(119) :='nvl(ref.study_connection_9,'' '') || ';
    v_query(120) :='nvl(ref.study_connection_10,'' '') || ';
    v_query(121) :='nvl(ref.study_connection_11,'' '') || ';
    v_query(122) :='nvl(ref.study_connection_12,'' '') || ';
    v_query(123) :='nvl(ref.study_connection_13,'' '') || ';
    v_query(124) :='nvl(ref.study_connection_14,'' '') || ';
    v_query(125) :='nvl(ref.study_connection_15,'' '') || ';
    v_query(126) :='nvl(ref.study_connection_16,'' '') || ';
    v_query(127) :='nvl(ref.study_connection_17,'' '') || ';
    v_query(128) :='nvl(ref.study_connection_18,'' '') || ';
    v_query(129) :='nvl(ref.study_connection_19,'' '') || ';
    v_query(130) :='nvl(ref.study_connection_20,'' '') || ';
    v_query(131) :='nvl(rpad(ndf_pmcc(p.market_abbr,p.fixed_cont_code,''' || v_market_abbr ||'FD'',''' || GV_PERIOD_START_DATE ||'''),20,'' ''),lpad('' '',20,'' '')) || ';
    v_query(132) :='LPAD(NVL(PACK_SIZE,''0''),8,''0'') || ';
    v_query(133) :='''00000'' || ';
    v_query(134) :='rpad(NVL(decode(rpad(nvl(p.weight_unit_absolute_strength,''0''),2,''0''),''00'',''0000'',lpad(nvl(to_char(p.absolute_strength_measure),''0''),4,''0'')),''0000''),4,'' '') || ';
    v_query(135) :=' '' '' || rpad(nvl(p.weight_unit_absolute_strength,'' ''),2,'' '') || ';
    v_query(136) :='decode(rpad(nvl(p.weight_unit_absolute_strength,''0''),2,''0''),''00'',''00000000'',lpad(nvl(to_char(p.absolute_strength_measure*1000),''0''),8,''0'')) || ';
    v_query(137) :='RPad(nvl(p.weight_unit_absolute_strength,'' ''),5,'' '') || ';
    v_query(138) :='decode(rpad(nvl(p.weight_unit_relative_strength,''0''),2,''0''),''00'',''00000000'',lpad(nvl(to_char(p.relative_strength_measure*1000),''0''),8,''0'')) || ';
    v_query(139) :='RPad(nvl(p.weight_unit_relative_strength,'' ''),5,'' '') || ';
    v_query(140) :='''00000000'' || ';
    v_query(141) :=''' '' || ';
    v_query(142) :='''00000000'' || ';
    v_query(143) :=''' '' || ';
    v_query(144) :='decode(pack_weight_measure,null,''00000000'',lpad(pack_weight_measure*1000,8,''0'')) || ';
    v_query(145) :='rpad(nvl(p.weight_unit_pack,'' ''),5,'' '') || ';
    v_query(146) := 'rpad(nvl( ' ;
    v_query(147) := 'ndf_pmcc(p.market_abbr, ' ;
    v_query(148) := ' p.fixed_cont_code, ' ;
    v_query(149) := '''ADDST'', ''' ;
    v_query(150) := GV_PERIOD_START_DATE ||'''), '' '')' ;
    v_query(151) := ' ,12,'' '' ) || ' ;
    v_query(152) :='rpad(nvl(p.ndf_pack_add_info,'' ''),8,'' '') || ';
    v_query(153) :='nvl(decode(p.pin_elh_status,''ACTIVE'','' '',''Z'' ),'' '') || lpad('' '',100,'' '') ';
    v_query(154) :='from pack p , PROD_NAME prn, PROD_DATE PRD, PACK_DATE PCKD, prod,';
    v_query(155) :=' lpin_cpi_20_ref_data ref ';
    v_query(156) :=' where ';
    v_query(157) :=' p.market_abbr = ''' || v_market_abbr ||''' and ';
    v_query(158) :=' p.market_abbr = ref.market_abbr and';
    v_query(159) :=' p.fixed_cont_code = ref.fixed_cont_code and';
    v_query(160) :=' p.PIN_ELH_STATUS <> ''RESEARCH'' and';
    v_query(161) :=' prod.prod_code = p.prod_code and';
    v_query(162) :=' prod.market_abbr = p.market_abbr and';
    v_query(163) :=' prod.PIN_ELH_STATUS <> ''RESEARCH'' and';
    v_query(164) :=' NDF_confmkt2 (p.market_abbr,p.fixed_cont_code,''' || GV_PERIOD_START_DATE ||''')>0 and ';
    v_query(165) :=' p.market_abbr = prn.market_abbr and';
    v_query(166) :=' p.prod_code = prn.prod_code and';
    v_query(167) :=' p.market_abbr = PRD.market_abbr and';
    v_query(168) :=' p.prod_code = PRD.prod_code AND';
    v_query(169) :=' p.market_abbr = PCKD.market_abbr and';
    v_query(170) :=' p.FIXED_CONT_CODE = PCKD.FIXED_CONT_CODE';
    v_query(171) :=' AND row_current_check (prd.valid_from_date, prd.valid_to_date, ''' || GV_PERIOD_START_DATE ||''') = 0';
    v_query(172) :=' AND row_current_check (prn.valid_from_date, prn.valid_to_date, ''' || GV_PERIOD_START_DATE ||''') = 0';
    v_query(173) :=' AND row_current_check (pckd.valid_from_date, pckd.valid_to_date, ''' || GV_PERIOD_START_DATE ||''') = 0';
    v_query(174) :=' order by p.fixed_cont_code ';
    DBMS_SQL.PARSE (v_cursor_handle, v_query,1,174,TRUE,dbms_sql.native);
    gv_total_packs :=dbms_sql.execute(v_cursor_handle);
    DBMS_SQL.CLOSE_CURSOR (v_cursor_handle);

    I will not even begin to try to help you ... here's why.
    1. You did not read the FAQ and learn the proper way to post to the forums using tags for listings.
    2. I have on idea what your version number is.
    3. I'm not going to read a kilometer of code to try to find an issue ... create a simple test case that recreates the issue.
    4. You didn't think the error important enough to post so I've no idea what is actually going on.
    Please fix this thread and likely I or someone else will be able to help you.
    But why are you using DBMS_SQL and not native dynamic SQL? That is really my first question.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • DBMS_SQL.PARSE Not Accepting My Query

    hi all ,
    i am trying to generate a ascii file from my procedure ..
    my ascii file should contain data like the below
    "7200", "SMITH","10-AUG-1981"
    DBMS_SQL.PARSE(l_cursor,'SELECT '"'||empno||'"'||','||'"'||ename||'"'||','||'"'||dob||'"'FROM EMP',dbms_sql.native);
    PLS-00103: Encountered the symbol "'||empno||'" when expecting one of the
    following:
    ) , * & | = - + < / > at in is mod remainder not rem => ..
    please give me any idea how to resolve this ..

    One sec ..i have again a small doubt can we pass parameters to this query
    DBMS_SQL.PARSE(l_cursor,q'[SELECT '"'||empno||'","'||ename||'","'||dob||'"' FROM EMP]',dbms_sql.native);
    i want to include where condition like FROM_DATE >= P_FROM_DATE
    TO_DATE <=P_TO_DATE
    These P_FROM_DATE and P_TO_DATE i am passing as input parameters to my procedures ..can i use them inside this query ?

  • DBMS_SQL.PARSE Question

    Hi,
    From the PL/SQL packages doc:
    DBMS_SQL.PARSE Procedure
    This procedure parses the given statement in the given cursor.
    All statements are parsed immediately. In addition, DDL
    statements are run immediately when parsed.Any reason as to why DDL statements are executed when passed
    to DBMS_SQL.PARSE ?
    Rgds.
    Amogh

    I think you are asking for alternate of dbms_sql.parse,
    so you can use native dynamic sql:
    SQL> create or replace procedure exec_ddl
      2  as
      3  begin
      4    execute immediate 'create table sample_table(x varchar2(1))' ;
      5  end;
      6  /
    Procedure created.
    SQL> exec exec_ddl
    PL/SQL procedure successfully completed.
    SQL> desc sample_table
    Name                                      Null?    Type
    X                                                  VARCHAR2(1)

  • Using DBMS_SQL getting ORA-29255

    Sort of new to DBMS_SQL - as I've been using NDS for almost everything to this point.
    However - I have a situation where I'm selecting data that requires a predicate of multiple values for a single column (i.e. column in (:v1)) where :v1 is a list of values. I was using bind_array to set the values for :v1. However - I get the error above.
    The SQL returns mutiple rows so - define array is being used to indicate what column should be returned to what array.
    I understand based on the error message that they can't be used together. So- my question is - when using a SQL statement that requires "columnA IN (multiple_values)" how are you supposed to bind those using DBMS_SQL?
    Any help is appreciated!!

    Thanks... Code is below...
    You can see where the vspccat is a predicate and - we're trying to get the multiple values 'bound' to the SQL. However - the sql also returns multiple rows (hence the 'define array' to get the return values).
    We're using DBMS_SQL over NDS simply because (as isn't illustrated in the example below - which I was using just to get the concept working in an example to use moving forward with the actual code I will need to write) I'm needing to use multiple varrying predicates depending on the situation and - this is a cleaner way to handle that - rather than tracking what's been dynamically written and - handling it with every possible scenario in many different executes (with the different 'using's' attached).
    Your help is appreciated!
    DECLARE
    col1    NUMBER(9,0);
    col2    VARCHAR2(15);
    col3    VARCHAR2(15);
    col4    VARCHAR2(60);
    col5    DATE;
    col6    DATE;
    col7    VARCHAR2(6);
    col8    NUMBER(9,0);
    col9    VARCHAR2(1);
    spc_cat_array   DBMS_SQL.VARCHAR2_TABLE;
    col1_array      DBMS_SQL.NUMBER_TABLE;
    col2_array      DBMS_SQL.VARCHAR2_TABLE;
    col3_array      DBMS_SQL.VARCHAR2_TABLE;
    col4_array      DBMS_SQL.VARCHAR2_TABLE;
    col5_array      DBMS_SQL.DATE_TABLE;
    col6_array      DBMS_SQL.DATE_TABLE;
    col7_array      DBMS_SQL.VARCHAR2_TABLE;
    col8_array      DBMS_SQL.NUMBER_TABLE;
    col9_array      DBMS_SQL.VARCHAR2_TABLE;
    p_spc_cat   VARCHAR2(15) := '03';
    p_status    VARCHAR2(6)  := 'APPROV';
    src_cur  INTEGER;
    dest_cur INTEGER;
    ignore   INTEGER;
    fdbk     INTEGER;
    l_sql   VARCHAR2(1000);
    dest_rec    VARCHAR2(500);
    BEGIN
        spc_cat_array(1) := '03';
        spc_cat_array(2) := '09';    
        spc_cat_array(3) := '35';
        l_sql := ' SELECT *' ||
                      ' FROM (SELECT maint_id, NULL AS ica_price_rule, spc_category, description,' ||
                                   ' effective_date, term_date, status,' ||
                                   ' seq_ica_spc_pr_whole AS sequence_id, update_type' ||
                              ' FROM ica_spc_pr_whole_hdr_wrk' ||
                                ' WHERE spc_category IN (:vspccat)' ||
                                ' AND status = :vstatus  ' ||
                                ' AND term_date IS NULL' ||
                             ' UNION ALL' ||
                            ' SELECT NULL AS maint_id, NULL AS ica_price_rule, spc_category,' ||
                                   ' description, effective_date, term_date, status,' ||
                                   ' seq_ica_spc_pr_whole AS sequence_id, NULL AS update_type' ||
                              ' FROM ica_spc_pr_whole_hdr live'  ||
                                ' WHERE spc_category IN (:vspccat)' ||
                                ' AND status = :vstatus  ' ||
                                ' AND term_date IS NULL' ||
                               ' AND NOT EXISTS (SELECT spc_category' ||
                                                 ' FROM ica_spc_pr_whole_hdr_wrk wrk' ||
                                                ' WHERE wrk.spc_category = live.spc_category)) a';
        -- open cursor on source table
      src_cur := dbms_sql.open_cursor;
      -- parse the SELECT statement
      dbms_sql.parse(src_cur, l_sql, dbms_sql.NATIVE);
      -- Bind Variables
    --  DBMS_SQL.BIND_VARIABLE (src_cur, ':vspccat', p_spc_cat);
      DBMS_SQL.BIND_ARRAY (src_cur, ':vspccat', spc_cat_array);
      DBMS_SQL.BIND_VARIABLE (src_cur, ':vstatus', p_status);
      -- define the column type
      dbms_sql.define_array(src_cur, 1, col1_array, 5, 1);
      dbms_sql.define_array(src_cur, 2, col2_array, 5, 1);
      dbms_sql.define_array(src_cur, 3, col3_array, 5, 1);
      dbms_sql.define_array(src_cur, 4, col4_array, 5, 1); 
      dbms_sql.define_array(src_cur, 5, col5_array, 5, 1);
      dbms_sql.define_array(src_cur, 6, col6_array, 5, 1);
      dbms_sql.define_array(src_cur, 7, col7_array, 5, 1);
      dbms_sql.define_array(src_cur, 8, col8_array, 5, 1);
      dbms_sql.define_array(src_cur, 9, col9_array, 5, 1);
      ignore := dbms_sql.execute(src_cur);
      if dbms_sql.fetch_rows(src_cur) > 0  then
              dbms_sql.column_value( src_cur, 1, col1_array);
              dbms_sql.column_value( src_cur, 2, col2_array);
              dbms_sql.column_value( src_cur, 3, col3_array);
              dbms_sql.column_value( src_cur, 4, col4_array);
              dbms_sql.column_value( src_cur, 5, col5_array);
              dbms_sql.column_value( src_cur, 6, col6_array);
              dbms_sql.column_value( src_cur, 7, col7_array);
              dbms_sql.column_value( src_cur, 8, col8_array);
              dbms_sql.column_value( src_cur, 9, col9_array);         
          end if;
        dbms_output.put_line(col3_array(1));
      dbms_sql.close_cursor(src_cur);
    end;

  • Dbms_sql.parse: varchar2a version does NOT throw ORA-24344

    I'm trying to execute some generated code in 10.2. using the varchar2a version of dbms_sql.parse.
    This works fine, but when the there is something wrong in the generated code, I do not get an exception (I do get it with the varchar2 version).
    So when I run the following example, the first call to dbms_sql.parse creates an invalid package, but only the second call will actually throw an exception:
    DECLARE
      v_cur INTEGER;
      v_sql dbms_sql.varchar2a;
    BEGIN
      v_cur := DBMS_SQL.open_cursor;
      v_sql(1) := 'CREATE OR REPLACE PACKAGE xxx AS a ###; END;'; -- invalid SQL
      dbms_sql.parse(v_cur, v_sql, 1, 1, FALSE, dbms_sql.native);
      dbms_output.put_line ('ERROR: should have failed');
      dbms_sql.parse(v_cur, v_sql(1), dbms_sql.native);
      dbms_sql.close_cursor(v_cur);
    EXCEPTION
      WHEN OTHERS THEN
        dbms_sql.close_cursor( v_cur );
        dbms_output.put_line ('OK: ' || SQLERRM );
    END;
    Can anybody reproduce/explain this?
    Thanks!

    Here is the code I am running ...
    CREATE OR REPLACE PROCEDURE p_sql_valid_or_not_cnt
    (vSQL IN VARCHAR2, vValid OUT NUMBER, vMessage OUT VARCHAR2, vCount OUT NUMBER) IS
    -- Purpose: Returns 0 in vvalid if SQL is valid, else returns -1. Returns row count when SQL is valid.
    -- Parameters:
    -- IN : vSQL
    -- OUT : vValid
    -- OUT : vMessage
    -- OUT : vCount
    cur INTEGER := DBMS_SQL.OPEN_CURSOR;
    fdbk INTEGER;
    BEGIN
    DBMS_SQL.PARSE (cur, vSQL, DBMS_SQL.NATIVE);
    fdbk := DBMS_SQL.EXECUTE (cur);
    vCount := 0;
    LOOP /* Fetch next row. Exit when done. */
    EXIT WHEN DBMS_SQL.FETCH_ROWS (cur) = 0;
    vCount := vCount + 1;
    END LOOP;
    vValid := 0;
    vMessage := 'No errors';
    DBMS_SQL.CLOSE_CURSOR (cur);
    END p_sql_valid_or_not_cnt;
    To run ...
    set serveroutput on
    declare
    i number;
    m varchar2(500);
    c number;
    begin
    p_sql_valid_or_not_cnt('SELECT * FROM TAB where 1 <> 1',i,m,c);
    DBMS_OUTPUT.PUT_LINE(i);
    DBMS_OUTPUT.PUT_LINE(m);
    DBMS_OUTPUT.PUT_LINE(c);
    end;
    This runs fine.
    But when I try to access an object from a remote server using DB link. I get the error ...
    set serveroutput on
    declare
    i number;
    m varchar2(500);
    c number;
    begin
    p_sql_valid_or_not_cnt('SELECT * FROM REMOTE_SCHEMA.T_REMOTE@REMOTE_SERVER where 1 <> 1',i,m,c);
    DBMS_OUTPUT.PUT_LINE(i);
    DBMS_OUTPUT.PUT_LINE(m);
    DBMS_OUTPUT.PUT_LINE(c);
    end;
    declare
    ERROR at line 1:
    ORA-24374: define not done before fetch or execute and fetch
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 1125
    ORA-06512: at "SYS.DBMS_SQL", line 328
    ORA-06512: at "IMEPAS.P_SQL_VALID_OR_NOT_CNT", line 16
    ORA-06512: at line 6
    I can run the SQL that I am passing as vSQL directly in SQLPLUS ...
    This code in itself works.
    SELECT * FROM
    REMOTE_SCHEMA.T_REMOTE@REMOTE_SERVER
    where 1 <> 1;
    The user I am using to logon to my server is also there on REMOTE_SERVER.
    The DB LINK is created by CONNECTED USER option. The user on REMOTE_SERVER has explict select access on the table (not via role) I am accessing.
    Any help would be much appreciated.

Maybe you are looking for

  • What's wrong with executing procedure in package???

    I am new to SQL Developer. I had developed a PL/SQL package<br> (called COMMON_SQL) and compiled<br> in my database. I could see my package in USER_OBJECTS<br><p> COMMON_SQL          13966          PACKAGE     03-APR-07     03-APR-07     2007-04-03:2

  • Jump Query

    In my sender query(Sales Cube) I have variable as order creation date (I enter a range as 01/01/2006 to 01/10/2006) and do a jump to get the details of delivery dates (delivery Cube), now the issue is delivery can be as early as 01/01/2006 to current

  • ORA-00942 error in simple stored proc

    Guys, I'm trying to learn to write some procedures in oracle and have started with the following; CREATE OR REPLACE PROCEDURE sp__who IS BEGIN FOR rec IN (SELECT s.SID, s.serial#, p.spid, s.osuser, s.program, s.status FROM v$process p, v$session s WH

  • What is the time period covered by "show statistics application"

    Hi, I'm checking the "show stat app" & "show stat app savings" from the cli of one of our remote site WAEs.  In order to really make sense of what I'm seeing, what time period will these commands cover? Thanks Claire

  • Please help me on this palindrome program

    import java.io.*; public class lab16b2 public static void main (String args[]) throws IOException           BufferedReader input = new BufferedReader(new InputStreamReader(System.in));           boolean finished = false;           clearScreen(31);