Why do I have to use SELECT INTO clause in a Stored Proc ?

Hi,
I'm new to oracle. I've bought Oracle Database 10g SQL and Oracle Database 10 A beginner's Guide, two books from Oracle press but I can't find any answer for that.
Why when I'm writing a Stored Procedure with a SELECT statement do I have to use an INTO clause ?? And why when the select returns more than one row do I have to use a cursor ? By the way is this the only way to return more than one row from a stored procedure ?
Any help will be appreciated.
Regards.
S. Nunes

Sounds like you may have some experience with other databases (SQL Server, maybe?) which allow you to create stored procedures which implicitly return result sets simply by embedding select statements.
In Oracle, the correct way to do this is using ref cursors.
See the following link for a good explanation:
http://osi.oracle.com/~tkyte/ResultSets/index.html

Similar Messages

  • Why do i have to use nextLine() when there is an InputMismatchException

    I dont understand why do i have to use this line of code to avoid an infinite loop here...help appreciated.
    import java.util.Scanner;
    import java.util.InputMismatchException;
    public class InputTest {
         public static void main(String [] args){
         Scanner in = new Scanner(System.in);
         int n = 0;
         while(true){
              try{
                   System.out.println("Input a number:");
                   n = in.nextInt();
                   break;
              }catch(InputMismatchException exc){
                   System.out.println("Error, non-valid input.");
                   //in.nextLine(); <--If i use this line of code it doesn't get into an infinite loop
                             System.out.println("Integer read is: " + n);
    }

    Rix87 wrote:
    When i run the program if i input something that triggers the exception, it infinitely loops through the question and the catch method block outputs, weirdest thing of all is that i can't even input again after the exception is thrown, but with nextLine() it avoids that, but i still dont understand why do i have to use nextLine().Exactly what I said.
    You enter "A". The exception is thrown. The "A" is not consumed. It calls nextInt on "A" again... and again... and again...
    If you do nextLine, the "A" and the newline are consumed.
    Even on good input, I don't think nextInt consumes the EOL.

  • Using SELECT INTO statement to transfer data from one DB to another?

    Hello,
    I need to move data from an SAP table to another downstream SQL server box without flat file in between. I have set up the DBCON interface, so that my ABAP code on SAP can connect to the remote SQL Server, then I can run INSERT command as Native SQL inside the ABAP.
    However, INSERT has performance problem. The best performer as I can find is SELECT INTO statement. But then I am stuck at how to use SELECT INTO to query my local SAP table and send (via INTO) to remote database. I am not even sure whether I should use Open SQL or Native SQL.
    Any suggestion? BTW, I understand the limitation of Native SQL, but we are OK to use it.
    Thanks!

    It appears that this is some kind of migration project due to the scope of the data contained in the single file? If so whatever you do is like ly to be trow away once the migration of data is completed.
    You have a couple of options:
    1) Get the data extracted from HFM in multiple files instead of one bulk file, broken down by scanario,year & period
    2) Take the single data dump file produced by FDM and manipulate it yourself to get the data in a more usuable format for processing through FDM.
    Option 2 could be achieved via any ETL tool or a custom file parsing script. What may be more attractive to you and allow you to fully leverage your investment in FDM is that you could use the PULL adapter that ships as part of the FDM adapter suite to perform this transformation exercise. The PULL adapter takes a flat file input and allows you to use all the in built functionality of FDM to transform it and output a modified flat file (or series of flat files). You could use it to produce multioload files or a series of files broken down by scenario,year,period.
    Whatever you do I would suggest that break the single data file down into smaller chunks as this will help with the iterative debugging process you will inevitably have to undetake whislt migrating the data to the new application.

  • HT201250 Why do i have to use the password for time capsule every time i start my computer

    Why do I have to use thr password for time capsuel every time I start my imac?

    With hindsight, the previous response I got from Apple was just a way of shelving the problem.
    Having just had to reset my password after another 3 months, I contacted Apple again, and it happened that the senior advisor whom the phone agent consulted had had exactly the same problem as me, and had found that iTunes could fix it.  However when I spoke to iTunes they told me I needed to speak to Apple ID account security.  The Apple ID account security representative spoke to a senior adviser, then told me that it would be fixed after I reset my password.  However I am not convinced that anything was actually done, so I may be back here in another 3 months ...
    To modify Roger's advice, the solution I was given is: go to https://expresslane.apple.com ; select 'All Products and Services' in the first column, 'iTunes' in the second column, 'iTunes Store' in the third column, then "Account Management" and "Apple ID account security", then "Talk to Apple support now". A complication is that the "Talk to Apple support now" option only appears when UK English is selected.  So you either need to select UK at the top, or find another way of making phone contact (the email link just went back to the person in iTunes)!

  • WHy should we have to use to update ipod touch

    WHy should we have to use to update ipod touch

    Your question does not make sense. Please clarify.
    GamingChamp wrote:
    WHy should we have to use to update ipod touch

  • Why do I have to use silverlight to view Netflix movies?

    I'm wondering why I have to use Silverlight to play Netflix movies. When I opened Netflix and selected a movie to play in my Firefox browser a gray page opened up and the only option was to play the movie using Silverlight. I have a sneaking suspicion that it's a requirement by Netflix as Netflix is partnered up with Silverlight, a Microsoft product and has some sway over what's able to be played with this addon. Why is there no alternative. I really like the new Firefox but still we're wanting for just a little more control of who does what on our machine.
    Respectfully,
    Tom V.

    Netflix determines which program their movies are to use. Firefox has no control over it.

  • Why do we have to use SwingUtilities.invokeLater() to update UI status?

    I just don't understand very well why we have to use SwingUtilities.invokeLater() to update UI status. Why not just new a thread in actionPerformed() method and do time consuming tasks in this thread and update UI status in it? Some tutorials say it is not safe to update UI status not in Event Dispatch Thread, I don't understand, why is it not safe? Can anyone provide a scenario for this? I just write an example, a button and a progressbar, click button, progressbar keeps updating value. I just create a new thread to do this, don't find any issue. Thanks.

    [Swing single threaded rule|http://www.lmgtfy.com/?q=swing+single+threaded+rule]
    db

  • When and why do i have to use a Network-Path?

    Hello,
    i'm wondering when i why i have to use a Network-Path in KM.
    I'm able to connect to a File-System Repository, even if i have no Network-Path defined.
    - both run on W2K Server
    - EP runs on host EP (not an Domain-member)
    - Filesystem is provided by host FS (Domain-member)
    - EP is started with the default local-user SAPServiceEP6
    - on the FS host, i have defined also a local-user SAPServiceEP6 (because EP always wants to logon with these credentials, i have checked this in the windows securitylog of host FS)
    - no network-path defined
    So regarding the fact, that everything is working, can anybody tell me when i have to use a Network-Path?
    Thanks in advance
    Frank

    Hi,
    for example if you want to access a share that only access is granted for a given user. The idea is having a superuser with privileges on the other computer to do things like checking ACLS.
    Another example, how can you access windows shares when running the portal in Unix? Using a network path.
    REgards,
    Miguel

  • Using select * into within a function

    What I'm wanting to do is to have a select query with many select fields and automatically create a new table (with the same schema) and insert the select result set in this new table.
    I can't seem to figure it out and doing the EXECUTE 'select * into dest_table from orig_table'; wouldn't work (not implemented yet).
    One reason I would like to do it this way is because the field attributes of orig_table may be different from one client to another.
    Thanks for any advice.

    Thanks very much.
    When I tried the execute immediate '...'; in the function I got an error stating: 'type "immediate" does not exist
    I tried to do some research on 'execute immediate' to see what might be the problem but couldn't find anything substantial to my cause.
    I just installed postgreSQL 8.2 this afternoon, and took all the installation defaults, so it may be something I need to configure.
    Anways, however, I just took the actual sql from the execute immediate call and that worked for me.
    Are there any pitfalls to doing it that way.
    Again, thanks for your quick and helpful reply.

  • Why do I have to use security code for wifi router each time I turn on iPad 3?

    Why do I have to enter wifi security code for my router each time I turn on ipad3?  I have checked all the settings I could but is this a router problem?

    If you're hiding your network SSID and/or using WEP security, I think these can cause this problem.  If you're hiding your SSID, there's really no point in doing that since there are ways people can easily see it if they're looking to do harm anyway.  If you're using WEP security, consider changing to WPA2 which is much more secure than WEP.

  • Why sometimes we have to use two message( ) to display one message ?

    Sometimes one message( ) function is not working properly ? We have to use two message( ) to display one message ? Why ?

    And just to add a little on what dave said:
    You can also detect which button the user has clicked and do some action accordingly.
    DECLARE
    al_id ALERT;
    al_result NUMBER;
    BEGIN
      al_id := Find_Alert('MESSAGE');
      SET_ALERT_PROPERTY(al_id, ALERT_MESSAGE_TEXT, 'your message here');
      al_result := Show_Alert(al_id);
      IF al_result = ALERT_BUTTON1 THEN
         ...  --do some action.
      END IF;
    END;

  • Need help with query that uses 'SELECT INTO'

    Hi guys,
    I am trying to duplicate the values of a table to another by using the script below:
    ACCEPT TBSNAME           CHAR PROMPT 'Tablespace name>'
    PROMPT Connect As System
    Connect system
    CREATE TABLE FREESPACE
         TABLESPACE_NAME          VARCHAR(20)          NOT NULL,
              CONSTRAINT FREESPACE_PKEY PRIMARY KEY(TABLESPACE_NAME),
         TOTAL_FREE_STORAGE     NUMBER(10)          NOT NULL
    ) TABLESPACE USERS;
    SELECT     TABLESPACE_NAME,
              SUM(BLOCKS) TOTBLOCKS
    INTO      FREESPACE
    FROM      SYS.DBA_FREE_SPACE
    WHERE      TABLESPACE_NAME = UPPER('&TBSNAME')
    GROUP BY TABLESPACE_NAME;
    However, when I execute this script, I was prompted with the 'missing keyword' error which happens at the third line of the select statment. Any idea what's missing here?
    Thanks in advance.

    If you mean "fill up the table FREESPACE" by using "select...into..." then it is totally wrong. You cannot do it in plsql also.
    Use this:
    insert into freespace(tablespace_name,total_free_storage)
    SELECT TABLESPACE_NAME,SUM(BLOCKS) TOTBLOCKS
    FROM SYS.DBA_FREE_SPACE
    WHERE TABLESPACE_NAME = UPPER('&TBSNAME')
    GROUP BY TABLESPACE_NAME;
    Message was edited by:
    Yas

  • Why do I have to use the tab key even more to tab between page elements.

    Firefox versions prior to ver 4 I used the tab key to tab between page elements (form elements, buttons, etc). I upgraded to ver 4 and now when I tab from form element to form element I first see a gray line outlining the element area and then another press of the tab the element becomes active for me to use. I now have to use double the tab keys to move between form elements.

    Hello new_mac_user, see if the next works
    # In the [[Location bar autocomplete|Location bar]], type '''about:config''' and press '''Enter'''. The about:config "''This might void your warranty!''" warning page may appear.
    # Click '''I'll be careful, I promise!''', to continue to the about:config page.
    # in search field type (or copy/paste from here) '''accessibility.tabfocus'''
    # double-click on it and change the value to '''4''' (probably you have 1 the default on mac)
    # click ok, exit firefox and restart it.
    with the above you give focus to links (and linked images) only when you press the tab key.
    see for more info : http://kb.mozillazine.org/Accessibility.tabfocus
    https://developer.mozilla.org/en-US/docs/Mozilla/Preferences/Preference_reference/accessibility.tabfocus
    thank you

  • Why do I have to use command O to open things in yosemite

    Updating to Yosemite I now have to use command O to open things now as double clicking them doesnt work. Anyone else have this issue?
    Thanks

    Maybe a Restart will help. I can double-click anything to open it on Yosemite.

  • Why do I have to re-sign into Pogo games?

    Every day I have to re-sign into Pogo Games with my user name & password. I installed Firefox solely so I could play games on the site because IE is not compatible with needed Java version. I have saved the cookie and am able to go in & out during the day as long as I haven't shut down the computer. I know it's a minor issue but is there anything I can do to avoid it?

    HI...
    If you are running v10.7 Lion, open System Preferences > General
    Deselect:  Restore windows when quitting and re-opening apps
    When you post, it really helps to tell us which Mac OS X you have installled  

Maybe you are looking for

  • ECC 6.0 installation o WIndows 2003 Ent R2 on SQL 2005

    Hello Folks, As mentioned in subject line, I am in middle of the installation. I have got error in phase "Run ABAP Reports". The error is mentioned in the file dev_slic file which I have pasted below. It is not able to drop an index to create a tempo

  • Trying to install Lightroom 5 with CC but getting error code 5 on initial startup of Lightroom.

    Trying to install Lightroom 5 with CC but getting error code 5 on initial startup of Lightroom. Have uninstalled all adobe products including Creative Cloud CC. Followed the instructions on the forum by using the CC Cleaner App for OSX. Have restarte

  • Numbers 3.5 export to PDF creates single page

    When I export a Numbers 3.5 sheet to PDF, the PDF shows up as a long single file. How do I break this up either in Number or in Adobe Acrobat? It seems very odd that there is no evident way to to do this in Numbers so that it will export this way? Is

  • Mapping the PP scenario

    Dear PP Gurus, Please guide me to map the following scenario: ABC is a company dealing with Manufacturing Of Refrigerators to their customer which includes Model 1  & Model 2. Based on the historical data of sales to Model 1 Model 2, the ABC Producti

  • Help report based in colums lov

    Hi, I'm trying to create a report and create a filter for columns and the value of these column, it's something like that: P52_C1 (select list) return the name of the columns of the table. LOV: select column_name display_value, column_name return_val