Can we use dbms_output.put_line package with forall statement

Hello Everybody
Can we use dbms_output.put_line package with forall or can we use insert,update and delete only
declare
type emp_rec is table of emp%rowtype
index by binary_integer;
t emp_rec;
begin
select * bulk collect into t from emp;
forall i in t.first..t.last
dbms_output.put_line(t(i).name);
end;Thanks & Regards
peeyush
Edited by: Peeyush on Nov 25, 2010 11:45 PM

MichaelS wrote:
Well as the docs explain (though not very clear and detailed, I admit) you can use a dynamic sql statement (execute immediate) with FORALL.You got me interested in the performance side doing this Michael - running PL/SQL code via a FORALL loop.
It is faster than using a normal FOR loop to execute dynamic PL/SQL - a bit surprising as I expected another context switch to be in there. But seems like the PL/SQL engine is a more clever at optimisation than what I originally credited it with.. ;-)
Of course - pre-compiled/static PL/SQL code in a FOR loop is the fastest, as expected.
SQL> declare
  2          type TNumbers is table of number;
  3 
  4          type TTimes is record(
  5                  for_all number,
  6                  for_dynamic number,
  7                  for_static number
  8          );
  9 
10          type TTimesTable is table of TTimes;
11 
12          MAX_ITERATIONS  constant number := 10;
13 
14          plBlock         varchar2(1000) :=
15          'declare i number;
16          begin i:= :var / 10; end;';
17 
18          performance     TTimesTable;
19          t1              number;
20          bindVar         TNumbers;
21          n               number;
22  begin
23          select
24                  level bulk collect into bindVar
25          from    dual
26          connect by level <= 10000;
27 
28          dbms_output.put_line( 'Iterations: '||bindVar.Count||' for loop cycle(s)' );
29 
30          performance := new TTimesTable();
31          performance.Extend( MAX_ITERATIONS );
32 
33          for j in 1..MAX_ITERATIONS
34          loop
35                  t1 := dbms_utility.get_time;
36                  forall i in 1..bindVar.Count
37                          execute immediate plBlock using bindVar(i);
38                  performance(j).for_all := dbms_utility.get_time-t1;
39 
40                  t1 := dbms_utility.get_time;
41                  for i in 1..bindVar.Count
42                  loop
43                          execute immediate plBlock using bindVar(i);
44                  end loop;
45                  performance(j).for_dynamic := dbms_utility.get_time-t1;
46 
47                  t1 := dbms_utility.get_time;
48                  for i in 1..bindVar.Count
49                  loop
50                          n := bindVar(i) / 10;
51                  end loop;
52                  performance(j).for_static := dbms_utility.get_time-t1;
53          end loop;
54 
55          dbms_output.put_line( 'Times in 100th of a second' );
56          dbms_output.put_line( rpad('for all',15) || rpad('for dynamic',15) || rpad('for static',15) );
57          for i in 1..performance.Count
58          loop
59                  dbms_output.put_line(
60                          rpad( performance(i).for_all, 15 )||' '||
61                          rpad( performance(i).for_dynamic, 15 )||' '||
62                          rpad( performance(i).for_static, 15)
63                  );
64          end loop;
65 
66  end;
67  /
Iterations: 10000 for loop cycle(s)
Times in 100th of a second
for all        for dynamic    for static
10              72              0
6               37              0
6               37              0
6               37              0
6               36              0
6               37              1
5               37              0
5               37              0
6               37              1
5               37              0
PL/SQL procedure successfully completed.
SQL>

