Stored Procedures (what is it really used for?)

So from a tutorial, I successfully created a stored procedure, stored it, and made code to use it. I think.
If I run my code, it seems to work fine, regardless of whether or not I have entered that stored procedure into the database.
Is my code suppose to work regardless? Is storing a procedure just meant to make my code, which repeats quite often, more efficient? Or are stored procedures created for different reasons? Are they there to let me run my java code from an sql query? I'm at my wits end trying to understand the significance of a stored procedure. I've posted my code, if it helps.
public static void callSortTwo(Connection conn, CallList cl) {
        try {
            Timestamp ts = new Timestamp(System.currentTimeMillis() );
            System.out.println("Executed at: " + ts);
            String insert_query = "INSERT INTO SWEATY_BALLSAK.CALLS (" +
                    "beat," +
                    "call_descr," +
                    "priority," +
                    "date," +
                    "time," +
                    "call_num," +
                    "location," +
                    "status," +
                    "entry_id) " +
                    "VALUES(?,?,?,?,?,?,?,?,?)";
            PreparedStatement pstmt = conn.prepareStatement(insert_query);
            for (int counter = 0; counter < cl.getSize(); counter++) {
                String current_event[] = cl.getElementArray(counter);
                pstmt.setString(1,current_event[0]);
                pstmt.setString(2,current_event[1]);
                pstmt.setString(3,current_event[2]);
                pstmt.setString(4,current_event[3]);
                pstmt.setString(5,current_event[4]);
                pstmt.setString(6,current_event[5]);
                pstmt.setString(7,current_event[6]);
                pstmt.setString(8,current_event[7]);
                pstmt.setTimestamp(9, ts);
                pstmt.executeUpdate();
        catch(SQLException sqle_callSort) {
            System.out.println("SQL Exception" + sqle_callSort.getMessage() );
        }

Stored procedures use PL/SQL, not SQL, find and read something about it, it is very wide topic.
Stored procedures are often used for efficiency reasons. Simple example: if stored procedure contains several embeded SQL statements, database has to parse and precompile these SQLs only once, during procedure's compilation. Second, database always optimizes each SQL query before execution - but in the stored procedure it is done only once, during compilation. When you execute SQL from your program, RDBMS must parse and optimize this SQL each time, so using stored procedure you could save some (little) time on parsing and optimizing.
But when you want to do some kind of 'batch procesing' - execute one query to take some data from the table, analyze this data, prepare next SQLs based on retrieved data and so on, it's always better to do it in the stored procedure instead of the program, because you avoid transferring data through the network from database to program and back - you call simply stored procedure and all the processing is done in the database.
Oracle from ver. 9, beside PL/SQL has something called "Java stored procedures', so .... yes, you could write stored procedures in Java too :)

Similar Messages

  • What data type is used for storing password,

    What data type is used for storing pass word in oracle db, i mean if user inputs some thing from forms it should be in Encrypted form in db, please any help??
    Thank you
    Hina

    Data type is VARCHAR2:
    SQL> desc dba_users;
    Name                                      Null?    Type
    USERNAME                                  NOT NULL VARCHAR2(30)
    USER_ID                                   NOT NULL NUMBER
    PASSWORD                                           VARCHAR2(30)
    ACCOUNT_STATUS                            NOT NULL VARCHAR2(32)
    LOCK_DATE                                          DATE
    EXPIRY_DATE                                        DATE
    DEFAULT_TABLESPACE                        NOT NULL VARCHAR2(30)
    TEMPORARY_TABLESPACE                      NOT NULL VARCHAR2(30)
    CREATED                                   NOT NULL DATE
    PROFILE                                   NOT NULL VARCHAR2(30)
    INITIAL_RSRC_CONSUMER_GROUP                        VARCHAR2(30)
    EXTERNAL_NAME                                      VARCHAR2(4000)
    PASSWORD_VERSIONS                                  VARCHAR2(8)
    EDITIONS_ENABLED                                   VARCHAR2(1)
    AUTHENTICATION_TYPE                                VARCHAR2(8)You can use SQL function ORA_HASH to hash password: http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions124.htm#SQLRF06313.

  • Call a Stored Procedure that returns a REFCURSOR using ODI Procedure

    Hi,
    I have a scenario wherein the stored procedure (TEST_PROC1) that returns a REFCURSOR. The second procedure(TEST_PROC2) will use the REFCURSOR as inpuut and insert it to a table.
    Now, I need to execute the test procedures (TEST_PROC1 and TEST_PROC2) using the ODI Procedure but I always get error. However, I was able to execute the test procedures using sqlplus. Here is the command I used for sqlplus:
                   var rc refcursor
                   exec TEST_PROC1(:rc);
                   exec TEST_PROC2(:rc);
    PL/SQL Stored Procedure:
    -- TEST_PROC1 --
    create or replace
    PROCEDURE TEST_PROC1 (p_cursor IN OUT SYS_REFCURSOR)
    AS
    BEGIN
    OPEN p_cursor FOR
    SELECT *
    FROM test_table1;
    END;
    -- TEST_PROC2 --
    create or replace
    procedure TEST_PROC2( rc in out sys_refcursor ) is
    FETCH_LIMIT constant integer := 100;
    type TFetchBuffer is table of test_table2%RowType;
    buffer TFetchBuffer;
    begin
    loop
    fetch rc bulk collect into buffer limit FETCH_LIMIT;
    forall i in 1..buffer.Count
    insert into test_table2(
    c1, c2
    ) values(
    buffer(i).c1, buffer(i).c2
    exit when rc%NotFound;
    end loop;
    end;
    Is there a way to call a PL/SQL Stored Procedure that returns a REFCURSOR using ODI Procedure?
    Thanks,
    Cathy

    Thanks for the reply actdi.
    The procedure TEST_PROC1 is just a sample procedure. The requirement is that I need to call a stored procedure that returns a cursor using ODI and fetch the data and insert into a table, which in this case is test_table2.
    I was able to execute a simple SQL procedure (without cursor) using ODI procedure. But when i try to execute the SQL procedure with cursor in ODI, I encountered error.
    Do you have any idea how to do this?

  • What is iCloud storage used for?

    I am confused as to why I have been asked to upgrade iCloud storage to 500 GB. I am not clear as to what the storage is used for - is it my email account? My music? Photos? If anyone can help me understand this I will be very appreciative!

    Emails, photos, video from an iOS device could be stored in iCloud. Also documents you create from any apps.
    Who asked you to upgrade to a larger amount?
    iCloud storage upgrades and downgrades - Apple Support

  • HT4341 from the apple travel adapter kit what adapter do you use for thailand

    from the apple travel adapter kit what adapter do i use for thailand

    I've used Apple a few times in the past for 4x6s (with iPhoto) and was really happy with the quality. There are other things about the service that frustrate me though. The shipping time was all over the place. Sometimes it would only take a week or two, other times over a month. Unfortunately, I can't seem to get Order Prints to work for iPhoto or Aperture anymore, so I'm looking for an alternative as well. Something that has an Aperture plug-in would be extra cool, if that exists...
    In the meantime, I've just been printing at Wal-Mart or the local camera shop (when they have a sale). The quality isn't as good -- less definition in the prints -- but the order is always ready to pick-up within a couple of hours at the most (which beats getting no prints at all through Apple's service). And the nice thing is, the pictures are printed and boxed in the order they're uploaded. None of this "we print the smallest files first, as they download" silliness from Apple that causes you to have to sort all of your photos again while referencing the images on your computer if you want to put them in chronological order. Does Apple really expect me to believe their printers are just waiting to print my order the split second each image is downloaded? There's no staging process involved whatsoever? Give me a break. I love Apple, but things like this are so backwards from the whole "it just works" mantra that they love to use. Sorry for the rant! I'm a little frustrated with Apple's printing services at the moment (as I'm sure you can tell).
    Anyway, you can always give your local Wal-mart a shot. Just do a small order and see how it turns out.
    Doug

  • What is the plugin used for jsp/servlet development , deployment in eclipse

    what is the plugin used for jsp/servlet development , deployment in eclipse?
    can some body tell me what are the other plugins to be used in enterprise java developement
    is eclipse would be a best choice j2ee application development?
    thanks

    what is the plugin used for jsp/servlet development ,
    deployment in eclipse?There are several J2EE plugins I think. One is Lomboz.
    can some body tell me what are the other plugins to
    be used in enterprise java developementPfft...
    1) Might depend on what you're doing. J2EE is not just JSP, you know?
    2) Why do you ask about Eclipse IDE at Sun's Java Programming forum?
    3) Do you really want me to list the 5000 plug-ins someone might use for J2EE-related development?
    4) Open fucking Google and search yourself
    is eclipse would be a best choice j2ee application
    development?IMO: no. Simply because you have to look for J2EE plugins. I'm too lazy for that. Though it has other benefits that might outweigh the plug-in-searching issue.

  • My Time Capsule won't allow my computer to back up.  It says it is already in use but that is what it is being used for.

    My Time Capsule won't allow my computer to back up.  It says it is already in use but that is what it is being used for. It has been working fine for years.  All of a sudden I keep getting a message that TC (time capsule) cannot complete back up as it is already in use.  I am doing the backups automatically through Time Capsule.

    Restart the Time Capsule by disconnecting and reconnecting the power adapter. When it's back online, open the AirPort Utility application and check to see whether there's a firmware update for it.

  • How to find out what are the interfaces used for Job and Job Codes

    HI All,
    I just wanted to know how do we find out what are the interfaces used for Job and Job codes .
    Thanks In Advance
    Sunny

    Hi,
    Here is an idea for your request.
    Basically you can create a simple query on multiprovider 0TCT_MC01.
    Filter: you can use a variable for restriction of time ( calday, or calmonth) since you should be interested for a time period.
    Choose following characters into your objects:
    InfoProvider ( 0TCTIFPROV )  - you can create a variable for choosing infoprovider before query runs.
    *Tp.[Type of BI Application Object] 0TCTBISOTYP  = filter this with 'QUERY' or whatever your need is.
    *BI Application Object 0TCTBISBOBJ,  ( this will give you the name of the queries)
    In key figures choose,  Count for BI Appl. (0TCTWTCOUNT).
    (number for query run)
    Create a condition , for top 20.
    Hope this helps.
    Derya

  • What are the classes used for bropdownListBox in BSP and purpose and how

    what are the classes used for bropdownListBox in BSP and purpose and how
    thank you,
    Regards.
    Jagrut BharatKumar Shukla

    Benje001,
    Right-click on the CWAI control on your form. Choose Properties. The first tab is the Channels tab. After you choose your device from the drop down box on the right, you can type in the Channels box which channel you want to use.
    If you want to see a CWAI control that is already configured, all of the shipping examples will have this already done.
    Also, if you have questions about any item on the CWAI (or any other NI ActiveX control) you can click the ? icon in the right corner of the properties page and then click on the item in the dialog that you need help with. This "What's this" help will describe that particular control on the dialog.
    Hope that helps!
    Regards,
    Shannon R.
    Applications Engineer
    National Instruments

  • What format i should use for my external hard drive that can be used interchangeably between mac and pc?

    What format i should use for my external hard drive that can be used interchangeably between mac and pc?

    Usually Fat32/MS-DOS as mentioned, but that has several limitatiuns, like 4GB filesize limit.
    One option is MacDrive for you PCs... allows them to Read/Write HFS+...
    http://www.mediafour.com/products/macdrive/
    More options...
    NTFS-3G Stable Read/Write Driver...
    http://www.ntfs-3g.org/
    MacFUSE: Full Read-Write NTFS for Mac OS X, Among Others...
    http://www.osnews.com/story/16930

  • What format do I use for internal drive?

    I want to install a new internal harddrive into my Macbook.  What format should I use for it?
    Mac OS Extended (Journaled)
    Mac OS Extended
    Mac OS Extended (Case-sensitive, Journaled)
    Mac OS Extended (Case-sensitive)
    MS-DOS (FAT)
    ExFAT
    I know MS-DOS(FAT) is what I should use for external to work on mac and windows.  Can't remember which to use for the internal.  I have an Intel-based Mac.
    Thanks for your help.

    I use SuperDuper for cloning my OSX volumes and it does not change the size of the destination partition to the size of the source partition.
    So, you can make the destination partitions size to your liking and the cloning will not change it afterwards.
    Keep in mind that SuperDuper or Carbon Copy Cloner cannot clone a BootCamp Windows partition to a new harddisk, only OSX partitions.
    But Parallels doesn't need to have a Windows partitions but is mostly just two files plus the Parallels app on your OSX partition.
    And therefor it would be cloned with the rest of the OSX.
    Stefan

  • What setting should I use for Abbey Road drums?  Getting a cpu overload issue

    What setting should I use for Abbey Road drums (i.e. multi-output, stereo, etc)?  Getting a cpu overload issue.  I have a macbook pro, 4 gb ram, running Logic Pro 9.  Just 3 tracks of drums and a few real instrument tracks.  Can't find a guide in the manual for either Kontakt or Logic.  Thanks in advance!

    Hi
    AR drums are complete resource (CPU) hogs. They work better if you turn off as many of the AR internal plugins as you can.
    See section 4 (?) of the AR manual, which you can find within Kontakt (In the library area of Kontakt click hold the small "i" on the right of the "AR drummer" Library).
    Alternatively, your only solution is to increase the I/O buffer in Preferences:Audio, with the associated increase in latency
    CCT

  • What is the method used for upload of  data

    Hi All,
    What is the method used for upload of  Data from excel spread sheets to SAP HR.
    it is Bulk Data from many countries.LSMW or BDC Session Method?
    what are country specific infotypes used for PA and OM.
    can u plz give the list of country specific infotypes used for PA n OM Module.
    Thanks
    Archana

    Hi Archana,
    To Upload bulk data I think BDC is the best and effecient way.
    Regarding Infotypes we dont have any country specific Infotypes in OM & PA. In Payroll we do have according to country wise.
    I hope you had understood the point
    Regards
    Pavani
    Remainder: Points to be given on answers

  • What are the tables used for this Report

    hi all..
    i am a fresher for ABAP. i need the help.
    what r the tables used for this report.
    Reports provide pending order details according to Material wise and customer wise for particular month.
    thanks in advance
    RK.Ashokkumar.
    9994262112.

    hi
    good
    try with these tables,
    MARA
    KNA1
    thanks
    mrutyun^

  • What Metadata Standard is used for Face Regions?

    Nice to see that LR6 now has support for Face Recognition and Face Regions. However, nowhere in the online help is it stated explicitly what metadata standards are used for the image regions.
    I would hope that as Adobe is a member of the Metadata Working Group, then LR6 is using the metadata standard specified by the MWG for image regions.

    It's the MWG.
    Within Lightroom itself, the face regions are recorded inside the catalogue and this data is associated with keywords.
    When you export a photo, unchecking the option Remove Person Info, the names are also written to the IPTC Extension Person Shown and the MWG Regions too.
    I suggest you export a photo as above and examine its metadata in the Advanced tab of Bridge's FIle Info dialog box, or in some other metadata tool.

Maybe you are looking for

  • Why did 4.3 cause the recopying of all my photos?

    Downloaded and installed IOS 4.3 with no problems on two phones, my iPhone 4 and my wife's 3Gs. But for both phones, subsequent syncs included the re-copying of all our photos. No problems with the photos, but does anyone know why the recopying? Than

  • How to make InfoObject 0SBO_ALTACT attribute of 0GL_ACCOUNT

    Dear all, Anyone who knows a workable approach for providing the Alternative Account Number for navigation in New G/L Reports? The field in ERP is: SKB1-ALTKT There is an IOBJ called 0SBO_ALTACT (is that the one to use?) I need Text and Attributes (r

  • I Tunes is in chinese how do I change it back to english

    itunes home screen is in Chinese how do I chnage to english?

  • Sound card error code10 - Satellite Pro A300-1PK PSAGRE

    Sound card is not working and error message appears as below during driver (realtek driver) installation. " Device can not start. code 10) In the device manager, yellow ! mark appears.

  • XMP definition in XMP

    Hello everyone, the development for XMP could be much easier if we had XMP definition in XMP For example one could create GUI for XMP editing even without reading XMP ducumentation. All we need is to parse XMP tree and translate metadata to appropria