Obtaining a collection as a return from an execute immediate pl/sql block

version 10.2
I need to obtain the collection back from the execute immediate of a pl/sql block:
procedure block(owner varchar2) is
stmt                   long;
objecttab_coll         dbms_stats.objecttab;
begin
stmt := '
   begin
    dbms_stats.gather_schema_stats(''' || owner || '''
     ,options => ''LIST AUTO''
     ,objlist => :objecttab_coll
   end;'; 
execute immediate stmt returning into objecttab_coll;
-- do more stuff here
end block;I have tried this + a few variations but with no luck. In looking through the docs I do not see an example. can this be done?
Thanks
Ox

I dont find any need for an execute immediate here. This must be just enough.
procedure block(owner varchar2)
is
     objecttab_coll         dbms_stats.objecttab;
begin
     dbms_stats.gather_schema_stats(ownname => owner, options => 'LIST AUTO', objlist => objecttab_coll);
     -- do more stuff here
end block;Thanks,
Karthick.

Similar Messages

  • How to see the data from the execute immediate o/p

    Hello
    i tried the following code
    SQL> declare
      2  vSql varchar2(3000);
      3  begin
      4  vSql:='SELECT';
      5   for i in (select column_name from user_tab_columns where table_name='EMP' order by column_name
      6   loop
      7     vSql:=vSql||i.column_name||',';
      8   end loop;
      9   execute immediate rtrim(vSql)||' '||'from emp';
    10  end;
    11  /
    declare
    ERROR at line 1:
    ORA-00900: invalid SQL statement
    ORA-06512: at line 9Please guide me to solve this error
    Edited by: josh1612 on Jun 22, 2010 3:58 AM

    josh1612 wrote:
    I need to execute that printed statment select ... from emp
    You are already executing it by using:
    execute immediate rtrim(vSql,',')||' from emp';What you probably want is to display results, right? Then you can either use bulk collect into clause in execute immediate or use cursor variable. Bulk collect example:
    set serveroutput on
    declare
      vSql varchar2(3000);
      type emp_rec_tbl_type is table of emp%rowtype;
      emp_rec_tbl emp_rec_tbl_type;
    begin
      vSql:='SELECT ';
       for i in (select column_name from user_tab_columns where table_name='EMP' order by column_id)
       loop
         vSql:=vSql||i.column_name||',';
       end loop;
       dbms_output.put_line(rtrim(vSql,',')||' from emp');
       execute immediate rtrim(vSql,',')||' from emp' bulk collect into emp_rec_tbl;
       for i in 1..emp_rec_tbl.count loop
         dbms_output.put_line(rpad(emp_rec_tbl(i).ename,10) || emp_rec_tbl(i).sal);
       end loop;
    end;
    SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO from emp
    SMITH     800
    ALLEN     1600
    WARD      1250
    JONES     2975
    MARTIN    1250
    BLAKE     2850
    CLARK     2450
    SCOTT     3000
    KING      5000
    TURNER    1500
    ADAMS     1100
    JAMES     950
    FORD      3000
    MILLER    1300
    PL/SQL procedure successfully completed.
    SQL> Cursor variable example:
    set serveroutput on
    declare
      vSql varchar2(3000);
      emp_rec emp%rowtype;
      cv sys_refcursor;
    begin
      vSql:='SELECT ';
       for i in (select column_name from user_tab_columns where table_name='EMP' order by column_id)
       loop
         vSql:=vSql||i.column_name||',';
       end loop;
       dbms_output.put_line(rtrim(vSql,',')||' from emp');
       open cv for rtrim(vSql,',')||' from emp';
       loop
         fetch cv into emp_rec;
         exit when cv%notfound;
         dbms_output.put_line(rpad(emp_rec.ename,10) || emp_rec.sal);
       end loop;
       close cv;
    end;
    SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO from emp
    SMITH     800
    ALLEN     1600
    WARD      1250
    JONES     2975
    MARTIN    1250
    BLAKE     2850
    CLARK     2450
    SCOTT     3000
    KING      5000
    TURNER    1500
    ADAMS     1100
    JAMES     950
    FORD      3000
    MILLER    1300
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Select from Function PIPELINED on PL/SQL Block

    Hi folks,
    I have a PL/SQL Block and I need this block to show me in a grid the rows from a variable table (Type table) that I have declared.
    I don´t want to create Database objects, that's why I haven´t created tableTest like a type object in the database.
    Example:
    Declare
    type tableTest is table of varchar2(500);
    function test(indName IN VARCHAR2) return tableTest PIPELINED as
    begin
    pipe row (indName);
    pipe row ('teste2');
    return
    end;
    begin
    -- HERE I NEED SHOW ROWS RETURNED BY FUNCTION WAS DECLARED;
    -- Select * from TABLE(test('NAME'));
    end;

    You declare a pipelined table function by specifying the PIPELINED keyword. Pipelined functions can be defined at the schema level with CREATE FUNCTION or in a package. The PIPELINED keyword indicates that the function returns rows iteratively. The return type of the pipelined table function must be a supported collection type, such as a nested table or a varray. This collection type can be declared at the schema level or inside a package. Inside the function, you return individual elements of the collection type. The elements of the collection type must be supported SQL datatypes, such as NUMBER and VARCHAR2. PL/SQL datatypes, such as PLS_INTEGER and BOOLEAN, are not supported as collection elements in a pipelined function.
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm

  • Dyn sql execute immediate  A plsql block returning sql%rowcount of rows inserted

    I would like to get the number of rows inserted in a dynamic sql statement like following.
    execute immediate
    'begin insert into a(c1,c2,c3)
    (select ac1,ac2,ac3 from ac where ac1=:thekey
    UNION select tc1,tc2,tc3 from tc where tc1=:otherkey); end;' using in key1,in key2;
    I have tried per the oracle8i dyn sql chapter in doc RETURN sql%rowcount won't compile.
    also add this to statement 'returning sql%rowcount into :rowcount'
    no luck.
    any ideas.?
    thanks.

    Quick comment first - I'm not sure why you are even using dynamic SQL here. There is nothing dynamic about your statement. It is equivalent to just:
    insert into a (c1, c2, c3)
      select ac1, ac2, ac3
        from ac
       where ac1 = key1
      UNION
      select tc1, tc2, tc3
        from tc
       where tc1 = key2;Unless you are really dynamically changing a table or column name here and just didn't show it in your example, you certainly don't want the overhead of NDS for this insert in this situation.
    In any case, you just need to evaluate SQL%ROWCOUNT in the next statement.
    insert ...;
    if sql%rowcount = 0 then
      -- nothing was inserted
    end if;

  • Resolved: Use value from select list in pl/sql block

    Hello,
    I have a form with a select list: P18_BONUSTYPE, the values of which come from a LOV.
    When the user clicks a button, a page process is used to insert a row into a table.
    When I use the :P18_BONUSTYPE bind variable in my insert statement I get an error "Invalid number" I get an "Invalid number" error. I assume that APEX is using the displayed text in that bind variable, not its actual (html option) value.
    I checked the HTML of the page, and the correct values are in the select list.
    Can someone tell me how to get the value into a bind variable that can be used in a pl/sql block for a page process?
    Thanks
    Message was edited by:
    Neeko
    Issue was a value in another item.

    Did you tried changing the value using "to_number"? (i.e. to_number(:P18_BONUSTYPE)).
    Max.

  • How to compare a boolean value returned from a function in a sql query

    Hi all
    i have a function which return boolean true or false.
    mean while i am writing a sql query which should check this function and will return a result set only when it is true. how will i use a function which returns boolean in a sql query..
    thanks in advance'
    Hari

    I don't think this is possible - i'm not sure. Can you post your function script? The reason why am i asking this is --
    satyaki>set serveroutput on
    satyaki>
    satyaki>
    satyaki>
    satyaki>create or replace function test_satf(emno in number)
      2  return boolean
      3  is
      4    v_cnt   number(5);
      5    v_flg   boolean;
      6  begin
      7    select count(*)
      8    into v_cnt
      9    from emp
    10    where empno = emno;
    11   
    12    if v_cnt = 1 then
    13       v_flg := TRUE;
    14    else
    15       v_flg := FALSE;
    16    end if;
    17   
    18    return v_flg;
    19  exception
    20    when others then
    21      v_flg := FALSE;
    22   return v_flg;
    23  end;
    24  /
    Function created.
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>desc emp;
    Name                                      Null?    Type
    EMPNO                                     NOT NULL NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    satyaki>
    satyaki>
    satyaki>
    satyaki>select count(*) from emp;
      COUNT(*)
            14
    satyaki>
    satyaki>select empno,test_satf(empno)
      2  from emp;
    select empno,test_satf(empno)
    ERROR at line 1:
    ORA-06552: PL/SQL: Statement ignored
    ORA-06553: PLS-382: expression is of wrong type
    satyaki>select to_char(test_satf(empno))
      2  from emp;
    select to_char(test_satf(empno))
    ERROR at line 1:
    ORA-06552: PL/SQL: Statement ignored
    ORA-06553: PLS-382: expression is of wrong type
    satyaki>
    satyaki>create or replace function test_satf(emno in number)
      2  return varchar2
      3  is
      4    v_cnt   number(5);
      5    v_flg   varchar2(10);
      6  begin
      7    select count(*)
      8    into v_cnt
      9    from emp
    10    where empno = emno;
    11   
    12    if v_cnt = 1 then
    13       v_flg := 'TRUE';
    14    else
    15       v_flg := 'FALSE';
    16    end if;
    17   
    18    return v_flg;
    19  exception
    20    when others then
    21      v_flg := 'FALSE';
    22   return v_flg;
    23  end;
    24  /
    Function created.
    satyaki>
    satyaki>
    satyaki>select test_satf(empno)
      2  from emp;
    TEST_SATF(EMPNO)
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TEST_SATF(EMPNO)
    TRUE
    TRUE
    TRUE
    14 rows selected.Or, may be i'm missing something.
    Regards.
    Satyaki De.

  • Error while selecting  from nested table in PL/SQL block ............

    SQL> create type string_table is table of varchar(100);
    2 /
    Type created.
    declare
    v_names string_table := string_table();
    begin
    v_names.EXTEND(3);
    v_names(1) := 'name1';
    v_names(2) := 'name2';
    v_names(3) := 'name3';
    dbms_output.put_line(v_names(1));
    dbms_output.put_line(v_names(2));
    dbms_output.put_line(v_names(3));
    dbms_output.put_line(v_names.COUNT());
    select * from table(v_names);
    end;
    select * from table(v_names);
    ERROR at line 12:
    ORA-06550: line 12, column 7:
    PLS-00428: an INTO clause is expected in this SELECT statement

    select * from table(v_names);
    I guess ,here you were trying to put the content of the NT into another NT, or just trying to print it.
    But, I don't think INTO Clause is mandatory here.
    Please check your modified code (w/o INTO) and the output :
    DECLARE
       TYPE string_table IS TABLE OF VARCHAR (100);
       v_names   string_table := string_table ();
       v_test    string_table := string_table ();
    BEGIN
       v_names.EXTEND (3);
       v_names (1) := 'name1';
       v_names (2) := 'name2';
       v_names (3) := 'name3';
       DBMS_OUTPUT.put_line ('Old collection - '||v_names (1));
       DBMS_OUTPUT.put_line ('Old collection - '||v_names (2));
       DBMS_OUTPUT.put_line ('Old collection - '||v_names (3));
       DBMS_OUTPUT.put_line ('Old collection - '||v_names.COUNT ());
       DBMS_OUTPUT.put_line (CHR(10));
       /* SELECT * FROM TABLE (v_names); */
       v_test := v_names;
       DBMS_OUTPUT.put_line ('New collection -- '||v_test (1));
       DBMS_OUTPUT.put_line ('New collection -- '||v_test (2));
       DBMS_OUTPUT.put_line ('New collection -- '||v_test (3));
       DBMS_OUTPUT.put_line ('New collection -- '||v_test.COUNT ());
       DBMS_OUTPUT.put_line (CHR(10));
       /* Printing using FOR LOOP */
       FOR i IN v_test.FIRST..v_test.LAST
       LOOP
         DBMS_OUTPUT.put_line ('In FOR Loop --- '||v_test (i));
       END LOOP;
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line ('Error ' ||SQLERRM|| DBMS_UTILITY.format_error_backtrace);
    END;gives o/p :
    Old collection - name1
    Old collection - name2
    Old collection - name3
    Old collection - 3
    New collection -- name1
    New collection -- name2
    New collection -- name3
    New collection -- 3
    In FOR Loop --- name1
    In FOR Loop --- name2
    In FOR Loop --- name3Refer this link -- http://docs.oracle.com/cd/E11882_01/appdev.112/e17126/tuning.htm#CIHGGBGF
    Edited by: ranit B on Dec 26, 2012 2:29 PM
    -- code modified
    Edited by: ranit B on Dec 26, 2012 2:45 PM
    -- code 'again' updated -- FOR LOOP added

  • Count rows returned in a subquery in pl/sql block

    Hi,
    I'm working on a trigger in Oracle 11 to check that a student has met prerequisites before enrolling in a class. I need to determine how many rows came back on the query in order to determine if I should raise an exception or not. The following is raising the exception if the prereqs are complete or not. I've haven't included the code in the where clause because I've tested is seperately and get good results. I know this is limiited info, but is there some obvious mistake I've made here?
    CREATE OR REPLACE TRIGGER prereq
    BEFORE INSERT ON enrollment
    FOR EACH ROW
    DECLARE
      howmany  number;
    BEGIN
      select count(*)
      into howmany
      from dual
      where exists ((insert code here that returns 0 rows if prerequisites are not met);
      if howmany = 0 then
        raise_application_error(-20000, 'The prerequisites for this course are not complete');
      end if;
    end;
    /

    As you are selecting from dual you might hit no_data_found if the exist caluse doesnot return any row.
    Try this,
    CREATE OR REPLACE TRIGGER prereq
       BEFORE INSERT
       ON enrollment
       FOR EACH ROW
    DECLARE
       howmany        NUMBER;
    BEGIN
       SELECT COUNT (*) INTO howmany FROM DUAL;
                   WHERE EXISTS ((INSERT code here that returns 0 ROWS IF prerequisites are NOT met);
    EXCEPTION
       WHEN NO_DATA_FOUND
       THEN
          raise_application_error (-20000
                                  ,'The prerequisites for this course are not complete');
    END;You dont need count(*) from dual you can simply use
    SELECT 1 INTO howmany FROM DUAL;
                   WHERE EXISTS ...G.

  • Using RETURNING clause with Execute Immediate

    I wrote a query to update a table and return the column in to a nested table type variable using returning clause but its not working I am getting error like
    ORA-06550: line 66, column 22:
    PLS-00306: wrong number or types of arguments in call to '||'
    ORA-06550: line 66, column 4:
    PL/SQL: Statement ignored
    I am getting error in following part of my query
    || 'RETURNING if_row_status bulk collect INTO '
    || v_if_row_status;
    v_if_row_status is defined as -
    TYPE v_count IS TABLE OF varchar2(50) INDEX BY BINARY_INTEGER;
    v_if_row_status v_count;

    I am trying to update a table for diffrent column if they are null and want no of column updated for each column.
    I wrote following query but I am not getting the correct output.
    UPDATE
    Temp_Bulk_Col_POC
    SET if_row_status = 'VALIDATED',
    if_row_processed_date = sysdate,
    if_row_error_msg =
    CASE
    WHEN record_type IS NULL
    THEN 'RECORD_TYPE is a required column and cannot be NULL'
    WHEN source_system IS NULL
    THEN 'SOURCE_SYSTEM is a required column and cannot be NULL'
    WHEN record_company IS NULL
    THEN 'RECORD_COMPANY is a required column and cannot be NULL'
    WHEN record_system IS NULL
    THEN 'RECORD_SYSTEM is a required column and cannot be NULL'
    WHEN txn_flag IS NULL
    THEN 'TXN_FLAG is a required column and cannot be NULL'
    WHEN create_date IS NULL
    THEN 'CREATE_DATE is a required column and cannot be NULL'
    WHEN UPDATE_date IS NULL
    THEN 'UPDATE_DATE is a required column and cannot be NULL'
    WHEN source_customer_id IS NULL
    THEN 'SOURCE_CUSTOMER_ID is a required column and cannot be NULL'
    WHEN source_product_id IS NULL
    THEN 'SOURCE_PRODUCT_ID is a required column and cannot be NULL'
    WHEN az_product_id IS NULL
    THEN 'AZ_PRODUCT_ID is a required column and cannot be NULL'
    WHEN decile IS NULL
    THEN 'DECILE is a required column and cannot be NULL'
    END
    WHERE if_row_status IS NULL
    AND (record_type IS NULL
    OR source_system IS NULL
    OR record_company IS NULL
    OR record_system IS NULL
    OR txn_flag IS NULL
    OR create_date IS NULL
    OR UPDATE_date IS NULL
    OR source_customer_id IS NULL
    OR source_product_id IS NULL
    OR az_product_id IS NULL
    OR decile IS NULL)
    RETURNING if_row_status,record_type,source_system,record_company,record_system,
    txn_flag,create_date,UPDATE_date,source_customer_id,source_product_id,az_product_id,
    decile
    BULK COLLECT INTO
    v_if_row_status,v_record_type,v_source_system,
    v_record_company,v_record_system,v_txn_flag,v_create_date,v_UPDATE_date,
    v_source_customer_id,v_source_product_id,v_az_product_id,v_decile;
    its showing same number for all the column.
    how I can collect based on the coulmn updated

  • Return code for EXECUTE PROCEDURE (native SQL)

    Hi Experts,
    I've seen in the Note 364707 that the field %_ERRCODE is no longer supported since WAS 6.10 for stored procedures like this:
    EXEC SQL.
      EXECUTE PROCEDURE proc [(parameter list)] %_ERRCODE INTO :rc
    ENDEXEC.
    So an Upgrade to WAS 7.00 gives this programms an error.
    Has anybody an idea for an alternative?
    Regards,
    Stefan

    Hello Peluka,
    i have seen you have worked with 'execute procedure'.
    I want to execute a procedure with two Parameters and one structure. Example:
    EXECUTE PROCEDURE test.p_getdata ( in :i_ls_nr , in :vdatum , out :vtest ).
    vtest has the simple structure with field lieferscheinnr (char25).
    When i execute the procedure, i get the error <b>wrong number or types of arguments in call</b>.
    Do you know, whether execute procedure with structures is not possible?
    Thank you in advance.

  • Some "formula" interpreter or returning value from unnamed PL/Sql blocks

    Hello,
    My company is developing Payroll and HR software and we use Oracle 10G Database. For a new module we are looking for a system were the end user (power user) can put in some kind of "formula's" to define what info/figures he wants for certain calculations done by de module (the budget module calculations will be done in PL/SQL stored proc written by us).
    Example: item "MonthlySalaryCost" = (BaseYearSal + TotalBonus)/12
    Where BaseYearSal and TotalBonus are functions that exist our will exist in or database. The idea is that a PL/SQL proc (which will be the same for all our customers), at runtime will execute that "formula" and use the result in its further calculations. The "formulas" will be stored in a table. (I foresee of course a "formula" validation to prevent dangerous sql-injection).
    My idea was to use Execute Immediate in the proc to execute the formula's and work with the results. In this approach we have to write (and foresee) all possible functions to access the data the user wants to use.
    Another (more powerful) solution I think about, is seeing these "formula's" as unnamed PL/SQL blocks (stored in a table), were the end user (or consultant) can use the full power of PL/SQL (if then else, select into ..., etc..) to obtain the result he wants to return into the item.
    My problem here is : how to return a value from a unnamed PL/SQL block that is executed via Execute Immediate in a stored proc ?
    And a general question: what do you think of this approach ? are there others possibilities to do this ?
    Thanks in advance,
    Philippe.

    Hi,
    Welcome to the forum!
    This is a simple example:
    Some functions to test:
    CREATE OR REPLACE FUNCTION f_test1 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 12;
       RETURN(RESULT);
    END f_test1;
    CREATE OR REPLACE FUNCTION f_test2 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 10;
       RETURN(RESULT);
    END f_test2;
    CREATE OR REPLACE PACKAGE pack_test_functions IS
       PROCEDURE proc_test;
    END pack_test_functions;
    CREATE OR REPLACE PACKAGE BODY pack_test_functions IS
       PROCEDURE proc_test IS
          v_sql    VARCHAR2(4000);
          v_result NUMBER;
       BEGIN
          v_sql := 'SELECT F_TEST1() + F_TEST2() FROM DUAL';
          EXECUTE IMMEDIATE v_sql
             INTO v_result;
          dbms_output.put_line(v_result);
       END proc_test;
    END pack_test_functions;
    /into v_result you have the result of the operation.
    Regards,

  • How to Return From Call to Stored Procedure

    I created an SQL Query Report portlet which contains a Delete
    link next to each record. If the user clicks on the link, it
    calls a JavaScript function which confirms the Delete and then
    calls a stored procedure which deletes the record. After the
    record is deleted, I get a page with,
    "No data returned from stored procedure
    The PL/SQL gateway invoked a stored procedure as part of
    processing the URL but the procedure returned no data."
    How can I get rid of this page and just return to the page that
    contains my report portlet after the stored procedure executes?
    Fran

    Hi Michael,
    I tried the following at the end of my procedure, but I still
    got the error page instead of the page containing the report
    portlet:
    --- return to calling page
    owa_util.redirect_url('http://pmim1a:7778/servlet/page?
    pageid=55&dad=portal30&_schema=PORTAL30');
    Fran

  • Delete From More than 1 table without using execute immediate

    Hi,
    Am new to PL/SQL, I had been asked to delete few of the table for my ETL jobs in Oracle 10G R2. I have to delete(truncate) few tables and the table names are in another table with a flag to delete it or not. So, when ever I run the job it should check for the flag and for those flag which is 'Y' then for all those tables should be deleted without using the Execute Immediate, because I dont have privilages to use "Execute Immediate" statement.
    Can anyone help me in how to do this.
    Regards
    Senthil

    Then tell you DBA's, or better yet their boss, that they need some additional training in how Oracle actually works.
    Yes, dynamic sql can be a bad thing when it is used to generate hundreds of identical queries that differ ony in the literals used in predicates, but for something like a set of delte table statements or truncate table statements, dynamic sql is no different in terms of the effect on the shared pool that hard coding the sql statements.
    This is a bad use of dynamic sql, because it generates a lot of nearly identical statements due to the lack of bind variables. It is the type of thing your DBA's should, correctly, bring out the lead pipe for.
    DECLARE
       l_sql VARCHAR2(4000);
    BEGIN
       FOR r in (SELECT account_no FROM accounts_to_delete) LOOP
          l_sql := 'DELETE FROM accounts WHERE account_no = '||r.account_no;
          EXECUTE IMMEDIATE l_sql;
       END LOOP;
    END;This will result in one sql statement in the shared pool for every row in accounts_to_delete. Although there is much else wrong with this example, from the bind variable perspective it should be re-written to use bind variables like:
    DECLARE
       l_sql  VARCHAR2(4000);
       l_acct NUMBER;
    BEGIN
       FOR r in (SELECT account_no FROM accounts_to_delete) LOOP
          l_sql := 'DELETE FROM accounts WHERE account_no = :b1';
          EXECUTE IMMEDIATE l_sql USING l_acct;
       END LOOP;
    END;However, since you cannot bind object names into sql statements, the difference in terms of the number of statements that end up in the shared pool between this:
    DECLARE
       l_sql VARCHAR2(4000);
    BEGIN
       FOR r in (SELECT table_name, delete_tab, trunc_tab
                 FROM tables_to_delete) LOOP
          IF r.delete_tab = 'Y' THEN
             l_sql := 'DELETE FROM '||r.table_name;
          ELSIF r.trunc_tab = 'Y' THEN
             l_sql := 'TRUNCATE TABLE '||r.table_name;
          ELSE
             l_sql := NULL;
          END IF;
          EXECUTE IMMEDIATE l_sql;
       END LOOP;
    END;and something like this:
    BEGIN
       DELETE FROM tab1;
       DELETE FROM tab2;
       EXECUTE IMMEDIATE 'TRUNCTE TABLE tab3';
    END;or this as a sql script
    DELETE FROM tab1;
    DELETE FROM tab2;
    TRUNCTE TABLE tab3;is absolutley nothing.
    Note that if you are truncating some of the tables, and wnat/need to use a stored procedure, you are going to have to use dynamic sql for the truncates anyway since trncate is ddl, and you cannot do ddl in pl/sql wiothout using dynamic sql.
    John

  • How to execute pl/sql block from a file

    hi all,
    can anybody tell me how to execute a pl/sql block from a file.it wont contain any procedures.it is of the form
    --begin
    --declare
    --end;
    Thanx

    Here is the file
    File is stored in C Drive (Windows Environment)
    declare
    x number;
    begin
    select 1 into x from dual;
    dbms_output.put_line(x);
    end;
    SQL> @c:\t.sql;
    1
    PL/SQL procedure successfully completed.Are you facing any issues?
    Regards,
    Bhushan

  • Collective PO Returns from Store

    Hi,
    I need to recall a product from all stores.
    Store will create the STO by a certain deadline.
    How can I gather all this return STO (Store >> DC) and assign with a collective PO.
    Ultimately, how many I collected will be returned to my Vendor.
    Can this be done?
    Bye

    Hi,
    Looks like your requirement will be satisfied using Allocation Returns Process.
    This in effect creates the returns STOs from the stores with the quantities and the corresponding PO to the Vendor from the DC.
    http://help.sap.com/erp2005_ehp_04/helpdata/en/12/08532c470311d1894a0000e8323352/content.htm
    Cheers,
    NT

Maybe you are looking for

  • How do I resolve duplicate contacts

    How do I resolve duplicate contacts in Address Book? I've used the Look for duplicates feature, but nothing shows up and there are clearly duplicates in my address book. I am using iCloud. Though didn't connect my desktop until recently. My iPhone an

  • I need help coding a form

    I need to code for a specific form, the only problem is i don't know much about coding for forms. here is the link to the form http://myenginebuilder.com/appointmentrequest.html any help would be appreciated

  • ME2M/ME2N/ME2L

    Hi All, I am having a requirement where we need to add a new outputs for these tcodes. After reading the SDN posts i understood we need to append structure to MEREP_OUTTAB_PURCHDOC. I  am not getting any clue as to where i to add the code for it get

  • Resetting the UIViewRoot

    I am navigating between a non JSF page and a JSFpage. The JSF page is backed by a session scoped bean. This is the scenario: 1. In the non JSF page, user clicks a button which navigates to a JSF page (I do a sendRedirect at the server side.. in my se

  • Dynamic SharePoint 2013 Dashboard Sizing

    Can SharePoint 2013 dashboards automatically scale in size based on the viewer's screen resolution? My company just began developing dashboards on SharePoint 2013 using PerformancePoint Dashboard Designer with reports built in Report Builder and Repo