Similar Messages

  • Can I use the dbms_application_info package with ADF BC?

    Hi,
    I am executing a PL/SQL package from my ADF BC Application module and need to set some audit information within the PL/SQL. The package does some intensive background processing that would be time consuming to do in ADF. Can I use the dbms_application_info pakage to store session information for the user?
    I am not sure if the application module has a true database session with the database or is it pooled/shared with other users that may be logged on to the application?
    I want to use dbms_application_info.set_client_info and dbms_application_info.read_client_info.
    thanks,
    Brenden

    >
    If I created the new user what are the privileges shoud I grant him.You should grant EXPORT FULL DATABASE for exporting and IMPORT FULL DATABASE for importing.
    >
    I created one user testdba and granted DBA privileges as well full_export_database.
    after that I run catexp.sql with sys credential.
    While running the schema level export using testdba I am getting the below error:
    My Export scripts is
    exp testdba/password FILE=ALLEDW_edw2.dmp log=ALLEDW_edw2.log owner=ALLEDW grants=y indexes=y direct=y compress=y
    EXP-00008: ORACLE error 4068 encountered
    ORA-04068: existing state of packages has been discarded
    ORA-04063: view "TESTDBA.V_$OPTION" has errors
    ORA-06512: at "SYS.DBMS_AW", line 151
    ORA-06512: at "SYS.DBMS_AW_EXP", line 225
    ORA-06512: at line 1
    EXP-00083: The previous problem occurred when calling SYS.DBMS_AW_EXP.schema_inf
    o_exp
    EXP-00008: ORACLE error 980 encountered
    ORA-00980: synonym translation is no longer valid
    ORA-06512: at "SYS.DBMS_RULE_EXP_RULES", line 133
    ORA-06512: at line 1
    EXP-00083: The previous problem occurred when calling SYS.DBMS_RULE_EXP_RULES.sc
    hema_info_exp
    . exporting foreign function library names for user ALLEDW
    . exporting PUBLIC type synonymsDo You have any invalid objects in database?
    recompile them with $OARCLE_HOME/rdbms/admin/utlrp.sql

  • Printing messages in Log File and Output File using Dbms_output.put_line

    Hi,
    I have a requirement of printing messages in log file and output file using dbms_output.put_line instead of fnd_file.put_line API.
    Please let me know how can I achieve this.
    I tried using a function to print messages and calling that function in my main package where ever there is fnd_file.put_line. But this approach is not required by the business.
    So let me know how I can achieve this functionality.
    Regards
    Sandy

    What is the requirement that doesn't allow you using fnd_file.put_line?
    Please see the following links.
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Dbms_output.put_line+AND+Log+AND+messages&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    https://forums.oracle.com/forums/search.jspa?threadID=&q=%22dbms_output.put_line+%22+AND+concurrent&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • Printing blank spaces using dbms_output.put_line

    There is one string getting generated dynamically. Upon generation, it may or may not contain blank spaces in the beginning. Then I am trying to print this on standard I/O using DBMS_OUTPUT.PUT_LINE. But if there are some leading spaces in the string, they are ignored. Is there any other way to print the exact string as it is?

    hi..
    it's depend on your client configuration.. you can configure the wrap option at the serveroutput parameter...
    set serveroutput on size 100000 for wrap;
    begin
      2    dbms_output.put_line('  Hello world.');
      3  end;
      4  /
      Hello world.
    PL/SQL procedure successfully completed.

  • Can I use a flash drive with my iPad?  If yes, what kind?

    Can I use a flash drive with my iPad?  If yes, what kind?

    Actually, and to clarify, the Lightning to sd card camera reader does not have a usb port in any shape.
    The Lightning to usb camera adapter is the one that has the USB port. (its an entirely different product)
    http://store.apple.com/us/product/MD821ZM/A/lightning-to-usb-camera-adapter?fnod e=3a
    The old 30 pin Camera connection kit, had a USB port adapter as well as the sd card reader in the same package.
    In any case, if the iPad you bought is an iPad 4, then no you{ll need to decide if you want an Sd card reader or the actual USB port.
    If its an iPad 2 then the camera connection kit will offer the usb port in the box.
    However as was already mentioned, and with either product you can only transfer pictures in a very specific format.

  • How can I use my Apple ID with 2 Apple devices?

    I just got an ipad mini and I registered it with the same Apple ID I use for my iphone 4s. Everything was fine until I downloaded apps to the ipad and noticed that the ones I had on both devices  no longer opened on my iphone. Why is this? How can I use my Apple ID with 2 Apple devices and how can I recover my apps on my iphone?

    I've had an iPad for almost two years. When I purchased an iPhone last fall I set it up to use the same Apple ID as my iPhone. I've had no problems doing this. Try resetting each device and see what happens.
    First thing to try is to reset your device. Press and hold the Home and Sleep buttons simultaneously ignoring the red slider should one appear until the Apple logo appears. Let go of the buttons and let the device restart. See if that fixes your problem.

  • How can i use my apple ID with the itune store over my windows laptop

    how can i use my apple ID with the itune store over my windows laptop

    If you don't have iTunes installed on your laptop then you can download and install it from here : http://www.apple.com/itunes/download/
    You can then log into your account on it via the Store > Sign In menu option (on iTunes 11 on a PC you can get the menus to show via control-B) :
    And you can then select the Store on the left-hand sidebar (you can enable the sidebar via control-S), and then browse items in the store and buy them by clickin on their price.

  • Can I use an USB disc with my macbook pro bought in 2005.  What capacity will it take 2.00 or 3.00?

    can I use an USB disc with my macbook pro bought in 2005.  What capacity will it take 2.00 or 3.00?

    The first MacBook Pro's were not released until the beginning of 2006, and they had USB 2 ports.
    Anything available new in 2005 would have been a PowerBook G4 and they also had USB 2 ports.
    A USB 3 disk will just transfer data slower then it could do, if you plug it into a USB 2 port though, so you can buy either.

  • I am new to IPAD and I want o use facetime, how can I use it to communicate with my mac at home, do I need to create another account with a different email account

    I am new to IPAD and I want o use facetime, how can I use it to communicate with my mac at home, do I need to create another account with a different email account

    do I need to create another account with a different email account
    Yes, the email addresses need to be unique to each device. You may use the same Apple ID on each device, but the email address used by each device needs to be different.

  • How can I use my time capsule with windows7

    How can I use my time capsule with windows7?

    This is asked regularly.
    https://discussions.apple.com/message/10978060#10978060
    Look at the more like this. On the right column next to the post.
    Load airport utility for windows.. which will also load bonjour for windows.
    In windows explorer type \\TCname or \\TCipaddress (replacing with the actual values.. names with spaces will give you trouble so change all names in the TC to SMB compatible or actual ip address).

  • New to Apple products (finally) - can I use my Itunes account with multiple products e.g. Iphone and Ipad?

    New to Apple products (finally) - can I use my Itunes account with multiple products e.g. Iphone and Ipad?

    Oh yes! Apple will be happy for you to buy as many Apple products as you can afford.
    As and when needed, each can be given its own selections of content to sync with.
    tt2

  • Can i use two apple tvs with one itunes account?

    can i use two apple tvs with one itunes account?

    yes and you can use more then 2
    just don't give them the same name

  • Can you use 2 Thunderbolt Displays with Windows 7/Bootcamp on a Early 2011 Macbook pro?

    Can you use 2 Thunderbolt Displays with Windows 7/Bootcamp on a Early 2011 Macbook pro?
    I have 2 and cannot seem to get them to work?

    Can you use 2 Thunderbolt Displays with Windows 7/Bootcamp on a Early 2011 Macbook pro?
    I have 2 and cannot seem to get them to work?

  • I was trying to get the iOS 8.2 on my iPhone 5 but then it stopped and my phone is now on recovery mode I have pictures I need and they did not all fit on iCloud  how can I use the phone again with ALL my pictures and videos without restoring it?

    I was trying to get the iOS 8.2 on my iPhone 5 but then it stopped and my phone is now on recovery mode I have pictures I need and they did not all fit on iCloud  how can I use the phone again with ALL my pictures and videos without restoring it?

    Contacts are designed to be synced to a supported application on the computer or a cloud service.
    Pictures taken with the device are designed to regularly be copied off the device to a computer as would be done with any digital camera.
    If you have failed to use the device as designed it may be too late to recovery anything.
    Is the device regularly backed up to a computer via iTunes?  If so, the most recent backup (when restored to a replacement iOS device) should contain all contacts and pictures as of when the backup was created.

  • Can I use two different devices with different apple ID for backing up data on one machine without losing any data that was backed up with one device earlier?

    Can I use two different devices with different apple ID for backing up data on one machine without losing any data that was backed up with one device earlier?

    The link is to a discussion started on 12/18 in the FiOS Internet forum.  Here's the link I get now, however it is different than the link I pulled a few hours ago.  If this system changes the link again, it may not work.
    http://forums.verizon.com/t5/FiOS-Internet/Frustration-and-just-confused-with-internet-help-please/t...
    You can also look for the topic, "frustration and just confused" in the FiOS Internet forum.
    Here's a link that is in the thread that gives more detail.
    https://secure.dslreports.com/faq/15984
    Good Luck!
    P.S.  "Copper Contributor" is my "rank."  gs0b is my user name.
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.

Maybe you are looking for

  • Shadows doesn't work. How to fix it?

    When I go to Edit > Adjust > Shadows and start the slider to brighten the photo, the screen goes blank. This is a much-used feature. I haven't used the Macbook for a few months, and I've updated software; it worked before. I want to improve some pix

  • How do you slow down audio files?

    Hey everyone! I was wondering if there is a way that you can slow down audio (not midi) in Logic. I really need that ability so I can start transcribing a lot of pieces for my music lessons... If Logic doesn't have anything like that, is there a free

  • Problem with data output stream

    in the code output.writeBytes(String arg); output.writeInt(Int arg); output.writeLong(dateOfPurchase.getTime());the first line is working fine ,but the other two line ,even though it writes something to the file it is not in a readable format can any

  • Explict cursor state in a serially_reusable package

    hi all below there's a modified example taken from the Oracle documentation: CREATE TABLE people (name VARCHAR2(20)); INSERT INTO people (name) VALUES ('John Smith'); INSERT INTO people (name) VALUES ('Mary Jones'); INSERT INTO people (name) VALUES (

  • Perform different actions on click of popup buttons

    Hi, I am Using <af:popup id=""><af:dialog type="okCancel" title=""> combination pop up. I want to navigate to different pages, say "one.jspx" and "two.jspx" when i click on 'OK' and 'cancel' buttons. can any one help on this please... Regards Syamala